From d242332aa41cd4a4e064919f6dd64ba2adc4031c Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 5 Jun 2022 15:02:03 +0000 Subject: [PATCH 1/3] Add the notify type to the notification query --- database.sql | 4 ++-- doc/database/db_notification.md | 2 +- src/Navigation/Notifications/Repository/Notification.php | 6 +++--- static/dbstructure.config.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/database.sql b/database.sql index 57ce736f13..c0c5f78358 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2022.05-rc (Siberian Iris) --- DB_UPDATE_VERSION 1466 +-- DB_UPDATE_VERSION 1467 -- ------------------------------------------ @@ -848,7 +848,7 @@ CREATE TABLE IF NOT EXISTS `notification` ( `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID', `uid` mediumint unsigned COMMENT 'Owner User id', `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs', - `type` tinyint unsigned COMMENT '', + `type` smallint unsigned COMMENT '', `actor-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the actor that caused the notification', `target-uri-id` int unsigned COMMENT 'Item-uri id of the related post', `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post', diff --git a/doc/database/db_notification.md b/doc/database/db_notification.md index 7c7dc3a543..e79778cb5b 100644 --- a/doc/database/db_notification.md +++ b/doc/database/db_notification.md @@ -11,7 +11,7 @@ Fields | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | | uid | Owner User id | mediumint unsigned | YES | | NULL | | | vid | Id of the verb table entry that contains the activity verbs | smallint unsigned | YES | | NULL | | -| type | | tinyint unsigned | YES | | NULL | | +| type | | smallint unsigned | YES | | NULL | | | actor-id | Link to the contact table with uid=0 of the actor that caused the notification | int unsigned | YES | | NULL | | | target-uri-id | Item-uri id of the related post | int unsigned | YES | | NULL | | | parent-uri-id | Item-uri id of the parent of the related post | int unsigned | YES | | NULL | | diff --git a/src/Navigation/Notifications/Repository/Notification.php b/src/Navigation/Notifications/Repository/Notification.php index 7c3a65fc09..e61ea57e2a 100644 --- a/src/Navigation/Notifications/Repository/Notification.php +++ b/src/Navigation/Notifications/Repository/Notification.php @@ -117,7 +117,7 @@ class Notification extends BaseRepository */ public function selectDetailedForUser(int $uid): Collection\Notifications { - $condition = []; + $condition = ["`type` & ? != 0", $this->pconfig->get($uid, 'system', 'notify_type', 3 | 72 | 4 | 16 | 32) | 128 | 256]; if (!$this->pconfig->get($uid, 'system', 'notify_like')) { $condition = DBA::mergeConditions($condition, ['`vid` != ?', Verb::getID(\Friendica\Protocol\Activity::LIKE)]); } @@ -138,7 +138,7 @@ class Notification extends BaseRepository */ public function selectDigestForUser(int $uid): Collection\Notifications { - $values = [$uid]; + $values = [$uid, $this->pconfig->get($uid, 'system', 'notify_type', 3 | 72 | 4 | 16 | 32) | 128 | 256]; $like_condition = ''; if (!$this->pconfig->get($uid, 'system', 'notify_like')) { @@ -158,7 +158,7 @@ class Notification extends BaseRepository WHERE `id` IN ( SELECT MAX(`id`) FROM `notification` - WHERE `uid` = ? + WHERE `uid` = ? AND `type` & ? != 0 $like_condition $announce_condition GROUP BY IFNULL(`parent-uri-id`, `actor-id`) diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 1594175b1b..642e1667bd 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', 1466); + define('DB_UPDATE_VERSION', 1467); } return [ @@ -902,7 +902,7 @@ return [ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "uid" => ["type" => "mediumint unsigned", "foreign" => ["user" => "uid"], "comment" => "Owner User id"], "vid" => ["type" => "smallint unsigned", "foreign" => ["verb" => "id", "on delete" => "restrict"], "comment" => "Id of the verb table entry that contains the activity verbs"], - "type" => ["type" => "tinyint unsigned", "comment" => ""], + "type" => ["type" => "smallint unsigned", "comment" => ""], "actor-id" => ["type" => "int unsigned", "foreign" => ["contact" => "id"], "comment" => "Link to the contact table with uid=0 of the actor that caused the notification"], "target-uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Item-uri id of the related post"], "parent-uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Item-uri id of the parent of the related post"], From 24559b711b17acbe7393139edf5bd9d33307d8b5 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 5 Jun 2022 16:26:20 +0000 Subject: [PATCH 2/3] Notify about shared posts again --- src/Navigation/Notifications/Repository/Notify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Navigation/Notifications/Repository/Notify.php b/src/Navigation/Notifications/Repository/Notify.php index 71d2eba0cf..2e27871318 100644 --- a/src/Navigation/Notifications/Repository/Notify.php +++ b/src/Navigation/Notifications/Repository/Notify.php @@ -663,7 +663,7 @@ class Notify extends BaseRepository $type = \Friendica\Factory\Api\Mastodon\Notification::getType($Notification); } - if (in_array($Notification->type, [Model\Post\UserNotification::TYPE_FOLLOW])) { + if (in_array($Notification->type, [Model\Post\UserNotification::TYPE_FOLLOW, Model\Post\UserNotification::TYPE_SHARED])) { return true; } From 9daeb552ddfa03c06b414e1c9ebe49fd06c9bac8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 5 Jun 2022 16:54:29 +0000 Subject: [PATCH 3/3] Suppress dislikes --- src/Navigation/Notifications/Repository/Notification.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Navigation/Notifications/Repository/Notification.php b/src/Navigation/Notifications/Repository/Notification.php index e61ea57e2a..e7ef062114 100644 --- a/src/Navigation/Notifications/Repository/Notification.php +++ b/src/Navigation/Notifications/Repository/Notification.php @@ -119,7 +119,7 @@ class Notification extends BaseRepository { $condition = ["`type` & ? != 0", $this->pconfig->get($uid, 'system', 'notify_type', 3 | 72 | 4 | 16 | 32) | 128 | 256]; if (!$this->pconfig->get($uid, 'system', 'notify_like')) { - $condition = DBA::mergeConditions($condition, ['`vid` != ?', Verb::getID(\Friendica\Protocol\Activity::LIKE)]); + $condition = DBA::mergeConditions($condition, ['NOT `vid` IN (?, ?)', Verb::getID(\Friendica\Protocol\Activity::LIKE), Verb::getID(\Friendica\Protocol\Activity::DISLIKE)]); } if (!$this->pconfig->get($uid, 'system', 'notify_announce')) { @@ -142,8 +142,9 @@ class Notification extends BaseRepository $like_condition = ''; if (!$this->pconfig->get($uid, 'system', 'notify_like')) { - $like_condition = 'AND vid != ?'; + $like_condition = 'AND NOT `vid` IN (?, ?)'; $values[] = Verb::getID(\Friendica\Protocol\Activity::LIKE); + $values[] = Verb::getID(\Friendica\Protocol\Activity::DISLIKE); } $announce_condition = '';