From 04f34de3a14211de70d5adbcef6375c7746ad425 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 10 Feb 2019 18:42:51 +0000 Subject: [PATCH] Multiples follows shouldn't be send anymore --- src/Protocol/ActivityPub/Processor.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 6d94b1b49e..a0630fe6c0 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -343,6 +343,8 @@ class Processor $item['body'] = $activity['source']; } + $stored = false; + foreach ($activity['receiver'] as $receiver) { $item['uid'] = $receiver; $item['contact-id'] = Contact::getIdForURL($activity['author'], $receiver, true); @@ -357,9 +359,14 @@ class Processor $item_id = Item::insert($item); Logger::log('Storing for user ' . $item['uid'] . ': ' . $item_id); + + if ($item_id) { + $stored = true; + } } - if (!$item['private'] && ($item['gravity'] == GRAVITY_PARENT) && ($item['author-link'] != $item['owner-link'])) { + // Store send a follow request for every reshare - but only when the item had been stored + if ($stored && !$item['private'] && ($item['gravity'] == GRAVITY_PARENT) && ($item['author-link'] != $item['owner-link'])) { $author = APContact::getByURL($item['owner-link'], false); // We send automatic follow requests for reshared messages. (We don't need though for forum posts) if ($author['type'] != 'Group') { @@ -662,11 +669,12 @@ class Processor } foreach ($parent_terms as $term) { - $contact = Contact::getDetailsByURL($term['url']); - - $implicit_mentions[] = $contact['url']; - $implicit_mentions[] = $contact['nurl']; - $implicit_mentions[] = $contact['alias']; + $contact = Contact::getDetailsByURL($term['url'], 0); + if (!empty($contact)) { + $implicit_mentions[] = $contact['url']; + $implicit_mentions[] = $contact['nurl']; + $implicit_mentions[] = $contact['alias']; + } } return $implicit_mentions;