]> git.mxchange.org Git - friendica.git/commitdiff
The function moved from the user to the contact class
authorMichael <heluecht@pirati.ca>
Sun, 10 Feb 2019 17:19:10 +0000 (17:19 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 10 Feb 2019 17:19:10 +0000 (17:19 +0000)
src/Model/Contact.php
src/Model/Item.php
src/Model/User.php

index cf90406e24a029d5afbc2cd83eceebfce9d95922..2d6bc716bb11338fdbffcc2af290b66ff1fa090c 100644 (file)
@@ -155,6 +155,23 @@ class Contact extends BaseObject
                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
         *
index 3f2f3c1752597c9542200df890e9e334f204e23a..54bd4a0ef7fe9db03e47079ec3cac5f781d0ab17 100644 (file)
@@ -1462,8 +1462,8 @@ class Item extends BaseObject
                }
 
                if ($item['verb'] == ACTIVITY_FOLLOW) {
-                       if (!$item['origin'] && ($item['author-id'] == User::getPublicContactById($uid))) {
-                               // Our own follow request can be relayed to us. We don't store them to avoid notification chaos.
+                       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;
                        }
index 841c81f741114a8707958b4d95e48d56ee8d5892..59ca4c90a40a3f6742c41cd0883babf94d13288f 100644 (file)
@@ -99,20 +99,6 @@ class User
                return DBA::selectFirst('user', [], ['uid' => $uid]);
        }
 
-       /**
-        * @param  integer       $uid
-        * @return array|boolean User record if it exists, false otherwise
-        * @throws Exception
-        */
-       public static function getPublicContactById($uid)
-       {
-               $self = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
-               if (!DBA::isResult($self)) {
-                       return false;
-               }
-               return Contact::getIdForURL($self['url'], 0, true);
-       }
-
        /**
         * @brief Returns the user id of a given profile URL
         *