]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Processor.php
Merge pull request #9194 from annando/additional-directions
[friendica.git] / src / Protocol / ActivityPub / Processor.php
index 7c40105e20a385def29ddc6076f83548500af177..24ac133358ac539c4874f7c35834087c963d5a6e 100644 (file)
@@ -26,6 +26,7 @@ use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\APContact;
@@ -226,9 +227,9 @@ class Processor
 
                $item['network'] = Protocol::ACTIVITYPUB;
                $item['author-link'] = $activity['author'];
-               $item['author-id'] = Contact::getIdForURL($activity['author'], 0, false);
+               $item['author-id'] = Contact::getIdForURL($activity['author']);
                $item['owner-link'] = $activity['actor'];
-               $item['owner-id'] = Contact::getIdForURL($activity['actor'], 0, false);
+               $item['owner-id'] = Contact::getIdForURL($activity['actor']);
 
                if (in_array(0, $activity['receiver']) && !empty($activity['unlisted'])) {
                        $item['private'] = Item::UNLISTED;
@@ -353,7 +354,7 @@ class Processor
                DBA::close($items);
 
                if (count($original) != count($receivers)) {
-                       Logger::info('Improved data', ['id' => $activity['id'], 'object' => $activity['object_id'], 'original' => $original, 'improved' => $receivers]);
+                       Logger::info('Improved data', ['id' => $activity['id'], 'object' => $activity['object_id'], 'original' => $original, 'improved' => $receivers, 'callstack' => System::callstack()]);
                }
 
                return $receivers;
@@ -527,14 +528,38 @@ class Processor
 
                        $item['uid'] = $receiver;
 
+                       $type = $activity['reception_type'][$receiver] ?? Receiver::TARGET_UNKNOWN;
+                       switch($type) {
+                               case Receiver::TARGET_TO:
+                                       $item['post-type'] = Item::PT_TO;
+                                       break;
+                               case Receiver::TARGET_CC:
+                                       $item['post-type'] = Item::PT_CC;
+                                       break;
+                               case Receiver::TARGET_BTO:
+                                       $item['post-type'] = Item::PT_BTO;
+                                       break;
+                               case Receiver::TARGET_BCC:
+                                       $item['post-type'] = Item::PT_BCC;
+                                       break;
+                               case Receiver::TARGET_FOLLOWER:
+                                       $item['post-type'] = Item::PT_FOLLOWER;
+                                       break;
+                               case Receiver::TARGET_ANSWER:
+                                       $item['post-type'] = Item::PT_COMMENT;
+                                       break;
+                               default:
+                                       $item['post-type'] = Item::PT_ARTICLE;
+                       }
+
                        if ($item['isForum'] ?? false) {
-                               $item['contact-id'] = Contact::getIdForURL($activity['actor'], $receiver, false);
+                               $item['contact-id'] = Contact::getIdForURL($activity['actor'], $receiver);
                        } else {
-                               $item['contact-id'] = Contact::getIdForURL($activity['author'], $receiver, false);
+                               $item['contact-id'] = Contact::getIdForURL($activity['author'], $receiver);
                        }
 
                        if (($receiver != 0) && empty($item['contact-id'])) {
-                               $item['contact-id'] = Contact::getIdForURL($activity['author'], 0, false);
+                               $item['contact-id'] = Contact::getIdForURL($activity['author']);
                        }
 
                        if (!empty($activity['directmessage'])) {
@@ -774,6 +799,9 @@ class Processor
                }
 
                $owner = User::getOwnerDataById($uid);
+               if (empty($owner)) {
+                       return;
+               }
 
                $cid = Contact::getIdForURL($activity['actor'], $uid);
                if (!empty($cid)) {
@@ -822,7 +850,7 @@ class Processor
                }
 
                Logger::info('Updating profile', ['object' => $activity['object_id']]);
-               Contact::updateFromProbeByURL($activity['object_id'], true);
+               Contact::updateFromProbeByURL($activity['object_id']);
        }
 
        /**
@@ -956,6 +984,9 @@ class Processor
                }
 
                $owner = User::getOwnerDataById($uid);
+               if (empty($owner)) {
+                       return;
+               }
 
                $cid = Contact::getIdForURL($activity['actor'], $uid);
                if (empty($cid)) {