From da79566125b28885d82de30d409f445f6843d4c3 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 28 Sep 2018 03:56:41 +0000 Subject: [PATCH] Relocated function --- src/Model/User.php | 17 +++++++++++++++++ src/Protocol/ActivityPub.php | 23 +++-------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Model/User.php b/src/Model/User.php index 095bf56e7..7432b7577 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -31,6 +31,23 @@ require_once 'include/text.php'; */ 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 * diff --git a/src/Protocol/ActivityPub.php b/src/Protocol/ActivityPub.php index 663b03e93..ce960e10d 100644 --- a/src/Protocol/ActivityPub.php +++ b/src/Protocol/ActivityPub.php @@ -1665,23 +1665,6 @@ class ActivityPub 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 * @@ -1690,7 +1673,7 @@ class ActivityPub private static function followUser($activity) { $actor = JsonLD::fetchElement($activity, 'object', 'id'); - $uid = self::getUserOfProfile($actor); + $uid = User::getIdForURL($actor); if (empty($uid)) { return; } @@ -1745,7 +1728,7 @@ class ActivityPub private static function acceptFollowUser($activity) { $actor = JsonLD::fetchElement($activity, 'object', 'actor'); - $uid = self::getUserOfProfile($actor); + $uid = User::getIdForURL($actor); if (empty($uid)) { return; } @@ -1803,7 +1786,7 @@ class ActivityPub private static function undoFollowUser($activity) { $object = JsonLD::fetchElement($activity, 'object', 'object'); - $uid = self::getUserOfProfile($object); + $uid = User::getIdForURL($object); if (empty($uid)) { return; }