]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Merge remote-tracking branch 'upstream/develop' into restricted
[friendica.git] / src / Model / Contact.php
index d91abe9bcdb0b3070fa579b0171be4da3b4ef6e1..243b48ad1d2124c6c08724f41f21bbdf1fe293f9 100644 (file)
@@ -222,6 +222,11 @@ class Contact
 
                Contact\User::insertForContactArray($contact);
 
+               if ((empty($contact['baseurl']) || empty($contact['gsid'])) && Probe::isProbable($contact['network'])) {
+                       Logger::debug('Update missing baseurl', ['id' => $contact['id'], 'url' => $contact['url'], 'callstack' => System::callstack(4, 0, true)]);
+                       UpdateContact::add(['priority' => Worker::PRIORITY_MEDIUM, 'dont_fork' => true], $contact['id']);
+               }
+
                return $contact['id'];
        }
 
@@ -528,6 +533,17 @@ class Contact
                return self::isSharing($cid, $uid, $strict);
        }
 
+       /**
+        * Checks if the provided public contact id has got followers on this system
+        *
+        * @param integer $cid
+        * @return boolean
+        */
+       public static function hasFollowers(int $cid): bool
+       {
+               return DBA::exists('account-user-view', ["`pid` = ? AND `uid` != ? AND `rel` IN (?, ?)", $cid, 0, self::SHARING, self::FRIEND]);
+       }
+
        /**
         * Get the basepath for a given contact link
         *
@@ -734,7 +750,7 @@ class Contact
                $user = DBA::selectFirst(
                        'user',
                        ['uid', 'username', 'nickname', 'pubkey', 'prvkey'],
-                       ['uid' => $uid, 'account_expired' => false]
+                       ['uid' => $uid, 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]
                );
                if (!DBA::isResult($user)) {
                        return false;
@@ -788,10 +804,10 @@ class Contact
        /**
         * Updates the self-contact for the provided user id
         *
-        * @param int   $uid
-        * @param bool  $update_avatar Force the avatar update
+        * @param int  $uid
+        * @param bool $update_avatar Force the avatar update
         * @return bool "true" if updated
-        * @throws HTTPException\InternalServerErrorException
+        * @throws \Exception
         */
        public static function updateSelfFromUserID(int $uid, bool $update_avatar = false): bool
        {
@@ -806,7 +822,7 @@ class Contact
                }
 
                $fields = ['uid', 'username', 'nickname', 'page-flags', 'account-type', 'prvkey', 'pubkey'];
-               $user = DBA::selectFirst('user', $fields, ['uid' => $uid, 'account_expired' => false]);
+               $user = DBA::selectFirst('user', $fields, ['uid' => $uid, 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]);
                if (!DBA::isResult($user)) {
                        return false;
                }
@@ -1372,6 +1388,7 @@ class Contact
                        $fields = [
                                'uid'       => $uid,
                                'url'       => $data['url'],
+                               'baseurl'   => $data['baseurl'] ?? '',
                                'nurl'      => Strings::normaliseLink($data['url']),
                                'network'   => $data['network'],
                                'created'   => DateTimeFormat::utcNow(),
@@ -3181,7 +3198,7 @@ class Contact
                        return false;
                }
 
-               $fields = ['id', 'url', 'name', 'nick', 'avatar', 'photo', 'network', 'blocked'];
+               $fields = ['id', 'url', 'name', 'nick', 'avatar', 'photo', 'network', 'blocked', 'baseurl'];
                $pub_contact = DBA::selectFirst('contact', $fields, ['id' => $datarray['author-id']]);
                if (!DBA::isResult($pub_contact)) {
                        // Should never happen
@@ -3252,6 +3269,7 @@ class Contact
                                'created'  => DateTimeFormat::utcNow(),
                                'url'      => $url,
                                'nurl'     => Strings::normaliseLink($url),
+                               'baseurl'  => $pub_contact['baseurl'] ?? '',
                                'name'     => $name,
                                'nick'     => $nick,
                                'network'  => $network,