]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Merge pull request #9652 from annando/issue-9584
[friendica.git] / src / Protocol / Diaspora.php
index 7ab41eb52b08ea6bd1b2d9bdbf41e442df4b5f65..54a8d1c1bafc8dc908e515074253df4ac298f419 100644 (file)
@@ -3031,7 +3031,18 @@ class Diaspora
                        $owner['uprvkey'] = $owner['prvkey'];
                }
 
-               $envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $contact['pubkey'], $public_batch);
+               // When sending content to Friendica contacts using the Diaspora protocol
+               // we have to fetch the public key from the fcontact.
+               // This is due to the fact that legacy DFRN had unique keys for every contact.
+               $pubkey = $contact['pubkey'];
+               if (!empty($contact['addr'])) {
+                       $fcontact = FContact::getByURL($contact['addr']);
+                       if (!empty($fcontact)) {
+                               $pubkey = $fcontact['pubkey'];
+                       }
+               }
+
+               $envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $pubkey, $public_batch);
 
                $return_code = self::transmit($owner, $contact, $envelope, $public_batch, $guid);