Merge pull request #6632 from annando/check-follow
Prevent multiple send follow requests
This commit is contained in:
commit
b5dcca995c
2 changed files with 22 additions and 7 deletions
|
@ -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,13 +359,18 @@ class Processor
|
|||
|
||||
$item_id = Item::insert($item);
|
||||
Logger::log('Storing for user ' . $item['uid'] . ': ' . $item_id);
|
||||
|
||||
if ($item['uid'] == 0) {
|
||||
$stored = $item_id;
|
||||
}
|
||||
}
|
||||
|
||||
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') {
|
||||
Logger::log('Send follow request for ' . $item['uri'] . ' to ' . $item['author-link'], Logger::DEBUG);
|
||||
Logger::log('Send follow request for ' . $item['uri'] . ' (' . $stored . ') to ' . $item['author-link'], Logger::DEBUG);
|
||||
ActivityPub\Transmitter::sendFollowObject($item['uri'], $item['author-link']);
|
||||
}
|
||||
}
|
||||
|
@ -662,12 +669,13 @@ class Processor
|
|||
}
|
||||
|
||||
foreach ($parent_terms as $term) {
|
||||
$contact = Contact::getDetailsByURL($term['url']);
|
||||
|
||||
$contact = Contact::getDetailsByURL($term['url'], 0);
|
||||
if (!empty($contact)) {
|
||||
$implicit_mentions[] = $contact['url'];
|
||||
$implicit_mentions[] = $contact['nurl'];
|
||||
$implicit_mentions[] = $contact['alias'];
|
||||
}
|
||||
}
|
||||
|
||||
return $implicit_mentions;
|
||||
}
|
||||
|
|
|
@ -1317,6 +1317,13 @@ class Transmitter
|
|||
$uid = $first_user['uid'];
|
||||
}
|
||||
|
||||
$condition = ['verb' => ACTIVITY_FOLLOW, 'uid' => 0, 'parent-uri' => $object,
|
||||
'author-id' => Contact::getPublicIdByUserId($uid)];
|
||||
if (Item::exists($condition)) {
|
||||
Logger::log('Follow for ' . $object . ' for user ' . $uid . ' does already exist.', Logger::DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
|
||||
$data = ['@context' => ActivityPub::CONTEXT,
|
||||
|
|
Loading…
Reference in a new issue