File 0002-Report-INVALID_SOURCE-if-the-move-fails.patch of Package kolab-syncroton

From 0a8e797ea62be331a2530440e45cc1c9edc786ee Mon Sep 17 00:00:00 2001
From: Christian Mollekopf <mollekopf@apheleia-it.ch>
Date: Tue, 30 Aug 2022 16:21:45 +0200
Subject: [PATCH 2/2] Report INVALID_SOURCE if the move fails

A nonexistent source message is at least one reason for the failure,
and returning SUCCESS without a destination msgid is clearly not
correct.
May fix an iphone issue where it keeps sending the same move command
over and over.
---
 lib/ext/Syncroton/Command/MoveItems.php | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/ext/Syncroton/Command/MoveItems.php b/lib/ext/Syncroton/Command/MoveItems.php
index 73e57dd..3f89b34 100644
--- a/lib/ext/Syncroton/Command/MoveItems.php
+++ b/lib/ext/Syncroton/Command/MoveItems.php
@@ -79,9 +79,12 @@ class Syncroton_Command_MoveItems extends Syncroton_Command_Wbxml
                 $dataController = Syncroton_Data_Factory::factory($sourceFolder->class, $this->_device, $this->_syncTimeStamp);
                 $newId          = $dataController->moveItem($move['srcFldId'], $move['srcMsgId'], $move['dstFldId']);
 
+                if (!$newId) {
+                    throw new Syncroton_Exception_Status_MoveItems(Syncroton_Exception_Status_MoveItems::INVALID_SOURCE);
+                }
+
                 $response->appendChild($this->_outputDom->createElementNS('uri:Move', 'Status', Syncroton_Command_MoveItems::STATUS_SUCCESS));
-                if ($newId)
-                    $response->appendChild($this->_outputDom->createElementNS('uri:Move', 'DstMsgId', $newId));
+                $response->appendChild($this->_outputDom->createElementNS('uri:Move', 'DstMsgId', $newId));
             } catch (Syncroton_Exception_Status $e) {
                 $response->appendChild($this->_outputDom->createElementNS('uri:Move', 'Status', $e->getCode()));
             } catch (Exception $e) {
-- 
2.37.1