diff --git a/src/Content/Conversation.php b/src/Content/Conversation.php index d9036c783..eb9af133c 100644 --- a/src/Content/Conversation.php +++ b/src/Content/Conversation.php @@ -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']]); diff --git a/src/Protocol/Activity.php b/src/Protocol/Activity.php index ea1feeefe..7212e9194 100644 --- a/src/Protocol/Activity.php +++ b/src/Protocol/Activity.php @@ -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, ]; /** diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 85965d712..41a3ca0ad 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -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)) {