Merge pull request #6627 from annando/check-follow
Don't store multiple follow request from a single person
This commit is contained in:
commit
3a9217049b
|
@ -155,6 +155,23 @@ class Contact extends BaseObject
|
||||||
return PortableContact::detectServer($url);
|
return PortableContact::detectServer($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the public contact id of the given user id
|
||||||
|
*
|
||||||
|
* @param integer $uid User ID
|
||||||
|
*
|
||||||
|
* @return integer|boolean Public contact id for given user id
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function getPublicIdByUserId($uid)
|
||||||
|
{
|
||||||
|
$self = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
|
||||||
|
if (!DBA::isResult($self)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return self::getIdForURL($self['url'], 0, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the contact id for the user and the public contact id for a given contact id
|
* @brief Returns the contact id for the user and the public contact id for a given contact id
|
||||||
*
|
*
|
||||||
|
|
|
@ -1315,6 +1315,8 @@ class Item extends BaseObject
|
||||||
$item['gravity'] = GRAVITY_PARENT;
|
$item['gravity'] = GRAVITY_PARENT;
|
||||||
} elseif (activity_match($item['verb'], ACTIVITY_POST)) {
|
} elseif (activity_match($item['verb'], ACTIVITY_POST)) {
|
||||||
$item['gravity'] = GRAVITY_COMMENT;
|
$item['gravity'] = GRAVITY_COMMENT;
|
||||||
|
} elseif (activity_match($item['verb'], ACTIVITY_FOLLOW)) {
|
||||||
|
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||||
} else {
|
} else {
|
||||||
$item['gravity'] = GRAVITY_UNKNOWN; // Should not happen
|
$item['gravity'] = GRAVITY_UNKNOWN; // Should not happen
|
||||||
Logger::log('Unknown gravity for verb: ' . $item['verb'], Logger::DEBUG);
|
Logger::log('Unknown gravity for verb: ' . $item['verb'], Logger::DEBUG);
|
||||||
|
@ -1459,6 +1461,22 @@ class Item extends BaseObject
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($item['verb'] == ACTIVITY_FOLLOW) {
|
||||||
|
if (!$item['origin'] && ($item['author-id'] == Contact::getPublicIdByUserId($uid))) {
|
||||||
|
// Our own follow request can be relayed to us. We don't store it to avoid notification chaos.
|
||||||
|
Logger::log("Follow: Don't store not origin follow request from us for " . $item['parent-uri'], Logger::DEBUG);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$condition = ['verb' => ACTIVITY_FOLLOW, 'uid' => $item['uid'],
|
||||||
|
'parent-uri' => $item['parent-uri'], 'author-id' => $item['author-id']];
|
||||||
|
if (self::exists($condition)) {
|
||||||
|
// It happens that we receive multiple follow requests by the same author - we only store one.
|
||||||
|
Logger::log('Follow: Found existing follow request from author ' . $item['author-id'] . ' for ' . $item['parent-uri'], Logger::DEBUG);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check for hashtags in the body and repair or add hashtag links
|
// Check for hashtags in the body and repair or add hashtag links
|
||||||
self::setHashtags($item);
|
self::setHashtags($item);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue