]> git.mxchange.org Git - friendica.git/commitdiff
Activity "Read" is now stored
authorMichael <heluecht@pirati.ca>
Mon, 26 Dec 2022 08:41:40 +0000 (08:41 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 26 Dec 2022 08:41:40 +0000 (08:41 +0000)
src/Content/Conversation.php
src/Protocol/Activity.php
src/Protocol/ActivityPub/Receiver.php

index d9036c78399c99be8fdd77a94a2fd4ee4f4c4c70..eb9af133c18e4ee6bdfd6269cea1dc0f8b109787 100644 (file)
@@ -970,7 +970,7 @@ class Conversation
                }
 
                $condition = DBA::mergeConditions($condition,
-                       ["`uid` IN (0, ?) AND (NOT `vid` IN (?, ?) OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW), Verb::getID(Activity::VIEW)]);
+                       ["`uid` IN (0, ?) AND (NOT `vid` IN (?, ?, ?) OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW), Verb::getID(Activity::VIEW), Verb::getID(Activity::READ)]);
 
                $thread_parents = Post::select(['uri-id', 'causer-id'], $condition, ['order' => ['uri-id' => false, 'uid']]);
 
index ea1feeefee82c2d4259f05ac3e5c0ea1bc4ee2f8..7212e919410fb2f236d65e6d1c1375743490436c 100644 (file)
@@ -163,6 +163,13 @@ final class Activity
         * @var string
         */
        const ANNOUNCE   = ActivityNamespace::ACTIVITY2 . 'Announce';
+       /**
+        * Indicates that the actor has read the object.
+        *
+        * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-read
+        * @var string
+        */
+       const READ       = ActivityNamespace::ACTIVITY2 . 'read';
 
        const O_UNFOLLOW    = ActivityNamespace::OSTATUS . '/unfollow';
        const O_UNFAVOURITE = ActivityNamespace::OSTATUS . '/unfavorite';
@@ -194,6 +201,7 @@ final class Activity
                self::ANNOUNCE,
                self::EMOJIREACT,
                self::VIEW,
+               self::READ,
        ];
 
        /**
index 85965d71291198ea9e2eca8e4e5fe24532084f2e..41a3ca0ad7d40733c0deb9c80267203d1743a233 100644 (file)
@@ -63,7 +63,7 @@ class Receiver
        const PUBLIC_COLLECTION = 'as:Public';
        const ACCOUNT_TYPES = ['as:Person', 'as:Organization', 'as:Service', 'as:Group', 'as:Application'];
        const CONTENT_TYPES = ['as:Note', 'as:Article', 'as:Video', 'as:Image', 'as:Event', 'as:Audio', 'as:Page', 'as:Question'];
-       const ACTIVITY_TYPES = ['as:Like', 'as:Dislike', 'as:Accept', 'as:Reject', 'as:TentativeAccept'];
+       const ACTIVITY_TYPES = ['as:Like', 'as:Dislike', 'as:Accept', 'as:Reject', 'as:TentativeAccept', 'as:Read'];
 
        const TARGET_UNKNOWN = 0;
        const TARGET_TO = 1;
@@ -934,6 +934,9 @@ class Receiver
                                } elseif (in_array($object_data['object_type'], ['as:Delete'])) {
                                        // We cannot undo deletions, so we just ignore this
                                        Queue::remove($object_data);
+                               } elseif (in_array($object_data['object_object_type'], ['as:Tombstone'])) {
+                                       // The object is a tombstone, we ignore any actions on it.
+                                       Queue::remove($object_data);
                                } else {
                                        return false;
                                }
@@ -949,6 +952,16 @@ class Receiver
                                        return false;
                                }
                                break;
+                       case 'as:Read':
+                               if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
+                                       ActivityPub\Processor::createActivity($object_data, Activity::READ);
+                               } elseif ($object_data['object_type'] == '') {
+                                       // The object type couldn't be determined. Most likely we don't have it here. We ignore this activity.
+                                       Queue::remove($object_data);
+                               } else {
+                                       return false;
+                               }
+                               break;
 
                        case 'litepub:EmojiReact':
                                if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {