From 8bfca6373afa91efd902ab12eb395e504102e820 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Mon, 13 Feb 2023 15:13:17 -0500 Subject: [PATCH 1/3] Remove extraneous, unused, non-standard 'count' parameter from request list - artifact of when I was playing around with the endpoint that somehow didn't get deleted when I did the ultimate commit. --- src/Module/Api/Mastodon/Notifications.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Module/Api/Mastodon/Notifications.php b/src/Module/Api/Mastodon/Notifications.php index c46cbe1e60..24564a715a 100644 --- a/src/Module/Api/Mastodon/Notifications.php +++ b/src/Module/Api/Mastodon/Notifications.php @@ -63,7 +63,6 @@ class Notifications extends BaseApi 'exclude_types' => [], // Array of types to exclude (follow, favourite, reblog, mention, poll, follow_request) 'account_id' => 0, // Return only notifications received from this account 'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users. - 'count' => 0, 'include_all' => false // Include dismissed and undismissed ], $request); From 7e91a88d9bc49cc91f4506729a8aef677ff827a5 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Mon, 13 Feb 2023 17:26:24 -0500 Subject: [PATCH 2/3] Add unsupported Friendica notification types to built query --- src/Module/Api/Mastodon/Notifications.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Module/Api/Mastodon/Notifications.php b/src/Module/Api/Mastodon/Notifications.php index 24564a715a..82ccd03edf 100644 --- a/src/Module/Api/Mastodon/Notifications.php +++ b/src/Module/Api/Mastodon/Notifications.php @@ -68,9 +68,12 @@ class Notifications extends BaseApi $params = ['order' => ['id' => true]]; - $condition = ['uid' => $uid, 'dismissed' => false]; - if ($request['include_all']) { - $condition = ['uid' => $uid]; + $condition = ["`uid` = ? AND (NOT `type` IN (?, ?))", $uid, + Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION, + POST\UserNotification::TYPE_COMMENT_PARTICIPATION]; + + if (!$request['include_all']) { + $condition = DBA::mergeConditions($condition, ['dismissed' => false]); } if (!empty($request['account_id'])) { From e384a9d6caf6b163b9a57f59c55e37e73c09748a Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Mon, 13 Feb 2023 17:27:06 -0500 Subject: [PATCH 3/3] Automatic PHPCBF style fix --- src/Module/Api/Mastodon/Notifications.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Module/Api/Mastodon/Notifications.php b/src/Module/Api/Mastodon/Notifications.php index 82ccd03edf..a1e99a6358 100644 --- a/src/Module/Api/Mastodon/Notifications.php +++ b/src/Module/Api/Mastodon/Notifications.php @@ -84,15 +84,21 @@ class Notifications extends BaseApi } if (in_array(Notification::TYPE_INTRODUCTION, $request['exclude_types'])) { - $condition = DBA::mergeConditions($condition, + $condition = DBA::mergeConditions( + $condition, ["(`vid` != ? OR `type` != ? OR NOT `actor-id` IN (SELECT `id` FROM `contact` WHERE `pending`))", - Verb::getID(Activity::FOLLOW), Post\UserNotification::TYPE_NONE]); + Verb::getID(Activity::FOLLOW), + Post\UserNotification::TYPE_NONE] + ); } if (in_array(Notification::TYPE_FOLLOW, $request['exclude_types'])) { - $condition = DBA::mergeConditions($condition, + $condition = DBA::mergeConditions( + $condition, ["(`vid` != ? OR `type` != ? OR NOT `actor-id` IN (SELECT `id` FROM `contact` WHERE NOT `pending`))", - Verb::getID(Activity::FOLLOW), Post\UserNotification::TYPE_NONE]); + Verb::getID(Activity::FOLLOW), + Post\UserNotification::TYPE_NONE] + ); } if (in_array(Notification::TYPE_LIKE, $request['exclude_types'])) { @@ -134,7 +140,7 @@ class Notifications extends BaseApi $request['limit'] ); - foreach($Notifications as $Notification) { + foreach ($Notifications as $Notification) { try { $mstdnNotifications[] = DI::mstdnNotification()->createFromNotification($Notification, self::appSupportsQuotes()); self::setBoundaries($Notification->id);