]> git.mxchange.org Git - friendica.git/commitdiff
Store "View" activity from Peertube
authorMichael <heluecht@pirati.ca>
Tue, 5 Apr 2022 07:48:38 +0000 (07:48 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 5 Apr 2022 07:48:38 +0000 (07:48 +0000)
src/Protocol/Activity.php
src/Protocol/ActivityNamespace.php
src/Protocol/ActivityPub/Receiver.php

index 637669a61e8bc7acd3744db6f87c224d0e954687..e75b1cf507213b00919be6f7560f5a30453da15f 100644 (file)
@@ -183,6 +183,13 @@ final class Activity
         */
        const EMOJIREACT = ActivityNamespace::LITEPUB . '/emojireact';
 
+       /**
+        * View notification from Peertube
+        *
+        * @var string
+        */
+       const VIEW       = ActivityNamespace::PEERTUBE . '/view';
+
        /**
         * likes (etc.) can apply to other things besides posts. Check if they are post children,
         * in which case we handle them specially
@@ -195,6 +202,7 @@ final class Activity
                self::FOLLOW,
                self::ANNOUNCE,
                self::EMOJIREACT,
+               self::VIEW,
        ];
 
        /**
index 5dbf88c86c2669ad9c6e8fc87fd3bdfba5bbdffa..ee6d80df14a459a6ed4cbcdd844400edd41dcd74 100644 (file)
@@ -144,12 +144,19 @@ final class ActivityNamespace
         * @var string
         */
        const ATOM1           = 'http://www.w3.org/2005/Atom';
+
        /**
         * @var string
         */
        const MASTODON        = 'http://mastodon.social/schema/1.0';
+
        /**
         * @var string
         */
        const LITEPUB         = 'http://litepub.social';
+
+       /**
+        * @var string
+        */
+       const PEERTUBE        = 'https://joinpeertube.org';     
 }
index 0894ffc453c1b2e0bc70b25ac09d9cd762425b4c..80bba0b0b9e8070e070715c537df4be1026ea393 100644 (file)
@@ -385,7 +385,7 @@ class Receiver
                        } else {
                                $object_data['directmessage'] = JsonLD::fetchElement($activity, 'litepub:directMessage');
                        }
-               } elseif (in_array($type, array_merge(self::ACTIVITY_TYPES, ['as:Follow', 'litepub:EmojiReact'])) && in_array($object_type, self::CONTENT_TYPES)) {
+               } elseif (in_array($type, array_merge(self::ACTIVITY_TYPES, ['as:Follow', 'litepub:EmojiReact', 'as:View'])) && in_array($object_type, self::CONTENT_TYPES)) {
                        // Create a mostly empty array out of the activity data (instead of the object).
                        // This way we later don't have to check for the existence of each individual array element.
                        $object_data = self::processObject($activity);
@@ -743,8 +743,10 @@ class Receiver
                                break;
 
                        case 'as:View':
-                               if (in_array($object_data['object_type'], ['as:Note', 'as:Video'])) {
-                                       // Unhandled Peertube activity
+                               if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
+                                       ActivityPub\Processor::createActivity($object_data, Activity::VIEW);
+                               } elseif ($object_data['object_type'] == '') {
+                                       // The object type couldn't be determined. Most likely we don't have it here. We ignore this activity.
                                } else {
                                        self::storeUnhandledActivity(true, $type, $object_data, $activity, $body, $uid, $trust_source, $push, $signer);
                                }