]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Notifier.php
Merge pull request #10190 from annando/api-attached
[friendica.git] / src / Worker / Notifier.php
index 896916ede6fbdf445399ae0640338ebe0f4c6a7a..60a5572ca5035c09a634d7676a03b97c42d9d59a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -60,23 +60,6 @@ class Notifier
                Logger::info('Invoked', ['cmd' => $cmd, 'target' => $post_uriid, 'sender_uid' => $sender_uid]);
 
                $target_id = $post_uriid;
-
-               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'];
-                       }
-               }
-
                $top_level = false;
                $recipients = [];
                $url_recipients = [];
@@ -117,6 +100,13 @@ class Notifier
                        $condition = ['uid' => $target_id, 'self' => false, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
                        $delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'addr', 'network', 'protocol', 'batch'], $condition);
                } else {
+                       $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'];
+
                        // find ancestors
                        $condition = ['id' => $target_id, 'visible' => true];
                        $target_item = Post::selectFirst(Item::DELIVER_FIELDLIST, $condition);
@@ -529,7 +519,9 @@ class Notifier
                                $contact['network'] = Protocol::DFRN;
                        }
 
-                       if (in_array($contact['id'], $ap_contacts)) {
+                       // Deletions are always sent via DFRN as well.
+                       // This is done until we can perform deletions of foreign comments on our own threads via AP.
+                       if (($cmd != Delivery::DELETION) && in_array($contact['id'], $ap_contacts)) {
                                Logger::info('Contact is already delivered via AP, so skip delivery via legacy DFRN/Diaspora', ['target' => $post_uriid, 'uid' => $sender_uid, 'contact' => $contact['url']]);
                                continue;
                        }