Add Collections notification support - #2494
Open
joebarbere wants to merge 2 commits into
Open
Conversation
Mastodon 4.6 added two notification types for Collections: `added_to_collection` (someone added you to their collection) and `collection_update` (a collection you're featured in changed). Both carry the Collection entity on the notification, and both the v1 and the v2 grouped notification endpoints serialize it. Until now Ice Cubes dropped these on the floor: an unknown `type` maps to a nil `supportedType`, and both consolidation paths skip those. This adds the two cases, decodes the attached `collection` on Notification and NotificationGroup, carries it through consolidation, and renders it in the notification row as the same collection pill used on profiles, tappable through to the existing collection detail view. Push notification taps route there too. The two new types are also offered in the notifications filter menu, but only on 4.6+ instances — older servers return nothing for them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ab8HLH6dDqz5QtrW2yWyeE
`CurrentInstance.version` parses `String.prefix(3)` into a Float, so a future "4.10" reads as 4.1 and would silently switch Collections back off. Collections shipped in 4.6.0, which bumped `api_versions.mastodon` to 10 (4.5.0 was 7, 4.7.1 is 11), so gate on that instead — the same way `isQuoteSupported` already does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ab8HLH6dDqz5QtrW2yWyeE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 of #2478, following #2479 (read-only viewing).
Mastodon 4.6 added two notification types for Collections:
added_to_collection(someone added you to their collection) andcollection_update(a collection you're featured in changed). Both carry the Collection entity on the notification.Until now Ice Cubes dropped these silently — an unrecognized
typemaps to a nilsupportedType, and both consolidation paths skip those notifications entirely.What's here
NotificationTypecases, andcollectiondecoded on bothNotificationandNotificationGroup.newGroup.collection ?? existingGroup.collection, so a merge can't drop it).NotificationRowCollectionViewrenders the same bordered pill used on profiles, tapping through to the existingCollectionDetailView. Icons arerectangle.stack.badge.person.crop.fillandperson.2.crop.square.stack.fill, tinted indigo.CurrentInstance.isCollectionsSupported.Notes
NotificationGroupcarriescollectiontoo. The docs page for that entity doesn't list it, butREST::NotificationGroupSerializeremits it for these types alongsideREST::NotificationSerializer— I went with the source, so the grouped (v2) path works and not just v1.isCollectionsSupportedchecksapi_versions.mastodon >= 10rather than parsing the version string. Collections shipped in 4.6.0, which bumped that to 10 (4.5.0 was 7, 4.7.1 is 11). The existingversionhelper doesFloat(String.prefix(3)), which would read a future "4.10" as 4.1 — this followsisQuoteSupportedinstead.There are no WebPush
alertskeys for collections, so the server never pushes these types; theNotificationTabbranch exists for exhaustiveness and future-proofing.Testing
Builds clean for the iOS simulator.
ModelsTestspasses 16/16, including four new decode tests: both notification types, a notification with no collection attached, and aNotificationGroupcarrying one.