Relocated function

This commit is contained in:
Michael 2018-09-28 03:56:41 +00:00
parent a5ddcb367b
commit da79566125
2 changed files with 20 additions and 20 deletions

View file

@ -31,6 +31,23 @@ require_once 'include/text.php';
*/ */
class User class User
{ {
/**
* @brief Returns the user id of a given profile url
*
* @param string $profile
*
* @return integer user id
*/
public static function getIdForURL($url)
{
$self = DBA::selectFirst('contact', ['uid'], ['nurl' => normalise_link($url), 'self' => true]);
if (!DBA::isResult($self)) {
return false;
} else {
return $self['uid'];
}
}
/** /**
* @brief Get owner data by user id * @brief Get owner data by user id
* *

View file

@ -1665,23 +1665,6 @@ class ActivityPub
logger('Activity ' . $url . ' had been fetched and processed.'); logger('Activity ' . $url . ' had been fetched and processed.');
} }
/**
* @brief Returns the user id of a given profile url
*
* @param string $profile
*
* @return integer user id
*/
private static function getUserOfProfile($profile)
{
$self = DBA::selectFirst('contact', ['uid'], ['nurl' => normalise_link($profile), 'self' => true]);
if (!DBA::isResult($self)) {
return false;
} else {
return $self['uid'];
}
}
/** /**
* @brief perform a "follow" request * @brief perform a "follow" request
* *
@ -1690,7 +1673,7 @@ class ActivityPub
private static function followUser($activity) private static function followUser($activity)
{ {
$actor = JsonLD::fetchElement($activity, 'object', 'id'); $actor = JsonLD::fetchElement($activity, 'object', 'id');
$uid = self::getUserOfProfile($actor); $uid = User::getIdForURL($actor);
if (empty($uid)) { if (empty($uid)) {
return; return;
} }
@ -1745,7 +1728,7 @@ class ActivityPub
private static function acceptFollowUser($activity) private static function acceptFollowUser($activity)
{ {
$actor = JsonLD::fetchElement($activity, 'object', 'actor'); $actor = JsonLD::fetchElement($activity, 'object', 'actor');
$uid = self::getUserOfProfile($actor); $uid = User::getIdForURL($actor);
if (empty($uid)) { if (empty($uid)) {
return; return;
} }
@ -1803,7 +1786,7 @@ class ActivityPub
private static function undoFollowUser($activity) private static function undoFollowUser($activity)
{ {
$object = JsonLD::fetchElement($activity, 'object', 'object'); $object = JsonLD::fetchElement($activity, 'object', 'object');
$uid = self::getUserOfProfile($object); $uid = User::getIdForURL($object);
if (empty($uid)) { if (empty($uid)) {
return; return;
} }