]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Delivery.php
Merge remote-tracking branch 'upstream/develop' into no-item
[friendica.git] / src / Worker / Delivery.php
index d5a3e8f5cb9259b0ad351fb33f6a9b2021f9587e..e2db058ea51969ba02560339ee9dd84f89d3664e 100644 (file)
@@ -36,6 +36,7 @@ use Friendica\Core\Worker;
 use Friendica\Model\Conversation;
 use Friendica\Model\FContact;
 use Friendica\Model\Item;
+use Friendica\Model\Post;
 use Friendica\Protocol\Relay;
 
 class Delivery
@@ -50,9 +51,27 @@ class Delivery
        const REMOVAL       = 'removeme';
        const PROFILEUPDATE = 'profileupdate';
 
-       public static function execute($cmd, $target_id, $contact_id)
+       public static function execute(string $cmd, int $post_uriid, int $contact_id, int $sender_uid = 0)
        {
-               Logger::info('Invoked', ['cmd' => $cmd, 'target' => $target_id, 'contact' => $contact_id]);
+               Logger::info('Invoked', ['cmd' => $cmd, 'target' => $post_uriid, 'sender_uid' => $sender_uid, 'contact' => $contact_id]);
+
+               if (!empty($sender_uid)) {
+                       $post = Post::selectFirst(['id'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
+                       if (!DBA::isResult($post)) {
+                               Logger::warning('Post not found', ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
+                               return;
+                       }
+                       $target_id = $post['id'];
+               } elseif (!in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
+                       $post = Post::selectFirst(['id', 'uid', 'uri-id'], ['item-id' => $post_uriid]);
+                       if (DBA::isResult($post)) {
+                               $target_id = $post['id'];
+                               $sender_uid = $post['uid'];
+                               $post_uriid = $post['uri-id'];
+                       }
+               } else {
+                       $target_id = $post_uriid;
+               }
 
                $top_level = false;
                $followup = false;