]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Processor.php
Add return value to Model\Contact::addRelationship to remove protocol-specific code...
[friendica.git] / src / Protocol / ActivityPub / Processor.php
index 70728edc9ea9e35b54624f1515d07c58a4b3c23f..8280ccfb78513d67372e2c53a024016b50a6eb42 100644 (file)
@@ -173,7 +173,7 @@ class Processor
                        $item['object-type'] = ACTIVITY_OBJ_COMMENT;
                }
 
-               if (($activity['id'] != $activity['reply-to-id']) && !Item::exists(['uri' => $activity['reply-to-id']])) {
+               if (empty($activity['directmessage']) && ($activity['id'] != $activity['reply-to-id']) && !Item::exists(['uri' => $activity['reply-to-id']])) {
                        Logger::log('Parent ' . $activity['reply-to-id'] . ' not found. Try to refetch it.');
                        self::fetchMissingActivity($activity['reply-to-id'], $activity);
                }
@@ -530,7 +530,7 @@ class Processor
                        DBA::update('contact', ['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
                        $contact = DBA::selectFirst('contact', [], ['id' => $cid, 'network' => Protocol::NATIVE_SUPPORT]);
                } else {
-                       $contact = false;
+                       $contact = [];
                }
 
                $item = ['author-id' => Contact::getIdForURL($activity['actor']),
@@ -541,7 +541,14 @@ class Processor
                // Ensure that the contact has got the right network type
                self::switchContact($item['author-id']);
 
-               Contact::addRelationship($owner, $contact, $item, '', false, $note);
+               $result = Contact::addRelationship($owner, $contact, $item, false, $note);
+               if ($result === false) {
+                       ActivityPub\Transmitter::sendContactReject($item['author-link'], $item['author-id'], $owner['uid']);
+                       return;
+               }elseif ($result === true) {
+                       ActivityPub\Transmitter::sendContactAccept($item['author-link'], $item['author-id'], $owner['uid']);
+               }
+
                $cid = Contact::getIdForURL($activity['actor'], $uid);
                if (empty($cid)) {
                        return;