]> git.mxchange.org Git - friendica.git/commitdiff
Contact updates should now work more reliable
authorMichael <heluecht@pirati.ca>
Mon, 26 Feb 2018 21:53:42 +0000 (21:53 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 26 Feb 2018 21:53:42 +0000 (21:53 +0000)
src/Model/Contact.php
src/Protocol/DFRN.php

index 7415bac0a958bd5d1efc9236d93f5f4193a6cae3..8a2be5e9ad2ef6ff3d07c9c83e7182c3e51286a6 100644 (file)
@@ -1032,7 +1032,7 @@ class Contact extends BaseObject
 
                                // Update the public contact (contact id = 0)
                                if ($uid != 0) {
-                                       $pcontact = dba::selectFirst('contact', ['id'], ['nurl' => $contact['nurl']]);
+                                       $pcontact = dba::selectFirst('contact', ['id'], ['nurl' => $contact['nurl'], 'uid' => 0]);
                                        if (DBM::is_result($pcontact)) {
                                                self::updateAvatar($avatar, 0, $pcontact['id'], $force);
                                        }
index 6876d254185aefff9877de9fae3aa305e2b9d823..0ee3ed42b25249b321c11cfa45ed2972d8885872 100644 (file)
@@ -1431,7 +1431,7 @@ class DFRN
                $author["name"] = $xpath->evaluate($element."/atom:name/text()", $context)->item(0)->nodeValue;
                $author["link"] = $xpath->evaluate($element."/atom:uri/text()", $context)->item(0)->nodeValue;
 
-               $contact_old = dba::fetch_first("SELECT `id`, `uid`, `url`, `network`, `avatar-date`, `name-date`, `uri-date`, `addr`,
+               $contact_old = dba::fetch_first("SELECT `id`, `uid`, `url`, `network`, `avatar-date`, `avatar`, `name-date`, `uri-date`, `addr`,
                                `name`, `nick`, `about`, `location`, `keywords`, `xmpp`, `bdyear`, `bd`, `hidden`, `contact-type`
                                FROM `contact` WHERE `uid` = ? AND `nurl` = ? AND `network` != ?",
                        $importer["uid"],
@@ -1468,7 +1468,7 @@ class DFRN
                                        $width = $attributes->textContent;
                                }
                                if ($attributes->name == "updated") {
-                                       $contact_old["avatar-date"] = $attributes->textContent;
+                                       $author["avatar-date"] = $attributes->textContent;
                                }
                        }
                        if (($width > 0) && ($href != "")) {
@@ -1601,6 +1601,7 @@ class DFRN
                        unset($fields["uid"]);
                        unset($fields["url"]);
                        unset($fields["avatar-date"]);
+                       unset($fields["avatar"]);
                        unset($fields["name-date"]);
                        unset($fields["uri-date"]);
 
@@ -1638,10 +1639,10 @@ class DFRN
                        }
 
                        Contact::updateAvatar(
-                               $author["avatar"],
-                               $importer["uid"],
-                               $contact["id"],
-                               (strtotime($contact["avatar-date"]) > strtotime($contact_old["avatar-date"]))
+                               $author['avatar'],
+                               $importer['uid'],
+                               $contact['id'],
+                               (strtotime($contact['avatar-date']) > strtotime($contact_old['avatar-date']) || ($author['avatar'] != $contact_old['avatar']))
                        );
 
                        /*
@@ -1660,7 +1661,7 @@ class DFRN
                        GContact::link($gcid, $importer["uid"], $contact["id"]);
                }
 
-               return($author);
+               return $author;
        }
 
        /**