]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Add Install Mode
[friendica.git] / src / Model / Contact.php
index 60dec8b2891f9b9a532892ecb790355b138ce59c..0bd5d06f68ddde8115c8af351bc602f207d745fa 100644 (file)
@@ -220,6 +220,11 @@ class Contact extends BaseObject
 
                        // Update the public contact as well
                        dba::update('contact', $fields, ['uid' => 0, 'nurl' => $self['nurl']]);
+
+                       // Update the profile
+                       $fields = ['photo' => System::baseUrl() . '/photo/profile/' .$uid . '.jpg',
+                               'thumb' => System::baseUrl() . '/photo/avatar/' . $uid .'.jpg'];
+                       dba::update('profile', $fields, ['uid' => $uid, 'is-default' => true]);
                }
        }
 
@@ -306,7 +311,9 @@ class Contact extends BaseObject
                         */
 
                        /// @todo Check for contact vitality via probing
-                       $expiry = $contact['term-date'] . ' + 32 days ';
+                       $archival_days = Config::get('system', 'archival_days', 32);
+
+                       $expiry = $contact['term-date'] . ' + ' . $archival_days . ' days ';
                        if (DateTimeFormat::utcNow() > DateTimeFormat::utc($expiry)) {
                                /* Relationship is really truly dead. archive them rather than
                                 * delete, though if the owner tries to unarchive them we'll start
@@ -343,9 +350,14 @@ class Contact extends BaseObject
                $fields = ['term-date' => NULL_DATE, 'archive' => false];
                dba::update('contact', $fields, ['id' => $contact['id']]);
 
-               if ($contact['url'] != '') {
+               if (!empty($contact['url'])) {
                        dba::update('contact', $fields, ['nurl' => normalise_link($contact['url'])]);
                }
+
+               if (!empty($contact['batch'])) {
+                       $condition = ['batch' => $contact['batch'], 'contact-type' => ACCOUNT_TYPE_RELAY];
+                       dba::update('contact', $fields, $condition);
+               }
        }
 
        /**
@@ -411,7 +423,7 @@ class Contact extends BaseObject
                // Fetch the data from the gcontact table
                if (!DBM::is_result($r)) {
                        $s = dba::p("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
-                       `keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, `contact-type`, `birthday`, 0 AS `self`
+                       `keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, 0 AS `forum`, 0 AS `prv`, `community`, `contact-type`, `birthday`, 0 AS `self`
                        FROM `gcontact` WHERE `nurl` = ?", normalise_link($url));
                        $r = dba::inArray($s);
                }
@@ -1470,6 +1482,11 @@ class Contact extends BaseObject
                        }
                        // send email notification to owner?
                } else {
+                       if (dba::exists('contact', ['nurl' => normalise_link($url), 'uid' => $importer['uid'], 'pending' => true])) {
+                               logger('ignoring duplicated connection request from pending contact ' . $url);
+                               return;
+                       }
+
                        // create contact record
                        q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `name`, `nick`, `photo`, `network`, `rel`,
                                `blocked`, `readonly`, `pending`, `writable`)