Merge pull request #8592 from annando/issue-8586
Issue 8586: Reduce the amount of item receivers
This commit is contained in:
commit
59d0bc5b5f
2 changed files with 10 additions and 8 deletions
|
@ -252,24 +252,26 @@ class Diaspora
|
||||||
* One of the parameters is a contact array.
|
* One of the parameters is a contact array.
|
||||||
* This is done to avoid duplicates.
|
* This is done to avoid duplicates.
|
||||||
*
|
*
|
||||||
* @param array $parent The parent post
|
* @param array $item Item that is about to be delivered
|
||||||
* @param array $contacts The previously fetched contacts
|
* @param array $contacts The previously fetched contacts
|
||||||
*
|
*
|
||||||
* @return array of relay servers
|
* @return array of relay servers
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function participantsForThread(array $parent, array $contacts)
|
public static function participantsForThread(array $item, array $contacts)
|
||||||
{
|
{
|
||||||
if (!in_array($parent['private'], [Item::PUBLIC, Item::UNLISTED])) {
|
if (!in_array($item['private'], [Item::PUBLIC, Item::UNLISTED]) || in_array($item["verb"], [Activity::FOLLOW, Activity::TAG])) {
|
||||||
return $contacts;
|
return $contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = Item::select(['author-id'], ['parent' => $parent['id']], ['group_by' => ['author-id']]);
|
$items = Item::select(['author-id', 'author-link', 'parent-author-link', 'parent-guid'],
|
||||||
|
['parent' => $item['parent'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
|
||||||
while ($item = DBA::fetch($items)) {
|
while ($item = DBA::fetch($items)) {
|
||||||
$contact = DBA::selectFirst('contact', ['id', 'url', 'name', 'protocol', 'batch', 'network'],
|
$contact = DBA::selectFirst('contact', ['id', 'url', 'name', 'protocol', 'batch', 'network'],
|
||||||
['id' => $item['author-id']]);
|
['id' => $item['author-id']]);
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact) || empty($contact['batch']) ||
|
||||||
// Shouldn't happen
|
($contact['network'] != Protocol::DIASPORA) ||
|
||||||
|
Strings::compareLink($item['parent-author-link'], $item['author-link'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +283,7 @@ class Diaspora
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$exists) {
|
if (!$exists) {
|
||||||
Logger::info('Add participant to receiver list', ['item' => $parent['guid'], 'participant' => $contact['url']]);
|
Logger::info('Add participant to receiver list', ['parent' => $item['parent-guid'], 'item' => $item['guid'], 'participant' => $contact['url']]);
|
||||||
$contacts[] = $contact;
|
$contacts[] = $contact;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,7 +437,7 @@ class Notifier
|
||||||
|
|
||||||
// Fetch the participation list
|
// Fetch the participation list
|
||||||
// The function will ensure that there are no duplicates
|
// The function will ensure that there are no duplicates
|
||||||
$relay_list = Diaspora::participantsForThread($parent, $relay_list);
|
$relay_list = Diaspora::participantsForThread($target_item, $relay_list);
|
||||||
|
|
||||||
// Add the relay to the list, avoid duplicates.
|
// Add the relay to the list, avoid duplicates.
|
||||||
// Don't send community posts to the relay. Forum posts via the Diaspora protocol are looking ugly.
|
// Don't send community posts to the relay. Forum posts via the Diaspora protocol are looking ugly.
|
||||||
|
|
Loading…
Reference in a new issue