]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Contact.php
Move Object\Profile to Model\Profile
[friendica.git] / src / Object / Contact.php
index bd7cee7fbea640281cdac4caacbac141568b00c9..f72ec025a4dbda0bcbba72a56acb8068ccb6569c 100644 (file)
@@ -141,8 +141,8 @@ class Contact extends BaseObject
         */
        public static function markForArchival(array $contact)
        {
-               // Contact already archived, nothing to do
-               if ($contact['archive']) {
+               // Contact already archived or "self" contact? => nothing to do
+               if ($contact['archive'] || $contact['self']) {
                        return;
                }
 
@@ -150,7 +150,7 @@ class Contact extends BaseObject
                        dba::update('contact', array('term-date' => datetime_convert()), array('id' => $contact['id']));
 
                        if ($contact['url'] != '') {
-                               dba::update('contact', array('term-date' => datetime_convert()), array('`nurl` = ? AND `term-date` <= ?', normalise_link($contact['url']), NULL_DATE));
+                               dba::update('contact', array('term-date' => datetime_convert()), array('`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE));
                        }
                } else {
                        /* @todo
@@ -169,7 +169,7 @@ class Contact extends BaseObject
                                dba::update('contact', array('archive' => 1), array('id' => $contact['id']));
 
                                if ($contact['url'] != '') {
-                                       dba::update('contact', array('archive' => 1), array('nurl' => normalise_link($contact['url'])));
+                                       dba::update('contact', array('archive' => 1), array('nurl' => normalise_link($contact['url']), 'self' => false));
                                }
                        }
                }
@@ -694,7 +694,8 @@ class Contact extends BaseObject
 
                self::updateAvatar($data["photo"], $uid, $contact_id);
 
-               $contact = dba::select('contact', array('url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date'), array('id' => $contact_id), array('limit' => 1));
+               $fields = array('url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'pubkey');
+               $contact = dba::select('contact', $fields, array('id' => $contact_id), array('limit' => 1));
 
                // This condition should always be true
                if (!DBM::is_result($contact)) {
@@ -708,6 +709,13 @@ class Contact extends BaseObject
                        'name' => $data['name'],
                        'nick' => $data['nick']);
 
+               // Only fill the pubkey if it was empty before. We have to prevent identity theft.
+               if (!empty($contact['pubkey'])) {
+                       unset($contact['pubkey']);
+               } else {
+                       $updated['pubkey'] = $data['pubkey'];
+               }
+
                if ($data['keywords'] != '') {
                        $updated['keywords'] = $data['keywords'];
                }