]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Notifier.php
Avoid local network communication / invalid url requests
[friendica.git] / src / Worker / Notifier.php
index 2e8721feee48fc7502ef41fcea269015ebdc6088..e4189c2c75c4b2fb12e1c09c8d2a8ff466c734f9 100644 (file)
@@ -517,7 +517,11 @@ class Notifier
 
                foreach ($contacts as $contact) {
                        // Direct delivery of local contacts
-                       if (!in_array($cmd, [Delivery::RELOCATION, Delivery::SUGGESTION, Delivery::DELETION, Delivery::MAIL]) && $target_uid = User::getIdForURL($contact['url'])) {
+                       if (!in_array($cmd, [Delivery::RELOCATION, Delivery::SUGGESTION, Delivery::MAIL]) && $target_uid = User::getIdForURL($contact['url'])) {
+                               if ($cmd == Delivery::DELETION) {
+                                       Logger::info('No need to deliver deletions internally', ['uid' => $target_uid, 'guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'uri' => $target_item['uri']]);
+                                       continue;
+                               }
                                if ($target_item['origin'] || ($target_item['network'] != Protocol::ACTIVITYPUB)) {
                                        if ($target_uid != $target_item['uid']) {
                                                $fields = ['protocol' => Conversation::PARCEL_LOCAL_DFRN, 'direction' => Conversation::PUSH, 'post-reason' => Item::PR_DIRECT];
@@ -593,7 +597,8 @@ class Notifier
 
                        if (!empty($contact['gsid']) && DI::config()->get('system', 'bulk_delivery')) {
                                $delivery_queue_count++;
-                               Delivery::addQueue($cmd, $post_uriid, $target_item['created'], $contact['id'], $contact['gsid'], $sender_uid);
+                               $deliveryQueueItem = DI::deliveryQueueItemFactory()->createFromDelivery($cmd, $post_uriid, new \DateTimeImmutable($target_item['created']), $contact['id'], $contact['gsid'], $sender_uid);
+                               DI::deliveryQueueItemRepo()->save($deliveryQueueItem);
                                Worker::add(['priority' => Worker::PRIORITY_HIGH, 'dont_fork' => true], 'BulkDelivery', $contact['gsid']);
                        } else {
                                if (Worker::add($deliver_options, 'Delivery', $cmd, $post_uriid, (int)$contact['id'], $sender_uid)) {
@@ -838,7 +843,11 @@ class Notifier
 
                        if ((count($receivers) == 1) && Network::isLocalLink($inbox)) {
                                $contact = Contact::getById($receivers[0], ['url']);
-                               if (!in_array($cmd, [Delivery::RELOCATION, Delivery::SUGGESTION, Delivery::DELETION, Delivery::MAIL]) && ($target_uid = User::getIdForURL($contact['url']))) {
+                               if (!in_array($cmd, [Delivery::RELOCATION, Delivery::SUGGESTION, Delivery::MAIL]) && ($target_uid = User::getIdForURL($contact['url']))) {
+                                       if ($cmd == Delivery::DELETION) {
+                                               Logger::info('No need to deliver deletions internally', ['uid' => $target_uid, 'guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'uri' => $target_item['uri']]);
+                                               continue;
+                                       }
                                        if ($target_item['origin'] || ($target_item['network'] != Protocol::ACTIVITYPUB)) {
                                                if ($target_uid != $target_item['uid']) {
                                                        $fields = ['protocol' => Conversation::PARCEL_LOCAL_DFRN, 'direction' => Conversation::PUSH, 'post-reason' => Item::PR_BCC];