]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Update "storage" console command
[friendica.git] / src / Model / Contact.php
index 7ff0032d231516d4adc7cf4cd20c2bf31eb4fa98..3c9071b9fe245a31b5351db46055de0785c89b2c 100644 (file)
@@ -6,7 +6,6 @@ namespace Friendica\Model;
 
 use Friendica\BaseObject;
 use Friendica\Content\Pager;
-use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
@@ -358,6 +357,7 @@ class Contact extends BaseObject
                                WHERE `gid` = ?
                                AND `contact`.`uid` = ?
                                AND NOT `contact`.`self`
+                               AND NOT `contact`.`deleted`
                                AND NOT `contact`.`blocked`
                                AND NOT `contact`.`pending`
                                ORDER BY `contact`.`name` ASC',
@@ -482,7 +482,7 @@ class Contact extends BaseObject
                        'gender' => $profile['gender'], 'avatar' => $profile['photo'],
                        'contact-type' => $user['account-type'], 'xmpp' => $profile['xmpp']];
 
-               $avatar = DBA::selectFirst('photo', ['resource-id', 'type'], ['uid' => $uid, 'profile' => true]);
+               $avatar = Photo::selectFirst(['resource-id', 'type'], ['uid' => $uid, 'profile' => true]);
                if (DBA::isResult($avatar)) {
                        if ($update_avatar) {
                                $fields['avatar-date'] = DateTimeFormat::utcNow();
@@ -578,6 +578,9 @@ class Contact extends BaseObject
         */
        public static function terminateFriendship(array $user, array $contact, $dissolve = false)
        {
+               if (empty($contact['network'])) {
+                       return;
+               }
                if (($contact['network'] == Protocol::DFRN) && $dissolve) {
                        DFRN::deliver($user, $contact, 'placeholder', true);
                } elseif (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) {
@@ -598,7 +601,7 @@ class Contact extends BaseObject
                } elseif ($contact['network'] == Protocol::DIASPORA) {
                        Diaspora::sendUnshare($user, $contact);
                } elseif ($contact['network'] == Protocol::ACTIVITYPUB) {
-                       ActivityPub\Transmitter::sendContactUndo($contact['url'], $user['uid']);
+                       ActivityPub\Transmitter::sendContactUndo($contact['url'], $contact['id'], $user['uid']);
 
                        if ($dissolve) {
                                ActivityPub\Transmitter::sendContactReject($contact['url'], $contact['hub-verify'], $user['uid']);
@@ -630,6 +633,8 @@ class Contact extends BaseObject
                        Logger::log('Empty contact: ' . json_encode($contact) . ' - ' . System::callstack(20), Logger::DEBUG);
                }
 
+               Logger::log('Contact '.$contact['id'].' is marked for archival', Logger::DEBUG);
+
                // Contact already archived or "self" contact? => nothing to do
                if ($contact['archive'] || $contact['self']) {
                        return;
@@ -678,6 +683,8 @@ class Contact extends BaseObject
                        return;
                }
 
+               Logger::log('Contact '.$contact['id'].' is marked as vital again', Logger::DEBUG);
+
                if (!isset($contact['url']) && !empty($contact['id'])) {
                        $fields = ['id', 'url', 'batch'];
                        $contact = DBA::selectFirst('contact', [], ['id' => $contact['id']]);
@@ -999,7 +1006,7 @@ class Contact extends BaseObject
 
                $args = ['contact' => $contact, 'menu' => &$menu];
 
-               Addon::callHooks('contact_photo_menu', $args);
+               Hook::callAll('contact_photo_menu', $args);
 
                $menucondensed = [];
 
@@ -1030,6 +1037,7 @@ class Contact extends BaseObject
                           FROM `contact`
                           WHERE `uid` = %d
                           AND NOT `self`
+                          AND NOT `deleted`
                           AND NOT `blocked`
                           AND NOT `pending`
                           AND `id` NOT IN (
@@ -1405,7 +1413,7 @@ class Contact extends BaseObject
 
                        $items = Item::inArray($r);
 
-                       $o = conversation($a, $items, $pager, 'contacts', $update);
+                       $o = conversation($a, $items, $pager, 'contacts', $update, false, 'commented', local_user());
                } else {
                        $r = Item::selectForUser(local_user(), [], $condition, $params);
 
@@ -1566,8 +1574,8 @@ class Contact extends BaseObject
 
                $ret = Probe::uri($contact["url"], $network);
 
-               // If Probe::uri fails the network code will be different
-               if (($ret["network"] != $contact["network"]) && !in_array($ret["network"], [Protocol::ACTIVITYPUB, $network])) {
+               // If Probe::uri fails the network code will be different (mostly "feed" or "unkn")
+               if (($ret["network"] != $contact["network"]) && !in_array($ret["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, $network])) {
                        return false;
                }
 
@@ -1822,7 +1830,13 @@ class Contact extends BaseObject
                                $ret = Diaspora::sendShare($a->user, $contact);
                                Logger::log('share returns: ' . $ret);
                        } elseif ($contact['network'] == Protocol::ACTIVITYPUB) {
-                               $ret = ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $uid);
+                               $activity_id = ActivityPub\Transmitter::activityIDFromContact($contact_id);
+                               if (empty($activity_id)) {
+                                       // This really should never happen
+                                       return false;
+                               }
+
+                               $ret = ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $uid, $activity_id);
                                Logger::log('Follow returns: ' . $ret);
                        }
                }
@@ -2074,7 +2088,7 @@ class Contact extends BaseObject
         */
        public static function magicLink($contact_url, $url = '')
        {
-               if (!local_user() && remote_user()) {
+               if (!local_user() && !remote_user()) {
                        return $url ?: $contact_url; // Equivalent to: ($url != '') ? $url : $contact_url;
                }