]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Receiver.php
Avoid PHP Warning: Illegal string offset 'type' in /src/Protocol/ActivityPub/Receive...
[friendica.git] / src / Protocol / ActivityPub / Receiver.php
index 62a583dc8caa0769413ea0e37d3106b0fb999a13..0a0d37a7cdb331f3c87ce20291a51c7501cd57c8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -111,9 +111,12 @@ class Receiver
                }
 
                $http_signer = HTTPSignature::getSigner($body, $header);
-               if (empty($http_signer)) {
+               if ($http_signer === false) {
                        Logger::warning('Invalid HTTP signature, message will be discarded.');
                        return;
+               } elseif (empty($http_signer)) {
+                       Logger::info('Signer is a tombstone. The message will be discarded, the signer account is deleted.');
+                       return;
                } else {
                        Logger::info('Valid HTTP signature', ['signer' => $http_signer]);
                }
@@ -522,7 +525,7 @@ class Receiver
                                                return;
                                        }
 
-                                       $item['post-type'] = Item::PT_ANNOUNCEMENT;
+                                       $item['post-reason'] = Item::PR_ANNOUNCEMENT;
                                        ActivityPub\Processor::postItem($object_data, $item);
 
                                        $announce_object_data = self::processObject($activity);
@@ -660,13 +663,14 @@ class Receiver
                }
 
                if (!empty($actor)) {
-                       $profile = APContact::getByURL($actor);
+                       $profile   = APContact::getByURL($actor);
                        $followers = $profile['followers'] ?? '';
-
-                       Logger::log('Actor: ' . $actor . ' - Followers: ' . $followers, Logger::DEBUG);
+                       $is_forum  = ($actor['type'] ?? '') == 'Group';
+                       Logger::info('Got actor and followers', ['actor' => $actor, 'followers' => $followers]);
                } else {
                        Logger::info('Empty actor', ['activity' => $activity]);
                        $followers = '';
+                       $is_forum  = false;
                }
 
                // We have to prevent false follower assumptions upon thread completions
@@ -689,7 +693,7 @@ class Receiver
                                }
 
                                // Fetch the receivers for the public and the followers collection
-                               if (in_array($receiver, [$followers, self::PUBLIC_COLLECTION]) && !empty($actor)) {
+                               if ((($receiver == $followers) || (($receiver == self::PUBLIC_COLLECTION) && !$is_forum)) && !empty($actor)) {
                                        $receivers = self::getReceiverForActor($actor, $tags, $receivers, $follower_target);
                                        continue;
                                }
@@ -1268,14 +1272,6 @@ class Receiver
                        } elseif ($filetype == 'video') {
                                $height = (int)JsonLD::fetchElement($url, 'as:height', '@value');
                                $size = (int)JsonLD::fetchElement($url, 'pt:size', '@value');
-
-                               // We save bandwidth by using a moderate height (alt least 480 pixel height)
-                               // Peertube normally uses these heights: 240, 360, 480, 720, 1080
-                               if (!empty($attachments[$filetype]['height']) &&
-                                       ($height > $attachments[$filetype]['height']) && ($attachments[$filetype]['height'] >= 480)) {
-                                       continue;
-                               }
-
                                $attachments[$filetype] = ['type' => $mediatype, 'url' => $href, 'height' => $height, 'size' => $size];
                        } elseif (in_array($mediatype, ['application/x-bittorrent', 'application/x-bittorrent;x-scheme-handler/magnet'])) {
                                $height = (int)JsonLD::fetchElement($url, 'as:height', '@value');
@@ -1372,6 +1368,7 @@ class Receiver
                $object_data = self::getSource($object, $object_data);
                $object_data['start-time'] = JsonLD::fetchElement($object, 'as:startTime', '@value');
                $object_data['end-time'] = JsonLD::fetchElement($object, 'as:endTime', '@value');
+               $object_data['adjust'] = JsonLD::fetchElement($object, 'dfrn:adjust', '@value');
                $object_data['location'] = $location;
                $object_data['latitude'] = JsonLD::fetchElement($object, 'as:location', 'as:latitude', '@type', 'as:Place');
                $object_data['latitude'] = JsonLD::fetchElement($object_data, 'latitude', '@value');