]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/FContact.php
Merge remote-tracking branch 'upstream/develop' into more-q
[friendica.git] / src / Model / FContact.php
index cf75a03dbc1df976ecc84c505d7fde2325df95ad..1c5c186e6994adec3f171ac979092378663f0626 100644 (file)
@@ -60,7 +60,7 @@ class FContact
                                        $update = true;
                                }
 
-                               if ($person["guid"] == "") {
+                               if (empty($person['guid']) || empty($person['uri-id'])) {
                                        $update = true;
                                }
                        }
@@ -100,6 +100,7 @@ class FContact
                        'batch' => $arr["batch"], 'notify' => $arr["notify"],
                        'poll' => $arr["poll"], 'confirm' => $arr["confirm"],
                        'alias' => $arr["alias"], 'pubkey' => $arr["pubkey"],
+                       'uri-id' => ItemURI::insert(['uri' => $arr['url'], 'guid' => $arr['guid']]),
                        'updated' => DateTimeFormat::utcNow()];
 
                $condition = ['url' => $arr["url"], 'network' => $arr["network"]];
@@ -120,14 +121,9 @@ class FContact
        {
                Logger::info('fcontact', ['guid' => $fcontact_guid]);
 
-               $r = q(
-                       "SELECT `url` FROM `fcontact` WHERE `url` != '' AND `network` = '%s' AND `guid` = '%s'",
-                       DBA::escape(Protocol::DIASPORA),
-                       DBA::escape($fcontact_guid)
-               );
-
-               if (DBA::isResult($r)) {
-                       return $r[0]['url'];
+               $fcontact = DBA::selectFirst('fcontact', ['url'], ["`url` != ? AND `network` = ? AND `guid` = ?", '', Protocol::DIASPORA, $fcontact_guid]);
+               if (DBA::isResult($fcontact)) {
+                       return $fcontact['url'];
                }
 
                return null;
@@ -175,7 +171,7 @@ class FContact
                $suggest['body'] = $note;
 
                $hash = Strings::getRandomHex();
-               $fields = ['uid' => $suggest['uid'], 'fid' => $fid, 'contact-id' => $suggest['cid'], 
+               $fields = ['uid' => $suggest['uid'], 'fid' => $fid, 'contact-id' => $suggest['cid'],
                        'note' => $suggest['body'], 'hash' => $hash, 'datetime' => DateTimeFormat::utcNow(), 'blocked' => false];
                DBA::insert('intro', $fields);