]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #7153 from annando/ap-mail-delivery
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 18 May 2019 15:50:10 +0000 (11:50 -0400)
committerGitHub <noreply@github.com>
Sat, 18 May 2019 15:50:10 +0000 (11:50 -0400)
Fix receiver list for mails

src/Protocol/ActivityPub/Transmitter.php
src/Worker/Notifier.php

index 88e047c1362bd2c26dbd7d0f640b1bf7d93f63ae..7fc5e2df0665ced6a9e0a478ba14e49617940ef4 100644 (file)
@@ -422,46 +422,48 @@ class Transmitter
                        }
                }
 
-               $parents = Item::select(['id', 'author-link', 'owner-link', 'gravity', 'uri'], ['parent' => $item['parent']]);
-               while ($parent = Item::fetch($parents)) {
-                       if ($parent['gravity'] == GRAVITY_PARENT) {
-                               $profile = APContact::getByURL($parent['owner-link'], false);
-                               if (!empty($profile)) {
-                                       if ($item['gravity'] != GRAVITY_PARENT) {
-                                               // Comments to forums are directed to the forum
-                                               // But comments to forums aren't directed to the followers collection
-                                               if ($profile['type'] == 'Group') {
-                                                       $data['to'][] = $profile['url'];
+               if (!empty($item['parent'])) {
+                       $parents = Item::select(['id', 'author-link', 'owner-link', 'gravity', 'uri'], ['parent' => $item['parent']]);
+                       while ($parent = Item::fetch($parents)) {
+                               if ($parent['gravity'] == GRAVITY_PARENT) {
+                                       $profile = APContact::getByURL($parent['owner-link'], false);
+                                       if (!empty($profile)) {
+                                               if ($item['gravity'] != GRAVITY_PARENT) {
+                                                       // Comments to forums are directed to the forum
+                                                       // But comments to forums aren't directed to the followers collection
+                                                       if ($profile['type'] == 'Group') {
+                                                               $data['to'][] = $profile['url'];
+                                                       } else {
+                                                               $data['cc'][] = $profile['url'];
+                                                               if (!$item['private']) {
+                                                                       $data['cc'][] = $actor_profile['followers'];
+                                                               }
+                                                       }
                                                } else {
-                                                       $data['cc'][] = $profile['url'];
-                                                       if (!$item['private']) {
+                                                       // Public thread parent post always are directed to the followers
+                                                       if (!$item['private'] && !$forum_mode) {
                                                                $data['cc'][] = $actor_profile['followers'];
                                                        }
                                                }
-                                       } else {
-                                               // Public thread parent post always are directed to the followes
-                                               if (!$item['private'] && !$forum_mode) {
-                                                       $data['cc'][] = $actor_profile['followers'];
-                                               }
                                        }
                                }
-                       }
 
-                       // Don't include data from future posts
-                       if ($parent['id'] >= $last_id) {
-                               continue;
-                       }
+                               // Don't include data from future posts
+                               if ($parent['id'] >= $last_id) {
+                                       continue;
+                               }
 
-                       $profile = APContact::getByURL($parent['author-link'], false);
-                       if (!empty($profile)) {
-                               if (($profile['type'] == 'Group') || ($parent['uri'] == $item['thr-parent'])) {
-                                       $data['to'][] = $profile['url'];
-                               } else {
-                                       $data['cc'][] = $profile['url'];
+                               $profile = APContact::getByURL($parent['author-link'], false);
+                               if (!empty($profile)) {
+                                       if (($profile['type'] == 'Group') || ($parent['uri'] == $item['thr-parent'])) {
+                                               $data['to'][] = $profile['url'];
+                                       } else {
+                                               $data['cc'][] = $profile['url'];
+                                       }
                                }
                        }
+                       DBA::close($parents);
                }
-               DBA::close($parents);
 
                $data['to'] = array_unique($data['to']);
                $data['cc'] = array_unique($data['cc']);
index 77aa4d564a5ed5a7520a1dbe1ba68e7453b4aae3..5094734808ca39cdca395792bac12e12206641cc 100644 (file)
@@ -78,7 +78,7 @@ class Notifier
                        $recipients[] = $message['contact-id'];
 
                        $mail = ActivityPub\Transmitter::ItemArrayFromMail($target_id);
-                       $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($mail, ยงuid, true);
+                       $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($mail, $uid, true);
                        foreach ($inboxes as $inbox) {
                                Logger::info('Delivery via ActivityPub', ['cmd' => $cmd, 'id' => $target_id, 'inbox' => $inbox]);
                                Worker::add(['priority' => PRIORITY_HIGH, 'created' => $a->queue['created'], 'dont_fork' => true],
@@ -441,8 +441,8 @@ class Notifier
                                                continue;
                                        }
 
-                                       if (($rr['network'] == Protocol::DFRN) && ($rr['protocol'] == Protocol::ACTIVITYPUB) &&
-                                               !in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
+                                       if (in_array($rr['network'], [Protocol::DFRN, Protocol::DIASPORA]) && ($rr['protocol'] == Protocol::ACTIVITYPUB) &&
+                                               !in_array($cmd, [Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
                                                Logger::info('Contact is Friendica AP, so skipping delivery via legacy DFRN', ['url' => $rr['url']]);
                                                continue;
                                        }
@@ -481,8 +481,8 @@ class Notifier
                                continue;
                        }
 
-                       if (($contact['network'] == Protocol::DFRN) && ($contact['protocol'] == Protocol::ACTIVITYPUB) &&
-                               !in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
+                       if (in_array($contact['network'], [Protocol::DFRN, Protocol::DIASPORA]) && ($contact['protocol'] == Protocol::ACTIVITYPUB) &&
+                               !in_array($cmd, [Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
                                Logger::info('Contact is Friendica AP, so skipping delivery via legacy DFRN', ['url' => $contact['url']]);
                                continue;
                        }