From 11513519ce11e09c047b1723a4a47034ab187a4b Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 20 Feb 2023 06:41:28 +0000 Subject: [PATCH] Config option to process the "view" activity --- database.sql | 2 +- doc/database/db_config.md | 25 +++++++++++++++++++++++++ src/Protocol/Activity.php | 15 ++++++++------- src/Protocol/ActivityPub/Receiver.php | 2 +- static/dbstructure.config.php | 2 +- static/defaults.config.php | 4 ++++ update.php | 7 +++++++ 7 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 doc/database/db_config.md diff --git a/database.sql b/database.sql index e890d7421a..053f0c7279 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2023.03-dev (Giant Rhubarb) --- DB_UPDATE_VERSION 1514 +-- DB_UPDATE_VERSION 1515 -- ------------------------------------------ diff --git a/doc/database/db_config.md b/doc/database/db_config.md new file mode 100644 index 0000000000..66796caeb1 --- /dev/null +++ b/doc/database/db_config.md @@ -0,0 +1,25 @@ +Table config +=========== + +main configuration storage + +Fields +------ + +| Field | Description | Type | Null | Key | Default | Extra | +| ----- | ------------------------- | ------------- | ---- | --- | ------- | -------------- | +| id | | int unsigned | NO | PRI | NULL | auto_increment | +| cat | The category of the entry | varbinary(50) | NO | | | | +| k | The key of the entry | varbinary(50) | NO | | | | +| v | | mediumtext | YES | | NULL | | + +Indexes +------------ + +| Name | Fields | +| ------- | -------------- | +| PRIMARY | id | +| cat_k | UNIQUE, cat, k | + + +Return to [database documentation](help/database) diff --git a/src/Protocol/Activity.php b/src/Protocol/Activity.php index c5fca4a5cc..aa322f4cf2 100644 --- a/src/Protocol/Activity.php +++ b/src/Protocol/Activity.php @@ -171,6 +171,14 @@ final class Activity */ const READ = ActivityNamespace::ACTIVITY2 . 'read'; + /** + * Indicates that the actor has viewed the object. + * + * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-view + * @var string + */ + const VIEW = ActivityNamespace::ACTIVITY2 . 'view'; + const O_UNFOLLOW = ActivityNamespace::OSTATUS . '/unfollow'; const O_UNFAVOURITE = ActivityNamespace::OSTATUS . '/unfavorite'; @@ -181,13 +189,6 @@ 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 diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 16257c2f95..4b8f1557b8 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -559,7 +559,7 @@ class Receiver return true; } - if ($type == 'as:View') { + if (!DI::config()->get('system', 'process_view') && ($type == 'as:View')) { Logger::info('View activities are ignored.', ['signer' => $signer, 'http_signer' => $http_signer]); return true; } diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index dcab1d0c87..83c890915d 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -55,7 +55,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1514); + define('DB_UPDATE_VERSION', 1515); } return [ diff --git a/static/defaults.config.php b/static/defaults.config.php index bb82473fa9..2c45e45e48 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -503,6 +503,10 @@ return [ // Sets the ImageMagick compression level for PNG images. Values range from 0 (uncompressed) to 9 (most compressed). 'png_quality' => 8, + // process_view (Boolean) + // Process the "View" activity that is used by Peertube. View activities are displayed, when "emoji_activities" are enabled. + 'process_view' => false, + // profiler (Boolean) // Enable internal timings to help optimize code. Needed for "rendertime" addon. 'profiler' => false, diff --git a/update.php b/update.php index 86735f864c..d6988c1d9c 100644 --- a/update.php +++ b/update.php @@ -59,6 +59,7 @@ use Friendica\Model\Photo; use Friendica\Model\Post; use Friendica\Model\Profile; use Friendica\Model\User; +use Friendica\Protocol\Activity; use Friendica\Protocol\Delivery; use Friendica\Security\PermissionSet\Repository\PermissionSet; @@ -1287,3 +1288,9 @@ function update_1514() return Update::SUCCESS; } + +function update_1515() +{ + DBA::update('verb', ['name' => Activity::VIEW], ['name' => 'https://joinpeertube.org/view']); + return Update::SUCCESS; +}