*/
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
*
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
*
private static function followUser($activity)
{
$actor = JsonLD::fetchElement($activity, 'object', 'id');
- $uid = self::getUserOfProfile($actor);
+ $uid = User::getIdForURL($actor);
if (empty($uid)) {
return;
}
private static function acceptFollowUser($activity)
{
$actor = JsonLD::fetchElement($activity, 'object', 'actor');
- $uid = self::getUserOfProfile($actor);
+ $uid = User::getIdForURL($actor);
if (empty($uid)) {
return;
}
private static function undoFollowUser($activity)
{
$object = JsonLD::fetchElement($activity, 'object', 'object');
- $uid = self::getUserOfProfile($object);
+ $uid = User::getIdForURL($object);
if (empty($uid)) {
return;
}