$item['owner-id'] = ($item['owner-id'] ?? 0) ?: Contact::getIdForURL($item['owner-link'], 0, null, $default);
$actor = ($item['gravity'] == GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
- if (!$item['origin'] && in_array($item['post-type'], [self::PT_ARTICLE, self::PT_COMMENT, self::PT_RELAY, self::PT_GLOBAL]) && Contact::isSharing($actor, $item['uid'])) {
+ if (in_array($item['post-type'], [self::PT_ARTICLE, self::PT_COMMENT, self::PT_RELAY, self::PT_GLOBAL])
+ && !$item['origin'] && ($item['uid'] != 0) && Contact::isSharing($actor, $item['uid'])) {
$item['post-type'] = self::PT_FOLLOWER;
}
$basecondition = ['rel' => [Contact::SHARING, Contact::FRIEND, Contact::FOLLOWER],
'network' => Protocol::FEDERATED, 'archive' => false, 'pending' => false];
- $condition = DBA::mergeConditions($basecondition, ['nurl' => Strings::normaliseLink($actor)]);
+ $condition = DBA::mergeConditions($basecondition, ["`nurl` = ? AND `uid` != ?", Strings::normaliseLink($actor), 0]);
$contacts = DBA::select('contact', ['uid', 'rel'], $condition);
while ($contact = DBA::fetch($contacts)) {
- if (empty($receivers['uid:' . $contact['uid']]) && self::isValidReceiverForActor($contact, $actor, $tags)) {
+ if (empty($receivers['uid:' . $contact['uid']]) && self::isValidReceiverForActor($contact, $tags)) {
$receivers['uid:' . $contact['uid']] = ['uid' => $contact['uid'], 'type' => self::TARGET_FOLLOWER];
}
}
DBA::close($contacts);
// The queries are split because of performance issues
- $condition = DBA::mergeConditions($basecondition, ["`alias` IN (?, ?)", Strings::normaliseLink($actor), $actor]);
+ $condition = DBA::mergeConditions($basecondition, ["`alias` IN (?, ?) AND `uid` != ?", Strings::normaliseLink($actor), $actor, 0]);
$contacts = DBA::select('contact', ['uid', 'rel'], $condition);
while ($contact = DBA::fetch($contacts)) {
- if (empty($receivers['uid:' . $contact['uid']]) && self::isValidReceiverForActor($contact, $actor, $tags)) {
+ if (empty($receivers['uid:' . $contact['uid']]) && self::isValidReceiverForActor($contact, $tags)) {
$receivers['uid:' . $contact['uid']] = ['uid' => $contact['uid'], 'type' => self::TARGET_FOLLOWER];
}
}
* @return bool with receivers (user id)
* @throws \Exception
*/
- private static function isValidReceiverForActor($contact, $actor, $tags)
+ private static function isValidReceiverForActor($contact, $tags)
{
- // Public contacts are no valid receiver
- if ($contact['uid'] == 0) {
- return false;
- }
-
// Are we following the contact? Then this is a valid receiver
if (in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND])) {
return true;
continue;
}
- if ($tag['href'] == $owner['url']) {
+ if (Strings::compareLink($tag['href'], $owner['url'])) {
return true;
}
}