feat(notifications): silence DM pushes for chats filed in the General inbox - #93
Merged
Merged
Conversation
… inbox Users can now file a chat into a Priority or General inbox (api#1037, apps#14593). Per the spec, General is the quiet bucket: the message still lands in the inbox and lights the General tab dot, but no push or browser notification is sent. After the age guard, look up the (receiver, chat_id) pairs about to be pushed in user_conversation_preferences with category = 'general' and drop those. Applies to direct messages, reactions and blasts (a blast to a user who already has a chat with the sender uses the same chat_id). The preference is per receiver, so the other member of the chat is unaffected. Cursors still advance for silenced notifications. The lookup fails open: if it errors (e.g. this ships before the api migration creates the table) every notification is still sent. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Sep 13, 2026
dylanjeffers
added a commit
to AudiusProject/api
that referenced
this pull request
Sep 13, 2026
## Summary
Backend for the **Priority / General inbox split** in the clients. Users
can file each direct-message chat into a Priority or General inbox; the
choice is private to that user and persists so future messages route to
the right tab. A chat with no preference row is uncategorized.
## Changes
- **Migration `0240_user_conversation_preferences.sql`**:
`user_conversation_preferences (user_id, chat_id, category CHECK IN
('priority','general'), updated_at)`, PK `(user_id, chat_id)`.
Idempotent, wrapped in a transaction.
- **RPC `chat.set_category`** `{ chat_id, category: "priority" |
"general" | null }`: validator checks chat membership and the enum;
apply upserts with the RPC timestamp guard (same idiom as
`chat_permissions`), and `null` deletes the row. New `ChatCategory` enum
and `Category` param in `schema.go`.
- **`GET /comms/chats`** and **`GET /comms/chats/:chatId`** now return
`"category"` per chat (`null` for uncategorized and for blast
pseudo-chats). Both queries LEFT JOIN the new table; the `members`
subquery was re-aliased to avoid ambiguity.
- **`GET /comms/chats/unread_by_category`**: `{ priority, general,
uncategorized }` counts of chats with `unread_count > 0`, mirroring
`/comms/chats/unread`'s filter. All three keys are always present.
- `sql/01_schema.sql` / `sql/03_migration_tracker.sql` re-dumped via
`make test-schema`. This also picks up drift from 0238/0239 (which were
never re-dumped) and a pg_dump header version bump from the local image.
`clear_user_records` only exists in the frozen schema dump, so it does
not yet delete from the new table; that needs a separate function
migration if wanted.
## Companion PR
Client side (SDK, store, web and mobile tab UI):
AudiusProject/apps#14593. Deploy this first;
older clients ignore the new field, and the new client falls back
gracefully if the endpoint is missing.
Notifications (pedalboard, DM pushes silenced for chats filed as
General; fails open until the api migration lands):
AudiusProject/pedalboard#93
## Test plan
- [x] `go build ./...`, `go vet` clean, `gofmt` clean on changed files
- [x] `go test ./api/comms/...` (new `TestChatSetCategory`: validator
accept/reject, apply, timestamp guards, clear)
- [x] `go test ./api/...` (new `TestPostMutateChatSetCategory` round
trip through `/comms/mutate` asserting `category` on both GET endpoints
and per-user isolation; new `TestGetUnreadCountByCategory`)
- [ ] Stage: run migration, set a category from the client, confirm
`category` and `unread_by_category` responses
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
dylanjeffers
added a commit
to AudiusProject/apps
that referenced
this pull request
Sep 13, 2026
## Summary
Users are being message-blasted by artists they follow but don't want to
block. This adds the "missing middle" between mute-per-conversation and
block: a **Priority / General** inbox split.
- Two inbox tabs, **Priority** (default) and **General**, on web and
mobile. No Spam tab (block covers that).
- All conversations start **uncategorized** and surface in the Priority
tab, so nothing is buried without a user action.
- Mark a conversation as Priority or General and future messages from
that sender route to that tab automatically. The category is stored
server-side per user (see the companion API PR).
- Each tab shows its own **purple dot** when it has unread messages.
Uncategorized unreads count toward the Priority dot. The existing
sidebar/nav dot keeps firing for unreads in **either** category.
### Categorizing is lightweight
- **Web:** hover a row for an options button, or use the conversation
header menu ("Move to Priority" / "Move to General").
- **Mobile:** swipe a row left to reveal Priority / General, long-press
for the actions drawer, or use the in-conversation drawer.
- No prompt on new chats.
## Changes
- **SDK:** `chats.setCategory` (RPC `chat.set_category`),
`chats.getUnreadCountByCategory`, `ChatCategory` enum, `category` on
`UserChat`.
- **Common store:** `setChatCategory` with optimistic move and rollback
on failure; per-category unread counts (server baseline plus an
optimistic overlay that tracks reads, new messages and moves); per-tab
chat list and unread-dot selectors; success/failure toasts; two
analytics events. Fixed the nav dot's fallback scan, which stopped at
the first blast row and could hide a later unread.
- **Web:** `InboxTabs` in the inbox header (fits the existing 112px
header), `useChatCategoryMenuItems` shared by the list row and the
conversation header, per-tab filtering with backfill in `ChatList`.
- **Mobile:** `InboxTabs`, `ChatCategorySwipeActions`, swipe/long-press
on `ChatListItem`, per-tab filtering with backfill in `ChatListScreen`,
new rows in `ChatActionsDrawer`.
Because chats are paginated by recency across categories, a tab
backfills older pages until it has at least 10 rows or nothing is left.
## Companion PR
Backend (migration `0240_user_conversation_preferences`,
`chat.set_category`, `category` on chat rows, `GET
/comms/chats/unread_by_category`):
AudiusProject/api#1037. Deploy the backend first
for accurate tab dots; older clients ignore the new field, and this
client falls back to loaded chats for the dots if the endpoint is
missing.
## Not included / follow-ups
- Category changes are not pushed over the websocket to a user's other
devices (same as read/delete today); they sync on the next chat fetch.
Notifications (pedalboard, DM pushes silenced for chats filed as
General; fails open until the api migration lands):
AudiusProject/pedalboard#93
## Test plan
- [x] `tsc` clean for sdk, common, web, mobile
- [x] eslint clean on changed files
- [x] common: 21 chat store tests pass (14 new, covering optimistic
move/rollback, unread bucket moves, tab selectors, nav dot)
- [x] web: 9 chat-page tests pass (7 new: tab filtering, per-tab dots,
fallback dot, tab switching, options menu)
- [ ] Manual: web inbox with a signed-in account (tabs, dots, hover
options, header menu)
- [ ] Manual: iOS + Android chat list (tabs, dots, swipe, long-press,
drawer)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
Third piece of the Priority / General inbox split (backend: AudiusProject/api#1037, clients: AudiusProject/apps#14593). Per the spec, General is the quiet bucket: a message in a chat the receiver filed as General still lands in the inbox and lights the General tab dot, but no push or browser notification is sent. Uncategorized and Priority chats notify as before.
Changes
dmNotifications.ts: after the existing age guard,getGeneralInboxKeyslooks up the(receiver_user_id, chat_id)pairs about to be pushed inuser_conversation_preferenceswherecategory = 'general'(one compositewhereInper tick) and those notifications are dropped from the push loop. Cursors still advance for them.chat_idthe preference is stored under, so it is silenced too; a blast to someone with no chat yet has no preference row and notifies normally.0240_user_conversation_preferenceshas run), a warning is logged and every notification is sent as before. Safe to merge in any order relative to the api PR.numberSilencedGeneral.Test plan
npm run typecheckcleanjest src/tasks/__tests__/dmNotifications.test.ts: 30 pass (7 new: silenced message/reaction/blast with cursors advanced, per-receiver isolation and query shape, fail-open on lookup error, no query for an empty batch, helper dedup)numberSilencedGenerallog line🤖 Generated with Claude Code