Add grouped notifications API #7910
No reviewers
Labels
No labels
AP C2S
AdminAPI
Breaking API
Breaks existing config
Check if still valid
Data Protection
Do not merge
Document in the changelog
Doing
Feature Request / Enhancement
MastoAPI
NL2
NL4
OStatus
OTP Releases
Refactor
Security
To Do
TwitterAPI
bug
complicated
confirmed
deps
discussion
documentation
easy
feature: to be merged in stable
fix: to be merged in stable
incident
needs to be backported to maint
needs-changes
needs-info
needs-review
performance
regression
unclear
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
pleroma/pleroma!7910
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-7905-grouped-notifications"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
/api/v2/notifications.Testing
mix format --check-formattedondocker.io/elixir:1.15-alpinepassed.git diff --checkpassed.docker.io/elixir:1.18-otp-27-alpine:4812 tests, 0 failures, 2 excluded, 4 skipped.docker.io/elixir:1.15-alpine:4812 tests, 0 failures, 2 excluded, 4 skipped.Closes #7905.
WIP: Add grouped notifications APIto Add grouped notifications APIAdd grouped notifications APIto WIP: Add grouped notifications API@ -78,0 +73,4 @@def get_grouped_notification_page(user, params \\ %{}) dogrouped_types =params|> Map.get("grouped_types", Map.get(params, :grouped_types))I guess this is here for uncasted and atom casted
grouped_typeswhich doesn't seem to be used. There doesn't seem to be any test that would use the atom representation. Ideally there should be only one representation of the same thing.The non-atom representation is triggered with this test:
test "round-trips ungrouped group keys when grouped_types excludes a type" do@ -78,0 +98,4 @@}enddef get_grouped_notification_groups(user, params \\ %{}) dounused?
@ -78,0 +177,4 @@since_id = Map.get(params, "since_id", Map.get(params, :since_id)) ->{:desc, [{:gt, since_id}]}max_id = Map.get(params, "max_id", Map.get(params, :max_id)) ->Same as
grouped_limit@ -78,0 +187,4 @@defp grouped_limit(params) doparams|> Map.get("limit", Map.get(params, :limit, 40))Same as get_grouped_notification_page, although this is a pagination cursor, so I guess this is relevant:
# Some OpenApiSpex routes cast cursor params to atoms. Keep the historical default for@ -78,0 +195,4 @@def unread_notification_group_count(user, params \\ %{}) dogrouped_types =params|> Map.get("grouped_types", Map.get(params, :grouped_types))Same as get_grouped_notification_page
@ -87,0 +406,4 @@defp unread_count_limit(params) doparams|> Map.get("limit", Map.get(params, :limit, 100))Same as
grouped_limit.@ -75,0 +95,4 @@statuses =notification_groups|> Enum.map(&List.first/1)If I'm reading this right, this would cause only the first post in each group to be rendered, which I'm not sure if that is correct. The Mastodon docs aren't explicit about that, but the given example implies that this would be intended.
@ -580,0 +837,4 @@refute link_header =~ "since_id="endtest "lists accounts from and dismisses a notification group" doNitpick: split into two tests
Addressed review cleanup in fc9e6793c:\n\n- normalized grouped notification service params to the string-keyed form produced by NotificationController\n- removed the unused get_grouped_notification_groups/2 helper\n- split the group accounts and dismiss coverage into separate tests\n\nI left grouped_index status rendering as one status per notification group. The grouped response exposes one status_id per group, and rendering all sampled notifications' statuses would duplicate the same status for grouped favourites/reblogs rather than adding useful response data.\n\nVerification:\n- focused notification controller/view tests passed locally: 49 tests, 0 failures\n- mix format --check-formatted passed\n- git diff --check passed\n- CI pipeline 366 passed
Formatted version of my previous comment:
Addressed review cleanup in
fc9e6793c:I left grouped_index status rendering as one status per notification group. The grouped response exposes one status_id per group, and rendering all sampled notification statuses would duplicate the same status for grouped favourites/reblogs rather than adding useful response data.
Verification:
@lambadalambda wrote in #7910 (comment):
In the way it currently works and the way how Mastodon currently implemented it, that is the case. If we ever in the future will want to group replies/mentions to a post for example, the current way would no longer work as it would only render one reply instead of all of them.
So good enough for now.
Anyways, I've played with it locally and everything seems to be working as expected besides the unimplemented
supported_typesandexpand_accountsquery params. I don't think we need those and they can be added later.WIP: Add grouped notifications APIto Add grouped notifications API