From 4c421125576c4aab0d0e3003fff98e984d3db53f Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Wed, 14 Oct 2026 23:54:31 +0300 Subject: [PATCH] APP-3450: Read subscribed post parents from the grouped notifications lexicon (#12012) --- lexicons.json | 12 ++-- .../notification/getGroupedNotifications.json | 5 ++ lexicons/tools/ozone/inbox/defs.json | 36 ++++++++-- .../inbox/getNotificationPreferences.json | 3 +- .../inbox/putNotificationPreferences.json | 19 +++-- lexicons/tools/ozone/queue/defs.json | 23 +++++- lexicons/tools/ozone/report/defs.json | 71 ++++++++++++++++++- .../grouped/__tests__/hydrate.test.ts | 56 ++++++--------- .../queries/notifications/grouped/hydrate.ts | 23 ++---- .../queries/notifications/grouped/types.ts | 3 +- 10 files changed, 177 insertions(+), 74 deletions(-) diff --git a/lexicons.json b/lexicons.json index a22a8811d..458e49151 100644 --- a/lexicons.json +++ b/lexicons.json @@ -706,7 +706,7 @@ }, "app.bsky.notification.getGroupedNotifications": { "uri": "at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.notification.getGroupedNotifications", - "cid": "bafyreierpxcqidgy57zawmtvlh5kg6paj2a3njo5cy3kj46uwkl3jyyfii" + "cid": "bafyreihlp4gpub6pvz7uf7b6qtch3sghv4m5heqzjaxzg5zuxk2qvltwra" }, "app.bsky.notification.getPreferences": { "uri": "at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.notification.getPreferences", @@ -1358,7 +1358,7 @@ }, "tools.ozone.inbox.defs": { "uri": "at://did:plc:33dt5kftu3jq2h5h4jjlqezt/com.atproto.lexicon.schema/tools.ozone.inbox.defs", - "cid": "bafyreidt5cwylevqwmjsuq7s6zqi33vttejv63zgufxrizdgqyugl2zwxm" + "cid": "bafyreiedged2hwzoith3rlx3sgfgj23w5pemxzjnusmwuu64qe34og4fmy" }, "tools.ozone.inbox.getAccountStatus": { "uri": "at://did:plc:33dt5kftu3jq2h5h4jjlqezt/com.atproto.lexicon.schema/tools.ozone.inbox.getAccountStatus", @@ -1370,7 +1370,7 @@ }, "tools.ozone.inbox.getNotificationPreferences": { "uri": "at://did:plc:33dt5kftu3jq2h5h4jjlqezt/com.atproto.lexicon.schema/tools.ozone.inbox.getNotificationPreferences", - "cid": "bafyreiff6smhk4bhqjpvwmxmwotygtdalxonvfjtjavdlzuo6lapphyv7q" + "cid": "bafyreiazdste66eecwcgsl5vexikckasfhg7rgu6lfz27mstxz46nz7c7q" }, "tools.ozone.inbox.getReport": { "uri": "at://did:plc:33dt5kftu3jq2h5h4jjlqezt/com.atproto.lexicon.schema/tools.ozone.inbox.getReport", @@ -1394,7 +1394,7 @@ }, "tools.ozone.inbox.putNotificationPreferences": { "uri": "at://did:plc:33dt5kftu3jq2h5h4jjlqezt/com.atproto.lexicon.schema/tools.ozone.inbox.putNotificationPreferences", - "cid": "bafyreiaejh7rdbmc4pukpwtnva5wberlwmi3zeltntkhzslhmwf2xlv6tu" + "cid": "bafyreiazgoerjgyqfou5clawjregprsq4fbeoe7zffbondlwbza5xdgsbi" }, "tools.ozone.inbox.updateSeen": { "uri": "at://did:plc:33dt5kftu3jq2h5h4jjlqezt/com.atproto.lexicon.schema/tools.ozone.inbox.updateSeen", @@ -1406,11 +1406,11 @@ }, "tools.ozone.queue.defs": { "uri": "at://did:plc:33dt5kftu3jq2h5h4jjlqezt/com.atproto.lexicon.schema/tools.ozone.queue.defs", - "cid": "bafyreify2cxcs5fziz6pqeufotqh632tp7oxedraayjstw6tglwjpuoalm" + "cid": "bafyreifxbjw2p6w6k2xx2yhwt5nwfy3zudp72ywinuedvyq3z2oeuky3le" }, "tools.ozone.report.defs": { "uri": "at://did:plc:33dt5kftu3jq2h5h4jjlqezt/com.atproto.lexicon.schema/tools.ozone.report.defs", - "cid": "bafyreierydps5vinv5ods32xe6vcgfdvncpaeoxyyuysidr7moedajpoou" + "cid": "bafyreibcqpddhvrdffur6yxwdyam7myg277pp2w7dpgcahwz72gqlneoau" }, "tools.ozone.server.getCapabilities": { "uri": "at://did:plc:33dt5kftu3jq2h5h4jjlqezt/com.atproto.lexicon.schema/tools.ozone.server.getCapabilities", diff --git a/lexicons/app/bsky/notification/getGroupedNotifications.json b/lexicons/app/bsky/notification/getGroupedNotifications.json index a47deb416..4bed4a649 100644 --- a/lexicons/app/bsky/notification/getGroupedNotifications.json +++ b/lexicons/app/bsky/notification/getGroupedNotifications.json @@ -391,6 +391,11 @@ "actor": { "type": "string", "format": "did" + }, + "parent": { + "type": "string", + "format": "at-uri", + "description": "The post this one replies to, if it is a reply." } }, "description": "One new post by an actor the requesting account subscribes to." diff --git a/lexicons/tools/ozone/inbox/defs.json b/lexicons/tools/ozone/inbox/defs.json index b37f14ae2..0038a2450 100644 --- a/lexicons/tools/ozone/inbox/defs.json +++ b/lexicons/tools/ozone/inbox/defs.json @@ -97,6 +97,14 @@ "expired" ] }, + "outcome": { + "type": "string", + "description": "Decision on a resolved appeal.", + "knownValues": [ + "approved", + "denied" + ] + }, "appealedAt": { "type": "string", "format": "datetime" @@ -151,6 +159,14 @@ }, "actionType": { "type": "string" + }, + "appealOutcome": { + "type": "string", + "description": "Decision captured when an appealResolved notification was created. Omitted when the outcome is unknown.", + "knownValues": [ + "approved", + "denied" + ] } } }, @@ -425,13 +441,25 @@ "notificationPreferences": { "type": "object", "required": [ - "push" + "reports", + "account", + "labels" ], "properties": { - "push": { - "type": "boolean" + "labels": { + "type": "boolean", + "description": "Notify when labels are applied to or removed from the account or its content (labelApplied and labelRemoved actions)." + }, + "account": { + "type": "boolean", + "description": "Notify about moderation actions against the account or its content, action reversals, appeal outcomes, and standing changes. Label application and removal are controlled by labels." + }, + "reports": { + "type": "boolean", + "description": "Notify about outcomes of reports filed by the account (reportResolved and reportReopened)." } - } + }, + "description": "Push notification preferences by moderation notification category. These preferences do not hide in-app inbox activity. Each category defaults to enabled." } }, "$type": "com.atproto.lexicon.schema", diff --git a/lexicons/tools/ozone/inbox/getNotificationPreferences.json b/lexicons/tools/ozone/inbox/getNotificationPreferences.json index 960ed2b4c..c03d72e56 100644 --- a/lexicons/tools/ozone/inbox/getNotificationPreferences.json +++ b/lexicons/tools/ozone/inbox/getNotificationPreferences.json @@ -27,7 +27,8 @@ "description": "Account to preview. Only Ozone staff can read another account; this does not change its read state." } } - } + }, + "description": "Get moderation push notification preferences for report outcomes, account actions, and labeling. Returns all three categories, defaulting to enabled for an account without saved preferences." } }, "$type": "com.atproto.lexicon.schema", diff --git a/lexicons/tools/ozone/inbox/putNotificationPreferences.json b/lexicons/tools/ozone/inbox/putNotificationPreferences.json index ebfd6e7f5..7d416f502 100644 --- a/lexicons/tools/ozone/inbox/putNotificationPreferences.json +++ b/lexicons/tools/ozone/inbox/putNotificationPreferences.json @@ -6,12 +6,18 @@ "input": { "schema": { "type": "object", - "required": [ - "push" - ], "properties": { - "push": { - "type": "boolean" + "labels": { + "type": "boolean", + "description": "Notify about labels applied to or removed from the account or its content." + }, + "account": { + "type": "boolean", + "description": "Notify about moderation actions against the account or its content, excluding labeling." + }, + "reports": { + "type": "boolean", + "description": "Notify about outcomes of reports filed by the account." } } }, @@ -31,7 +37,8 @@ } }, "encoding": "application/json" - } + }, + "description": "Update the authenticated account's moderation push notification preferences. Only provided categories are updated; omitted categories retain their values. At least one category must be provided. Returns all three preferences. These preferences do not hide in-app inbox activity." } }, "$type": "com.atproto.lexicon.schema", diff --git a/lexicons/tools/ozone/queue/defs.json b/lexicons/tools/ozone/queue/defs.json index c6930d927..9c81fd84d 100644 --- a/lexicons/tools/ozone/queue/defs.json +++ b/lexicons/tools/ozone/queue/defs.json @@ -112,7 +112,7 @@ }, "pendingCount": { "type": "integer", - "description": "Number of reports in 'open' status" + "description": "Number of unmuted reports currently not closed." }, "actionedCount": { "type": "integer", @@ -125,6 +125,27 @@ "avgHandlingTimeSec": { "type": "integer", "description": "Average time in seconds from report creation to close, for reports closed in this period." + }, + "closureTargetMetRate": { + "type": "integer", + "maximum": 100, + "minimum": 0, + "description": "Percent of reports meeting their closure target." + }, + "closureTargetMetCount": { + "type": "integer", + "minimum": 0, + "description": "Reports whose closure meets their closure target." + }, + "closureTargetMissedCount": { + "type": "integer", + "minimum": 0, + "description": "Reports whose closure exceeds their closure target." + }, + "closureTargetOverdueCount": { + "type": "integer", + "minimum": 0, + "description": "Unmuted pending reports past their closure target." } } }, diff --git a/lexicons/tools/ozone/report/defs.json b/lexicons/tools/ozone/report/defs.json index 318a9a754..4cba2d905 100644 --- a/lexicons/tools/ozone/report/defs.json +++ b/lexicons/tools/ozone/report/defs.json @@ -23,7 +23,7 @@ }, "pendingCount": { "type": "integer", - "description": "Number of reports currently not closed." + "description": "Number of unmuted reports currently not closed." }, "actionedCount": { "type": "integer", @@ -65,6 +65,17 @@ "type": "integer", "description": "Average resolution time in seconds from report creation to close." }, + "closureTargetMetRate": { + "type": "integer", + "maximum": 100, + "minimum": 0, + "description": "Percent of reports meeting their closure target." + }, + "closureTargetMetCount": { + "type": "integer", + "minimum": 0, + "description": "Reports whose closure meets their closure target." + }, "resolutionDurationSec": { "type": "integer", "description": "Sum of report creation-to-close seconds." @@ -72,6 +83,16 @@ "resolutionSampleCount": { "type": "integer", "description": "Number of closed-report samples in resolutionDurationSec." + }, + "closureTargetMissedCount": { + "type": "integer", + "minimum": 0, + "description": "Reports whose closure exceeds their closure target." + }, + "closureTargetOverdueCount": { + "type": "integer", + "minimum": 0, + "description": "Unmuted pending reports past their closure target." } }, "description": "Live statistics for reports for the current calendar day, filterable by queue, moderator, or report type." @@ -223,6 +244,16 @@ "default": false, "description": "Whether this report was emitted by automated tooling." }, + "priorityLevel": { + "type": "string", + "description": "Priority level assigned to the report." + }, + "priorityScore": { + "type": "integer", + "maximum": 100, + "minimum": 0, + "description": "Report priority score. Higher scores have higher priority." + }, "subjectStatus": { "ref": "tools.ozone.moderation.defs#subjectStatusView", "type": "ref", @@ -235,9 +266,24 @@ }, "description": "Array of moderation event IDs representing actions taken on this report, in append order (most recently linked event last)" }, + "priorityTargetMet": { + "type": "boolean", + "description": "Whether the current closure occurred within the report's snapshotted target." + }, + "resolutionTimeSec": { + "type": "integer", + "minimum": 0, + "description": "Time from report creation to its last closure." + }, "relatedReportCount": { "type": "integer", "description": "Number of other pending reports on the same subject" + }, + "priorityTargetMinutes": { + "type": "integer", + "maximum": 2147483647, + "minimum": 1, + "description": "Target resolution duration in minutes." } } }, @@ -372,7 +418,7 @@ }, "pendingCount": { "type": "integer", - "description": "Number of reports not closed at time of computation." + "description": "Number of unmuted reports not closed at the end of this UTC day, or at computation time for the current day." }, "actionedCount": { "type": "integer", @@ -414,6 +460,17 @@ "type": "integer", "description": "Average resolution time in seconds from report creation to close." }, + "closureTargetMetRate": { + "type": "integer", + "maximum": 100, + "minimum": 0, + "description": "Percent of reports meeting their closure target." + }, + "closureTargetMetCount": { + "type": "integer", + "minimum": 0, + "description": "Reports whose closure meets their closure target." + }, "resolutionDurationSec": { "type": "integer", "description": "Sum of report creation-to-close seconds for this day's samples." @@ -421,6 +478,16 @@ "resolutionSampleCount": { "type": "integer", "description": "Number of closed-report samples in resolutionDurationSec." + }, + "closureTargetMissedCount": { + "type": "integer", + "minimum": 0, + "description": "Reports whose closure exceeds their closure target." + }, + "closureTargetOverdueCount": { + "type": "integer", + "minimum": 0, + "description": "Unmuted pending reports past their closure target at the snapshot time." } }, "description": "A single daily snapshot of report statistics for a calendar date." diff --git a/src/state/queries/notifications/grouped/__tests__/hydrate.test.ts b/src/state/queries/notifications/grouped/__tests__/hydrate.test.ts index e5ae2ff1c..546d14408 100644 --- a/src/state/queries/notifications/grouped/__tests__/hydrate.test.ts +++ b/src/state/queries/notifications/grouped/__tests__/hydrate.test.ts @@ -773,60 +773,48 @@ describe('hydratePage', () => { ).toBeUndefined() }) - it('resolves the parent of a reply when the page came with it', () => { + it('resolves the parent the group names', () => { const subscribed = narrow( hydrateKind({ $type: `${NS}#subscribedPostGroup`, - items: [{actor: DANIELLE, post: DANIELLE_REPLY}], + items: [{actor: DANIELLE, post: DANIELLE_REPLY, parent: FUNGUS_POST}], }), 'subscribedPost', ) - expect(subscribed.items[0].parent).toEqual({ - type: 'post', - post: related(BASE, FUNGUS_POST), - }) + const [item] = subscribed.items + expect(item.parent?.type).toBe('post') // The original view, so shadows apply to it - expect( - subscribed.items[0].parent?.type === 'post' && - subscribed.items[0].parent.post, - ).toBe(related(BASE, FUNGUS_POST)) + expect(item.parent?.type === 'post' && item.parent.post).toBe( + related(BASE, FUNGUS_POST), + ) }) - it('has no parent for a post that is not a reply', () => { + it('has no parent when the group names none, whatever the post is', () => { const subscribed = narrow( hydrateKind({ $type: `${NS}#subscribedPostGroup`, - items: [{actor: DANIELLE, post: FUNGUS_POST}], + items: [{actor: DANIELLE, post: DANIELLE_REPLY}], }), 'subscribedPost', ) expect(subscribed.items[0]).not.toHaveProperty('parent') }) - it('has no parent when the page did not come with it, rather than treating it as deleted', () => { - const page = hydratePage( - { - ...BASE, - relatedViews: BASE.relatedViews?.filter( - view => (view as {uri?: string}).uri !== FUNGUS_POST, - ), - groups: [ - { - id: 'group-0', - isRead: false, - indexedAt: '2026-10-08T11:00:00.000Z', - count: 1, - kind: { - $type: `${NS}#subscribedPostGroup`, - items: [{actor: DANIELLE, post: DANIELLE_REPLY}], - }, - }, + it('marks a named parent that can’t be shown as blocked or not found', () => { + const subscribed = narrow( + hydrateKind({ + $type: `${NS}#subscribedPostGroup`, + items: [ + {actor: DANIELLE, post: DANIELLE_REPLY, parent: BLOCKED_POST}, + {actor: DANIELLE, post: FUNGUS_POST, parent: MISSING_POST}, ], - }, - {viewerDid: VIEWER_DID}, + }), + 'subscribedPost', ) - const subscribed = narrow(page.notifications[0], 'subscribedPost') - expect(subscribed.items[0]).not.toHaveProperty('parent') + expect(subscribed.items.map(item => item.parent)).toEqual([ + {type: 'blocked'}, + {type: 'notFound'}, + ]) }) }) diff --git a/src/state/queries/notifications/grouped/hydrate.ts b/src/state/queries/notifications/grouped/hydrate.ts index 58f8135c9..c1ee11b91 100644 --- a/src/state/queries/notifications/grouped/hydrate.ts +++ b/src/state/queries/notifications/grouped/hydrate.ts @@ -203,8 +203,11 @@ function hydrateGroup( const actor = resolveActor(item.actor, ctx) const post = resolvePost(item.post, ctx) if (!actor || !post) return [] - const parent = resolveSubscribedPostParent(post, ctx) - return [parent ? {actor, post, parent} : {actor, post}] + return [ + item.parent + ? {actor, post, parent: resolveParent(item.parent, ctx)} + : {actor, post}, + ] }), ) if (!items) return @@ -386,22 +389,6 @@ function resolveParent(uri: string, ctx: Context): ParentPost { return ctx.posts.get(uri) ?? {type: 'notFound'} } -/** - * The parent of a subscribed post that replies to another post, if the page - * came with it. Unlike a reply notification's, a subscribed post's parent isn't - * named in the group, so a missing view means it wasn't sent, not that it's - * gone. - */ -function resolveSubscribedPostParent( - post: PostView, - ctx: Context, -): ParentPost | undefined { - const parentUri = bsky.isType(app.bsky.feed.post, post.record) - ? post.record.reply?.parent.uri - : undefined - return parentUri ? ctx.posts.get(parentUri) : undefined -} - function nonEmpty(items: T[]): NonEmptyArray | undefined { return isNonEmpty(items) ? items : undefined } diff --git a/src/state/queries/notifications/grouped/types.ts b/src/state/queries/notifications/grouped/types.ts index 5f5c8af51..8960f3fa3 100644 --- a/src/state/queries/notifications/grouped/types.ts +++ b/src/state/queries/notifications/grouped/types.ts @@ -127,8 +127,7 @@ export type NotificationView = actor: ProfileView post: PostView /** - * Set when the post replies to another and the page came with that - * post's view. + * Set when the post replies to another. */ parent?: ParentPost }> -- knotmirror 0.0.1