]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Replace IHTTPResult for CurlResult usages
[friendica.git] / src / Protocol / Diaspora.php
index 2c3e9add63af3eea9ee128ec0da82cb095d1d7f8..b38e0506b9dd33c128beb5b83ef4cf917a2908b8 100644 (file)
@@ -3082,6 +3082,11 @@ class Diaspora
                        if (!empty($fcontact)) {
                                $pubkey = $fcontact['pubkey'];
                        }
+               } else {
+                       // The "addr" field should always be filled.
+                       // If this isn't the case, it will raise a notice some lines later.
+                       // And in the log we will see where it came from and we can handle it there.
+                       Logger::notice('Empty addr', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]);
                }
 
                $envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $pubkey, $public_batch);
@@ -3988,13 +3993,7 @@ class Diaspora
                }
 
                if (!$recips) {
-                       $recips = q(
-                               "SELECT `id`,`name`,`network`,`pubkey`,`notify` FROM `contact` WHERE `network` = '%s'
-                               AND `uid` = %d AND `rel` != %d",
-                               DBA::escape(Protocol::DIASPORA),
-                               intval($uid),
-                               intval(Contact::SHARING)
-                       );
+                       $recips = DBA::selectToArray('contact', [], ['network' => Protocol::DIASPORA, 'uid' => $uid, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]]);
                }
 
                if (!$recips) {
@@ -4051,13 +4050,18 @@ class Diaspora
         */
        public static function createCommentSignature(array $item)
        {
-               $contact = Contact::getById($item['author-id'], ['url']);
-               if (empty($contact['url'])) {
-                       Logger::warning('Author Contact not found', ['author-id' => $item['author-id']]);
-                       return false;
+               if (!empty($item['author-link'])) {
+                       $url = $item['author-link'];
+               } else {
+                       $contact = Contact::getById($item['author-id'], ['url']);
+                       if (empty($contact['url'])) {
+                               Logger::warning('Author Contact not found', ['author-id' => $item['author-id']]);
+                               return false;
+                       }
+                       $url = $contact['url'];
                }
 
-               $uid = User::getIdForURL($contact['url']);
+               $uid = User::getIdForURL($url);
                if (empty($uid)) {
                        Logger::info('No owner post, so not storing signature', ['url' => $contact['url']]);
                        return false;