@atproto/bsky 0.0.280 → 0.0.282
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/dist/api/app/bsky/bookmark/getBookmarks.js +1 -1
- package/dist/api/app/bsky/bookmark/getBookmarks.js.map +1 -1
- package/dist/api/app/bsky/contact/getMatches.js +1 -1
- package/dist/api/app/bsky/contact/getMatches.js.map +1 -1
- package/dist/api/app/bsky/feed/getQuotes.js +1 -0
- package/dist/api/app/bsky/feed/getQuotes.js.map +1 -1
- package/dist/api/app/bsky/graph/getBlocks.js +1 -1
- package/dist/api/app/bsky/graph/getBlocks.js.map +1 -1
- package/dist/api/app/bsky/graph/getFollowers.js +1 -1
- package/dist/api/app/bsky/graph/getFollowers.js.map +1 -1
- package/dist/api/app/bsky/graph/getFollows.js +1 -1
- package/dist/api/app/bsky/graph/getFollows.js.map +1 -1
- package/dist/api/app/bsky/graph/getKnownFollowers.d.ts.map +1 -1
- package/dist/api/app/bsky/graph/getKnownFollowers.js +12 -7
- package/dist/api/app/bsky/graph/getKnownFollowers.js.map +1 -1
- package/dist/api/app/bsky/graph/getList.js +1 -1
- package/dist/api/app/bsky/graph/getList.js.map +1 -1
- package/dist/api/app/bsky/graph/getListBlocks.js +1 -1
- package/dist/api/app/bsky/graph/getListBlocks.js.map +1 -1
- package/dist/api/app/bsky/graph/getListMutes.js +1 -1
- package/dist/api/app/bsky/graph/getListMutes.js.map +1 -1
- package/dist/api/app/bsky/graph/getMutes.js +1 -1
- package/dist/api/app/bsky/graph/getMutes.js.map +1 -1
- package/dist/api/app/bsky/graph/getStarterPacksWithMembership.js +1 -1
- package/dist/api/app/bsky/graph/getStarterPacksWithMembership.js.map +1 -1
- package/dist/api/app/bsky/notification/getPreferences.d.ts +1 -1
- package/dist/api/app/bsky/notification/getPreferences.d.ts.map +1 -1
- package/dist/api/app/bsky/notification/getPreferences.js +2 -18
- package/dist/api/app/bsky/notification/getPreferences.js.map +1 -1
- package/dist/api/app/bsky/notification/listActivitySubscriptions.js +1 -1
- package/dist/api/app/bsky/notification/listActivitySubscriptions.js.map +1 -1
- package/dist/api/app/bsky/notification/listNotifications.d.ts.map +1 -1
- package/dist/api/app/bsky/notification/listNotifications.js +3 -18
- package/dist/api/app/bsky/notification/listNotifications.js.map +1 -1
- package/dist/api/app/bsky/notification/putPreferences.d.ts.map +1 -1
- package/dist/api/app/bsky/notification/putPreferences.js +14 -2
- package/dist/api/app/bsky/notification/putPreferences.js.map +1 -1
- package/dist/api/app/bsky/notification/putPreferencesV2.d.ts +1 -1
- package/dist/api/app/bsky/notification/putPreferencesV2.d.ts.map +1 -1
- package/dist/api/app/bsky/notification/putPreferencesV2.js +3 -15
- package/dist/api/app/bsky/notification/putPreferencesV2.js.map +1 -1
- package/dist/api/app/bsky/notification/util.d.ts +5 -0
- package/dist/api/app/bsky/notification/util.d.ts.map +1 -1
- package/dist/api/app/bsky/notification/util.js +39 -0
- package/dist/api/app/bsky/notification/util.js.map +1 -1
- package/dist/api/util.js +2 -2
- package/dist/api/util.js.map +1 -1
- package/dist/data-plane/server/bsync-subscription.d.ts +0 -3
- package/dist/data-plane/server/bsync-subscription.d.ts.map +1 -1
- package/dist/data-plane/server/bsync-subscription.js +1 -27
- package/dist/data-plane/server/bsync-subscription.js.map +1 -1
- package/dist/data-plane/server/db/migrations/20260918T214110000Z-remove-priority-notifs.d.ts +4 -0
- package/dist/data-plane/server/db/migrations/20260918T214110000Z-remove-priority-notifs.d.ts.map +1 -0
- package/dist/data-plane/server/db/migrations/20260918T214110000Z-remove-priority-notifs.js +13 -0
- package/dist/data-plane/server/db/migrations/20260918T214110000Z-remove-priority-notifs.js.map +1 -0
- package/dist/data-plane/server/db/migrations/index.d.ts +1 -0
- package/dist/data-plane/server/db/migrations/index.d.ts.map +1 -1
- package/dist/data-plane/server/db/migrations/index.js +1 -0
- package/dist/data-plane/server/db/migrations/index.js.map +1 -1
- package/dist/data-plane/server/db/tables/actor-state.d.ts +0 -1
- package/dist/data-plane/server/db/tables/actor-state.d.ts.map +1 -1
- package/dist/data-plane/server/db/tables/actor-state.js.map +1 -1
- package/dist/data-plane/server/routes/follows.d.ts.map +1 -1
- package/dist/data-plane/server/routes/follows.js +57 -22
- package/dist/data-plane/server/routes/follows.js.map +1 -1
- package/dist/data-plane/server/routes/notifs.d.ts.map +1 -1
- package/dist/data-plane/server/routes/notifs.js +2 -12
- package/dist/data-plane/server/routes/notifs.js.map +1 -1
- package/dist/data-plane/server/routes/profile.js +0 -3
- package/dist/data-plane/server/routes/profile.js.map +1 -1
- package/dist/hydration/actor.d.ts +0 -1
- package/dist/hydration/actor.d.ts.map +1 -1
- package/dist/hydration/actor.js +8 -10
- package/dist/hydration/actor.js.map +1 -1
- package/dist/lexicons/app/bsky/authFullApp.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/authFullApp.defs.js +10 -0
- package/dist/lexicons/app/bsky/authFullApp.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/feed/defs.defs.d.ts +8 -0
- package/dist/lexicons/app/bsky/feed/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/defs.defs.js +2 -0
- package/dist/lexicons/app/bsky/feed/defs.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/feed/getQuotes.defs.d.ts +6 -0
- package/dist/lexicons/app/bsky/feed/getQuotes.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/getQuotes.defs.js +2 -0
- package/dist/lexicons/app/bsky/feed/getQuotes.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.d.ts +3 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.d.ts +65 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.js +49 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.js.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.js +6 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.js.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/defs.d.ts +2 -0
- package/dist/lexicons/tools/ozone/inbox/defs.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/defs.defs.d.ts +89 -0
- package/dist/lexicons/tools/ozone/inbox/defs.defs.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/defs.defs.js +73 -0
- package/dist/lexicons/tools/ozone/inbox/defs.defs.js.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/defs.js +5 -0
- package/dist/lexicons/tools/ozone/inbox/defs.js.map +1 -0
- package/dist/lexicons/tools/ozone/inbox.d.ts +3 -0
- package/dist/lexicons/tools/ozone/inbox.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/inbox.js +6 -0
- package/dist/lexicons/tools/ozone/inbox.js.map +1 -0
- package/dist/lexicons/tools/ozone/queue/createQueue.defs.d.ts +2 -0
- package/dist/lexicons/tools/ozone/queue/createQueue.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/queue/createQueue.defs.js +2 -0
- package/dist/lexicons/tools/ozone/queue/createQueue.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/queue/defs.defs.d.ts +4 -0
- package/dist/lexicons/tools/ozone/queue/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/queue/defs.defs.js +2 -0
- package/dist/lexicons/tools/ozone/queue/defs.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/queue/updateQueue.defs.d.ts +3 -1
- package/dist/lexicons/tools/ozone/queue/updateQueue.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/queue/updateQueue.defs.js +3 -0
- package/dist/lexicons/tools/ozone/queue/updateQueue.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/report/defs.defs.d.ts +89 -9
- package/dist/lexicons/tools/ozone/report/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/report/defs.defs.js +20 -0
- package/dist/lexicons/tools/ozone/report/defs.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/report/getLiveStats.defs.d.ts +1 -1
- package/dist/lexicons/tools/ozone/report/getLiveStats.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/report/getLiveStats.defs.js +1 -1
- package/dist/lexicons/tools/ozone/report/getLiveStats.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/report/refreshStats.defs.d.ts +1 -1
- package/dist/lexicons/tools/ozone/report/refreshStats.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/report/refreshStats.defs.js +1 -1
- package/dist/lexicons/tools/ozone/report/refreshStats.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone.d.ts +1 -0
- package/dist/lexicons/tools/ozone.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone.js +1 -0
- package/dist/lexicons/tools/ozone.js.map +1 -1
- package/dist/proto/bsky_connect.d.ts +10 -1
- package/dist/proto/bsky_connect.d.ts.map +1 -1
- package/dist/proto/bsky_connect.js +10 -1
- package/dist/proto/bsky_connect.js.map +1 -1
- package/dist/proto/bsky_pb.d.ts +83 -12
- package/dist/proto/bsky_pb.d.ts.map +1 -1
- package/dist/proto/bsky_pb.js +130 -15
- package/dist/proto/bsky_pb.js.map +1 -1
- package/dist/proto/bsync_connect.d.ts +1 -10
- package/dist/proto/bsync_connect.d.ts.map +1 -1
- package/dist/proto/bsync_connect.js +1 -10
- package/dist/proto/bsync_connect.js.map +1 -1
- package/dist/proto/bsync_pb.d.ts +0 -38
- package/dist/proto/bsync_pb.d.ts.map +1 -1
- package/dist/proto/bsync_pb.js +0 -57
- package/dist/proto/bsync_pb.js.map +1 -1
- package/dist/views/types.d.ts +1 -4
- package/dist/views/types.d.ts.map +1 -1
- package/dist/views/types.js.map +1 -1
- package/package.json +15 -16
|
@@ -1 +1 @@
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SAAS,EAAE,GAAG,QAAQ,CAAA;IAC9B,OAAO,GAAG,CAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AACnE,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CACnB,KAA0D,EAC1D,EAAE;IACF,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC1C,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAA;IACtC,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;IACF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;AAC1B,CAAC,CAAA","sourcesContent":["import { mapDefined } from '@atproto/common'\nimport type { DidString } from '@atproto/lex'\nimport type { Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport type {\n HydrateCtxWithViewer,\n Hydrator,\n} from '../../../../hydration/hydrator.js'\nimport { app } from '../../../../lexicons/index.js'\nimport {\n type HydrationFnInput,\n type PresentationFnInput,\n type SkeletonFnInput,\n createPipeline,\n noRules,\n} from '../../../../pipeline.js'\nimport type { Views } from '../../../../views/index.js'\nimport { clearlyBadCursor, fillPage, resHeaders } from '../../../util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const getMutes = createPipeline(skeleton, hydration, noRules, presentation)\n server.add(app.bsky.graph.getMutes, {\n auth: ctx.authVerifier.standard,\n handler: async ({ params, auth, req }) => {\n const viewer = auth.credentials.iss\n const labelers = ctx.reqLabelers(req)\n const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer })\n const result = await fillPage({\n cursor: params.cursor,\n limit: params.limit,\n fetch: ({ cursor, limit }) =>\n getMutes({ ...params, cursor, limit, hydrateCtx }, ctx),\n items: (r) => r.mutes,\n })\n return {\n encoding: 'application/json',\n body: result,\n headers: resHeaders({ labelers: hydrateCtx.labelers }),\n }\n },\n })\n}\n\nconst skeleton = async (\n input: SkeletonFnInput<Context, Params>,\n): Promise<SkeletonState> => {\n const { params, ctx } = input\n if (clearlyBadCursor(params.cursor)) {\n return { mutedDids: [] }\n }\n const res = await ctx.hydrator.dataplane.getMutes({\n actorDid: params.hydrateCtx.viewer,\n cursor: params.cursor,\n limit: params.limit,\n })\n\n // only fully muted accounts are enumerated: scoped mutes (only reposts /\n // only quoteposts) are filtered out.\n const mutedDids = res.mutes.length\n ? res.mutes\n .filter((mute) => !mute.onlyReposts && !mute.onlyQuoteposts)\n .map((mute) => mute.did)\n : res.dids\n return {\n mutedDids: mutedDids as DidString[],\n cursor: res.cursor,\n }\n}\n\nconst hydration = async (\n input: HydrationFnInput<Context, Params, SkeletonState>,\n) => {\n const { ctx, params, skeleton } = input\n const { mutedDids } = skeleton\n return ctx.hydrator.hydrateProfiles(mutedDids, params.hydrateCtx)\n}\n\nconst presentation = (\n input: PresentationFnInput<Context, Params, SkeletonState>,\n) => {\n const { ctx, hydration, skeleton } = input\n const { mutedDids, cursor } = skeleton\n const mutes = mapDefined(mutedDids, (did) => {\n return ctx.views.profile(did, hydration)\n })\n return { mutes, cursor }\n}\n\ntype Context = {\n hydrator: Hydrator\n views: Views\n}\n\ntype Params = app.bsky.graph.getMutes.$Params & {\n hydrateCtx: HydrateCtxWithViewer\n}\n\ntype SkeletonState = {\n mutedDids: DidString[]\n cursor?: string\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStarterPacksWithMembership.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/graph/getStarterPacksWithMembership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAA;AAEvE,OAAO,EAGL,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0BAA0B,EAAE,MAAM,EAAE,CAAA;AAC/C,CAAC,CAAA","sourcesContent":["import { mapDefined } from '@atproto/common'\nimport type { AtUriString, DidString } from '@atproto/syntax'\nimport { InvalidRequestError, type Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport {\n type HydrateCtxWithViewer,\n type Hydrator,\n mergeManyStates,\n} from '../../../../hydration/hydrator.js'\nimport { app } from '../../../../lexicons/index.js'\nimport {\n type HydrationFnInput,\n type PresentationFnInput,\n type SkeletonFnInput,\n createPipeline,\n noRules,\n} from '../../../../pipeline.js'\nimport type { Views } from '../../../../views/index.js'\nimport { clearlyBadCursor, fillPage, resHeaders } from '../../../util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const getStarterPacksWithMembership = createPipeline(\n skeleton,\n hydration,\n noRules,\n presentation,\n )\n server.add(app.bsky.graph.getStarterPacksWithMembership, {\n auth: ctx.authVerifier.standard,\n handler: async ({ params, auth, req }) => {\n const viewer = auth.credentials.iss\n const labelers = ctx.reqLabelers(req)\n const hydrateCtx = await ctx.hydrator.createContext({\n labelers,\n viewer,\n })\n const result = await fillPage({\n cursor: params.cursor,\n limit: params.limit,\n fetch: ({ cursor, limit }) =>\n getStarterPacksWithMembership(\n { ...params, cursor, limit, hydrateCtx },\n ctx,\n ),\n items: (r) => r.starterPacksWithMembership,\n })\n\n return {\n encoding: 'application/json',\n body: result,\n headers: resHeaders({ labelers: hydrateCtx.labelers }),\n }\n },\n })\n}\n\nconst skeleton = async (\n input: SkeletonFnInput<Context, Params>,\n): Promise<SkeletonState> => {\n const { ctx, params } = input\n const [actorDid] = await ctx.hydrator.actor.getDids([params.actor])\n if (!actorDid) throw new InvalidRequestError('Profile not found')\n\n if (clearlyBadCursor(params.cursor)) {\n return { actorDid, starterPackUris: [] }\n }\n\n const { uris: starterPackUris, cursor } =\n await ctx.hydrator.dataplane.getActorStarterPacks({\n actorDid: params.hydrateCtx.viewer,\n cursor: params.cursor,\n limit: params.limit,\n })\n\n return {\n actorDid,\n starterPackUris: starterPackUris as AtUriString[],\n cursor,\n }\n}\n\nconst hydration = async (\n input: HydrationFnInput<Context, Params, SkeletonState>,\n) => {\n const { ctx, params, skeleton } = input\n const { actorDid, starterPackUris } = skeleton\n const spHydrationState = await ctx.hydrator.hydrateStarterPacks(\n starterPackUris,\n params.hydrateCtx,\n )\n const listUris = mapDefined(\n starterPackUris,\n (uri) => spHydrationState.starterPacks?.get(uri)?.record.list,\n )\n const listMembershipHydrationState =\n await ctx.hydrator.hydrateListsMembership(\n listUris,\n actorDid,\n params.hydrateCtx,\n )\n return mergeManyStates(spHydrationState, listMembershipHydrationState)\n}\n\nconst presentation = (\n input: PresentationFnInput<Context, Params, SkeletonState>,\n): app.bsky.graph.getStarterPacksWithMembership.$OutputBody => {\n const { ctx, skeleton, hydration } = input\n const { actorDid, starterPackUris, cursor } = skeleton\n\n const starterPacksWithMembership = mapDefined(starterPackUris, (spUri) => {\n const listUri = hydration.starterPacks?.get(spUri)?.record.list\n const starterPack = ctx.views.starterPack(spUri, hydration)\n if (!listUri || !starterPack) return\n\n const listItemUri = hydration.listMemberships\n ?.get(listUri)\n ?.get(actorDid)?.actorListItemUri\n\n return {\n starterPack,\n listItem: listItemUri\n ? ctx.views.listItemView(listItemUri, actorDid, hydration)\n : undefined,\n }\n })\n return { starterPacksWithMembership, cursor }\n}\n\ntype Context = {\n hydrator: Hydrator\n views: Views\n}\n\ntype Params = app.bsky.graph.getStarterPacksWithMembership.$Params & {\n hydrateCtx: HydrateCtxWithViewer\n}\n\ntype SkeletonState = {\n actorDid: DidString\n starterPackUris: AtUriString[]\n cursor?: string\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Server } from '@atproto/xrpc-server';
|
|
2
2
|
import type { AppContext } from '../../../../context.js';
|
|
3
3
|
export default function (server: Server, ctx: AppContext): void;
|
|
4
4
|
//# sourceMappingURL=getPreferences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPreferences.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/getPreferences.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPreferences.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/getPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAcvD"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import { UpstreamFailureError } from '@atproto/xrpc-server';
|
|
3
1
|
import { app } from '../../../../lexicons/index.js';
|
|
4
|
-
import {
|
|
2
|
+
import { getNotificationPreferences } from './util.js';
|
|
5
3
|
export default function (server, ctx) {
|
|
6
4
|
server.add(app.bsky.notification.getPreferences, {
|
|
7
5
|
auth: ctx.authVerifier.standard,
|
|
8
6
|
handler: async ({ auth }) => {
|
|
9
7
|
const actorDid = auth.credentials.iss;
|
|
10
|
-
const preferences = await
|
|
8
|
+
const preferences = await getNotificationPreferences(ctx, actorDid);
|
|
11
9
|
return {
|
|
12
10
|
encoding: 'application/json',
|
|
13
11
|
body: {
|
|
@@ -17,18 +15,4 @@ export default function (server, ctx) {
|
|
|
17
15
|
},
|
|
18
16
|
});
|
|
19
17
|
}
|
|
20
|
-
const computePreferences = async (ctx, actorDid) => {
|
|
21
|
-
let res;
|
|
22
|
-
try {
|
|
23
|
-
res = await ctx.dataplane.getNotificationPreferences({
|
|
24
|
-
dids: [actorDid],
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
throw new UpstreamFailureError('cannot get current notification preferences', 'NotificationPreferencesFailed', { cause: err });
|
|
29
|
-
}
|
|
30
|
-
assert(res.preferences.length === 1, `expected exactly one preferences entry, got ${res.preferences.length}`);
|
|
31
|
-
const currentPreferences = protobufToLex(res.preferences[0]);
|
|
32
|
-
return currentPreferences;
|
|
33
|
-
};
|
|
34
18
|
//# sourceMappingURL=getPreferences.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPreferences.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/getPreferences.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPreferences.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/getPreferences.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AAEtD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE;QAC/C,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,QAAQ;QAC/B,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAA;YACrC,MAAM,WAAW,GAAG,MAAM,0BAA0B,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;YACnE,OAAO;gBACL,QAAQ,EAAE,kBAAkB;gBAC5B,IAAI,EAAE;oBACJ,WAAW;iBACZ;aACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import type { Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport { app } from '../../../../lexicons/index.js'\nimport { getNotificationPreferences } from './util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(app.bsky.notification.getPreferences, {\n auth: ctx.authVerifier.standard,\n handler: async ({ auth }) => {\n const actorDid = auth.credentials.iss\n const preferences = await getNotificationPreferences(ctx, actorDid)\n return {\n encoding: 'application/json',\n body: {\n preferences,\n },\n }\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listActivitySubscriptions.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/listActivitySubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAQ5C,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAKL,cAAc,GACf,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEzE,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,yBAAyB,GAAG,cAAc,CAC9C,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,YAAY,CACb,CAAA;IACD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,yBAAyB,EAAE;QAC1D,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,QAAQ;QAC/B,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE;YACvC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAA;YACnC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;YACrC,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC;gBAClD,QAAQ;gBACR,MAAM;aACP,CAAC,CAAA;YAEF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC;gBAC5B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAC3B,yBAAyB,CACvB,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,EACxC,GAAG,CACJ;gBACH,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa;aAC9B,CAAC,CAAA;YAEF,OAAO;gBACL,QAAQ,EAAE,kBAAkB;gBAC5B,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,UAAU,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC;aACvD,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,QAAQ,GAAG,KAAK,EACpB,KAAuC,EACf,EAAE;IAC1B,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAA;IAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAA;IACzC,IAAI,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;IAC/B,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GACpB,MAAM,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,2BAA2B,CAAC;QACvD,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM;QAClC,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC,CAAA;IACJ,OAAO;QACL,QAAQ;QACR,IAAI,EAAE,IAAmB;QACzB,MAAM
|
|
1
|
+
{"version":3,"file":"listActivitySubscriptions.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/listActivitySubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAQ5C,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAKL,cAAc,GACf,MAAM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GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,EAAE,SAAS,CAAC,CACtD,CAAA;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CACnB,KAA0D,EAC1D,EAAE;IACF,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC1C,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAA;IACjC,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE;QAC7C,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;IACF,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,CAAA;AAClC,CAAC,CAAA","sourcesContent":["import { mapDefined } from '@atproto/common'\nimport type { DidString } from '@atproto/syntax'\nimport type { Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport type {\n HydrateCtxWithViewer,\n Hydrator,\n} from '../../../../hydration/hydrator.js'\nimport { app } from '../../../../lexicons/index.js'\nimport {\n type HydrationFnInput,\n type PresentationFnInput,\n type RulesFnInput,\n type SkeletonFnInput,\n createPipeline,\n} from '../../../../pipeline.js'\nimport type { Views } from '../../../../views/index.js'\nimport { clearlyBadCursor, fillPage, resHeaders } from '../../../util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const listActivitySubscriptions = createPipeline(\n skeleton,\n hydration,\n noBlocks,\n presentation,\n )\n server.add(app.bsky.notification.listActivitySubscriptions, {\n auth: ctx.authVerifier.standard,\n handler: async ({ params, auth, req }) => {\n const viewer = auth.credentials.iss\n const labelers = ctx.reqLabelers(req)\n const hydrateCtx = await ctx.hydrator.createContext({\n labelers,\n viewer,\n })\n\n const result = await fillPage({\n cursor: params.cursor,\n limit: params.limit,\n fetch: ({ cursor, limit }) =>\n listActivitySubscriptions(\n { ...params, cursor, limit, hydrateCtx },\n ctx,\n ),\n items: (r) => r.subscriptions,\n })\n\n return {\n encoding: 'application/json',\n body: result,\n headers: resHeaders({ labelers: hydrateCtx.labelers }),\n }\n },\n })\n}\n\nconst skeleton = async (\n input: SkeletonFnInput<Context, Params>,\n): Promise<SkeletonState> => {\n const { params, ctx } = input\n const actorDid = params.hydrateCtx.viewer\n if (clearlyBadCursor(params.cursor)) {\n return { actorDid, dids: [] }\n }\n const { dids, cursor } =\n await ctx.hydrator.dataplane.getActivitySubscriptionDids({\n actorDid: params.hydrateCtx.viewer,\n limit: params.limit,\n cursor: params.cursor,\n })\n return {\n actorDid,\n dids: dids as DidString[],\n cursor,\n }\n}\n\nconst hydration = async (\n input: HydrationFnInput<Context, Params, SkeletonState>,\n) => {\n const { ctx, params, skeleton } = input\n const { dids } = skeleton\n const state = await ctx.hydrator.hydrateProfilesDetailed(\n dids,\n params.hydrateCtx,\n )\n return state\n}\n\nconst noBlocks = (input: RulesFnInput<Context, Params, SkeletonState>) => {\n const { skeleton, hydration, ctx } = input\n skeleton.dids = skeleton.dids.filter(\n (did) => !ctx.views.viewerBlockExists(did, hydration),\n )\n return skeleton\n}\n\nconst presentation = (\n input: PresentationFnInput<Context, Params, SkeletonState>,\n) => {\n const { ctx, hydration, skeleton } = input\n const { dids, cursor } = skeleton\n const subscriptions = mapDefined(dids, (did) => {\n return ctx.views.profile(did, hydration)\n })\n return { subscriptions, cursor }\n}\n\ntype Context = {\n hydrator: Hydrator\n views: Views\n}\n\ntype Params = app.bsky.notification.listActivitySubscriptions.$Params & {\n hydrateCtx: HydrateCtxWithViewer\n}\n\ntype SkeletonState = {\n actorDid: DidString\n dids: DidString[]\n cursor?: string\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listNotifications.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/listNotifications.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAEvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAmBxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"listNotifications.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/listNotifications.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAEvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAmBxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAuCvD;AAwBD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,cACX,MAAM,GAAG,SAAS,WACpB,MAAM,KACd,MAMF,CAAA"}
|
|
@@ -16,10 +16,6 @@ export default function (server, ctx) {
|
|
|
16
16
|
const viewer = auth.credentials.iss;
|
|
17
17
|
const labelers = ctx.reqLabelers(req);
|
|
18
18
|
const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer });
|
|
19
|
-
// @NOTE the viewer's priority setting and last-seen time don't change
|
|
20
|
-
// across the pages that fillPage() may fetch, so they're read once here
|
|
21
|
-
// rather than on every page.
|
|
22
|
-
const priority = params.priority ?? (await getPriority(ctx, viewer));
|
|
23
19
|
const lastSeenRes = await ctx.hydrator.dataplane.getNotificationSeen({
|
|
24
20
|
actorDid: viewer,
|
|
25
21
|
});
|
|
@@ -27,7 +23,7 @@ export default function (server, ctx) {
|
|
|
27
23
|
const result = await fillPage({
|
|
28
24
|
cursor: params.cursor,
|
|
29
25
|
limit: params.limit,
|
|
30
|
-
fetch: ({ cursor, limit }) => listNotifications({ ...params, cursor, limit, hydrateCtx,
|
|
26
|
+
fetch: ({ cursor, limit }) => listNotifications({ ...params, cursor, limit, hydrateCtx, lastSeen }, ctx),
|
|
31
27
|
items: (r) => r.notifications,
|
|
32
28
|
});
|
|
33
29
|
return {
|
|
@@ -39,10 +35,9 @@ export default function (server, ctx) {
|
|
|
39
35
|
});
|
|
40
36
|
}
|
|
41
37
|
const paginateNotifications = async (opts) => {
|
|
42
|
-
const { ctx,
|
|
38
|
+
const { ctx, reasons, limit, viewer } = opts;
|
|
43
39
|
const res = await ctx.hydrator.dataplane.getNotifications({
|
|
44
40
|
actorDid: viewer,
|
|
45
|
-
priority,
|
|
46
41
|
cursor: opts.cursor,
|
|
47
42
|
limit,
|
|
48
43
|
});
|
|
@@ -73,10 +68,8 @@ const skeleton = async (input) => {
|
|
|
73
68
|
const originalCursor = params.cursor;
|
|
74
69
|
const delayedCursor = delayCursor(originalCursor, ctx.cfg.notificationsDelayMs);
|
|
75
70
|
const viewer = params.hydrateCtx.viewer;
|
|
76
|
-
const { priority } = params;
|
|
77
71
|
const res = await paginateNotifications({
|
|
78
72
|
ctx,
|
|
79
|
-
priority,
|
|
80
73
|
reasons: params.reasons,
|
|
81
74
|
cursor: delayedCursor,
|
|
82
75
|
limit: params.limit,
|
|
@@ -90,8 +83,7 @@ const skeleton = async (input) => {
|
|
|
90
83
|
}
|
|
91
84
|
return {
|
|
92
85
|
notifs: res.notifications,
|
|
93
|
-
cursor: res.cursor
|
|
94
|
-
priority,
|
|
86
|
+
cursor: res.cursor,
|
|
95
87
|
lastSeenNotifs: lastSeenDate
|
|
96
88
|
? lastSeenDate.toISOString()
|
|
97
89
|
: undefined,
|
|
@@ -167,14 +159,7 @@ const presentation = (input) => {
|
|
|
167
159
|
return {
|
|
168
160
|
notifications,
|
|
169
161
|
cursor,
|
|
170
|
-
priority: skeleton.priority,
|
|
171
162
|
seenAt: skeleton.lastSeenNotifs,
|
|
172
163
|
};
|
|
173
164
|
};
|
|
174
|
-
const getPriority = async (ctx, did) => {
|
|
175
|
-
const actors = await ctx.hydrator.actor.getActors([did], {
|
|
176
|
-
skipCacheForDids: [did],
|
|
177
|
-
});
|
|
178
|
-
return !!actors.get(did)?.priorityNotifications;
|
|
179
|
-
};
|
|
180
165
|
//# sourceMappingURL=listNotifications.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listNotifications.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/listNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAA;AAOvE,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAKL,cAAc,GACf,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEvD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,iBAAiB,GAAG,cAAc,CACtC,QAAQ,EACR,SAAS,EACT,8BAA8B,EAC9B,YAAY,CACb,CAAA;IACD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE;QAClD,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,QAAQ;QAC/B,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE;YACvC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClB,MAAM,IAAI,mBAAmB,CAAC,qCAAqC,CAAC,CAAA;YACtE,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAA;YACnC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;YACrC,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE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E,QAAQ,CAAC,QAAQ;QAC3B,MAAM,EAAE,QAAQ,CAAC,cAAc;KAChC,CAAA;AACH,CAAC,CAAA;AAwBD,MAAM,WAAW,GAAG,KAAK,EAAE,GAAY,EAAE,GAAc,EAAE,EAAE;IACzD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,EAAE;QACvD,gBAAgB,EAAE,CAAC,GAAG,CAAC;KACxB,CAAC,CAAA;IACF,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,qBAAqB,CAAA;AACjD,CAAC,CAAA","sourcesContent":["import { mapDefined } from '@atproto/common'\nimport type { AtUriString, DatetimeString, DidString } from '@atproto/syntax'\nimport { InvalidRequestError, type Server } from '@atproto/xrpc-server'\nimport type { ServerConfig } from '../../../../config.js'\nimport type { AppContext } from '../../../../context.js'\nimport type {\n HydrateCtxWithViewer,\n Hydrator,\n} from '../../../../hydration/hydrator.js'\nimport { app } from '../../../../lexicons/index.js'\nimport {\n type HydrationFnInput,\n type PresentationFnInput,\n type RulesFnInput,\n type SkeletonFnInput,\n createPipeline,\n} from '../../../../pipeline.js'\nimport type { Notification } from '../../../../proto/bsky_pb.js'\nimport { uriToDid as didFromUri } from '../../../../util/uris.js'\nimport type { Views } from '../../../../views/index.js'\nimport { isPostRecordType } from '../../../../views/types.js'\nimport { fillPage, resHeaders } from '../../../util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const listNotifications = createPipeline(\n skeleton,\n hydration,\n noBlockOrMutesOrNeedsFiltering,\n presentation,\n )\n server.add(app.bsky.notification.listNotifications, {\n auth: ctx.authVerifier.standard,\n handler: async ({ params, auth, req }) => {\n if (params.seenAt) {\n throw new InvalidRequestError('The seenAt parameter is unsupported')\n }\n const viewer = auth.credentials.iss\n const labelers = ctx.reqLabelers(req)\n const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer })\n\n // @NOTE the viewer's priority setting and last-seen time don't change\n // across the pages that fillPage() may fetch, so they're read once here\n // rather than on every page.\n const priority = params.priority ?? (await getPriority(ctx, viewer))\n const lastSeenRes = await ctx.hydrator.dataplane.getNotificationSeen({\n actorDid: viewer,\n })\n const lastSeen = lastSeenRes.timestamp?.toDate()\n\n const result = await fillPage({\n cursor: params.cursor,\n limit: params.limit,\n fetch: ({ cursor, limit }) =>\n listNotifications(\n { ...params, cursor, limit, hydrateCtx, priority, lastSeen },\n ctx,\n ),\n items: (r) => r.notifications,\n })\n return {\n encoding: 'application/json',\n body: result,\n headers: resHeaders({ labelers: hydrateCtx.labelers }),\n }\n },\n })\n}\n\nconst paginateNotifications = async (opts: {\n ctx: Context\n priority: boolean\n reasons?: string[]\n cursor?: string\n limit: number\n viewer: string\n}) => {\n const { ctx, priority, reasons, limit, viewer } = opts\n\n const res = await ctx.hydrator.dataplane.getNotifications({\n actorDid: viewer,\n priority,\n cursor: opts.cursor,\n limit,\n })\n return {\n notifications: reasons\n ? res.notifications.filter((notif) => reasons.includes(notif.reason))\n : res.notifications,\n cursor: res.cursor,\n }\n}\n\n/**\n * Applies a configurable delay to the datetime string of a cursor,\n * effectively allowing for a delay on listing the notifications.\n * This is useful to allow time for services to process notifications\n * before they are listed to the user.\n */\nexport const delayCursor = (\n cursorStr: string | undefined,\n delayMs: number,\n): string => {\n const nowMinusDelay = Date.now() - delayMs\n if (cursorStr === undefined) return new Date(nowMinusDelay).toISOString()\n const cursor = new Date(cursorStr).getTime()\n if (isNaN(cursor)) return cursorStr\n return new Date(Math.min(cursor, nowMinusDelay)).toISOString()\n}\n\nconst skeleton = async (\n input: SkeletonFnInput<Context, Params>,\n): Promise<SkeletonState> => {\n const { params, ctx } = input\n const originalCursor = params.cursor\n const delayedCursor = delayCursor(\n originalCursor,\n ctx.cfg.notificationsDelayMs,\n )\n const viewer = params.hydrateCtx.viewer\n const { priority } = params\n const res = await paginateNotifications({\n ctx,\n priority,\n reasons: params.reasons,\n cursor: delayedCursor,\n limit: params.limit,\n viewer,\n })\n // @NOTE for the first page of results if there's no last-seen time, consider top notification unread\n // rather than all notifications. bit of a hack to be more graceful when seen times are out of sync.\n let lastSeenDate = params.lastSeen\n if (!lastSeenDate && !originalCursor) {\n lastSeenDate = res.notifications.at(0)?.timestamp?.toDate()\n }\n return {\n notifs: res.notifications,\n cursor: res.cursor || undefined,\n priority,\n lastSeenNotifs: lastSeenDate\n ? (lastSeenDate.toISOString() as DatetimeString)\n : undefined,\n }\n}\n\nconst hydration = async (\n input: HydrationFnInput<Context, Params, SkeletonState>,\n) => {\n const { skeleton, params, ctx } = input\n return ctx.hydrator.hydrateNotifications(skeleton.notifs, params.hydrateCtx)\n}\n\nconst noBlockOrMutesOrNeedsFiltering = (\n input: RulesFnInput<Context, Params, SkeletonState>,\n) => {\n const { skeleton, hydration, ctx, params } = input\n skeleton.notifs = skeleton.notifs.filter((item) => {\n const uri = item.uri as AtUriString\n const did = didFromUri(uri)\n if (\n ctx.views.viewerBlockExists(did, hydration) ||\n ctx.views.viewerMuteExists(did, hydration)\n ) {\n return false\n }\n // Filter out hidden replies only if the viewer owns\n // the threadgate and they hid the reply.\n if (item.reason === 'reply') {\n const post = hydration.posts?.get(uri)\n if (post) {\n const rootPostUri = isPostRecordType(post.record)\n ? post.record.reply?.root.uri\n : undefined\n const isRootPostByViewer =\n rootPostUri && didFromUri(rootPostUri) === params.hydrateCtx?.viewer\n const isHiddenByThreadgate = isRootPostByViewer\n ? ctx.views.replyIsHiddenByThreadgate(uri, rootPostUri, hydration)\n : false\n if (isHiddenByThreadgate) {\n return false\n }\n }\n }\n // Filter out notifications from users that have thread hide tags and are from people they\n // are not following\n if (\n item.reason === 'reply' ||\n item.reason === 'quote' ||\n item.reason === 'mention'\n ) {\n const post = hydration.posts?.get(uri)\n if (post) {\n for (const [tag] of post.tags.entries()) {\n if (ctx.cfg.threadTagsHide.has(tag)) {\n if (!hydration.profileViewers?.get(did)?.following) {\n return false\n } else {\n break\n }\n }\n }\n }\n }\n // Filter out notifications from users that need review unless moots\n if (\n item.reason === 'reply' ||\n item.reason === 'quote' ||\n item.reason === 'mention' ||\n item.reason === 'like' ||\n item.reason === 'follow'\n ) {\n if (!ctx.views.viewerSeesNeedsReview({ did, uri }, hydration)) {\n return false\n }\n }\n return true\n })\n return skeleton\n}\n\nconst presentation = (\n input: PresentationFnInput<Context, Params, SkeletonState>,\n): app.bsky.notification.listNotifications.$OutputBody => {\n const { skeleton, hydration, ctx } = input\n const { notifs, lastSeenNotifs, cursor } = skeleton\n const notifications = mapDefined(notifs, (notif) =>\n ctx.views.notification(notif, lastSeenNotifs, hydration),\n )\n return {\n notifications,\n cursor,\n priority: skeleton.priority,\n seenAt: skeleton.lastSeenNotifs,\n }\n}\n\ntype Context = {\n hydrator: Hydrator\n views: Views\n cfg: ServerConfig\n}\n\ntype Params = Omit<\n app.bsky.notification.listNotifications.$Params,\n 'priority'\n> & {\n hydrateCtx: HydrateCtxWithViewer\n priority: boolean\n lastSeen?: Date\n}\n\ntype SkeletonState = {\n notifs: Notification[]\n priority: boolean\n lastSeenNotifs?: DatetimeString\n cursor?: string\n}\n\nconst getPriority = async (ctx: Context, did: DidString) => {\n const actors = await ctx.hydrator.actor.getActors([did], {\n skipCacheForDids: [did],\n })\n return !!actors.get(did)?.priorityNotifications\n}\n"]}
|
|
1
|
+
{"version":3,"file":"listNotifications.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/listNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAA;AAOvE,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAKL,cAAc,GACf,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BA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AC,CAAA;IACF,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CACnB,KAA0D,EACL,EAAE;IACvD,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,KAAK,CAAA;IAC1C,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAA;IACnD,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CACjD,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,CAAC,CACzD,CAAA;IACD,OAAO;QACL,aAAa;QACb,MAAM;QACN,MAAM,EAAE,QAAQ,CAAC,cAAc;KAChC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { mapDefined } from '@atproto/common'\nimport type { AtUriString, DatetimeString } from '@atproto/syntax'\nimport { InvalidRequestError, type Server } from '@atproto/xrpc-server'\nimport type { ServerConfig } from '../../../../config.js'\nimport type { AppContext } from '../../../../context.js'\nimport type {\n HydrateCtxWithViewer,\n Hydrator,\n} from '../../../../hydration/hydrator.js'\nimport { app } from '../../../../lexicons/index.js'\nimport {\n type HydrationFnInput,\n type PresentationFnInput,\n type RulesFnInput,\n type SkeletonFnInput,\n createPipeline,\n} from '../../../../pipeline.js'\nimport type { Notification } from '../../../../proto/bsky_pb.js'\nimport { uriToDid as didFromUri } from '../../../../util/uris.js'\nimport type { Views } from '../../../../views/index.js'\nimport { isPostRecordType } from '../../../../views/types.js'\nimport { fillPage, resHeaders } from '../../../util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const listNotifications = createPipeline(\n skeleton,\n hydration,\n noBlockOrMutesOrNeedsFiltering,\n presentation,\n )\n server.add(app.bsky.notification.listNotifications, {\n auth: ctx.authVerifier.standard,\n handler: async ({ params, auth, req }) => {\n if (params.seenAt) {\n throw new InvalidRequestError('The seenAt parameter is unsupported')\n }\n const viewer = auth.credentials.iss\n const labelers = ctx.reqLabelers(req)\n const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer })\n\n const lastSeenRes = await ctx.hydrator.dataplane.getNotificationSeen({\n actorDid: viewer,\n })\n const lastSeen = lastSeenRes.timestamp?.toDate()\n\n const result = await fillPage({\n cursor: params.cursor,\n limit: params.limit,\n fetch: ({ cursor, limit }) =>\n listNotifications(\n { ...params, cursor, limit, hydrateCtx, lastSeen },\n ctx,\n ),\n items: (r) => r.notifications,\n })\n return {\n encoding: 'application/json',\n body: result,\n headers: resHeaders({ labelers: hydrateCtx.labelers }),\n }\n },\n })\n}\n\nconst paginateNotifications = async (opts: {\n ctx: Context\n reasons?: string[]\n cursor?: string\n limit: number\n viewer: string\n}) => {\n const { ctx, reasons, limit, viewer } = opts\n\n const res = await ctx.hydrator.dataplane.getNotifications({\n actorDid: viewer,\n cursor: opts.cursor,\n limit,\n })\n return {\n notifications: reasons\n ? res.notifications.filter((notif) => reasons.includes(notif.reason))\n : res.notifications,\n cursor: res.cursor,\n }\n}\n\n/**\n * Applies a configurable delay to the datetime string of a cursor,\n * effectively allowing for a delay on listing the notifications.\n * This is useful to allow time for services to process notifications\n * before they are listed to the user.\n */\nexport const delayCursor = (\n cursorStr: string | undefined,\n delayMs: number,\n): string => {\n const nowMinusDelay = Date.now() - delayMs\n if (cursorStr === undefined) return new Date(nowMinusDelay).toISOString()\n const cursor = new Date(cursorStr).getTime()\n if (isNaN(cursor)) return cursorStr\n return new Date(Math.min(cursor, nowMinusDelay)).toISOString()\n}\n\nconst skeleton = async (\n input: SkeletonFnInput<Context, Params>,\n): Promise<SkeletonState> => {\n const { params, ctx } = input\n const originalCursor = params.cursor\n const delayedCursor = delayCursor(\n originalCursor,\n ctx.cfg.notificationsDelayMs,\n )\n const viewer = params.hydrateCtx.viewer\n const res = await paginateNotifications({\n ctx,\n reasons: params.reasons,\n cursor: delayedCursor,\n limit: params.limit,\n viewer,\n })\n // @NOTE for the first page of results if there's no last-seen time, consider top notification unread\n // rather than all notifications. bit of a hack to be more graceful when seen times are out of sync.\n let lastSeenDate = params.lastSeen\n if (!lastSeenDate && !originalCursor) {\n lastSeenDate = res.notifications.at(0)?.timestamp?.toDate()\n }\n return {\n notifs: res.notifications,\n cursor: res.cursor,\n lastSeenNotifs: lastSeenDate\n ? (lastSeenDate.toISOString() as DatetimeString)\n : undefined,\n }\n}\n\nconst hydration = async (\n input: HydrationFnInput<Context, Params, SkeletonState>,\n) => {\n const { skeleton, params, ctx } = input\n return ctx.hydrator.hydrateNotifications(skeleton.notifs, params.hydrateCtx)\n}\n\nconst noBlockOrMutesOrNeedsFiltering = (\n input: RulesFnInput<Context, Params, SkeletonState>,\n) => {\n const { skeleton, hydration, ctx, params } = input\n skeleton.notifs = skeleton.notifs.filter((item) => {\n const uri = item.uri as AtUriString\n const did = didFromUri(uri)\n if (\n ctx.views.viewerBlockExists(did, hydration) ||\n ctx.views.viewerMuteExists(did, hydration)\n ) {\n return false\n }\n // Filter out hidden replies only if the viewer owns\n // the threadgate and they hid the reply.\n if (item.reason === 'reply') {\n const post = hydration.posts?.get(uri)\n if (post) {\n const rootPostUri = isPostRecordType(post.record)\n ? post.record.reply?.root.uri\n : undefined\n const isRootPostByViewer =\n rootPostUri && didFromUri(rootPostUri) === params.hydrateCtx?.viewer\n const isHiddenByThreadgate = isRootPostByViewer\n ? ctx.views.replyIsHiddenByThreadgate(uri, rootPostUri, hydration)\n : false\n if (isHiddenByThreadgate) {\n return false\n }\n }\n }\n // Filter out notifications from users that have thread hide tags and are from people they\n // are not following\n if (\n item.reason === 'reply' ||\n item.reason === 'quote' ||\n item.reason === 'mention'\n ) {\n const post = hydration.posts?.get(uri)\n if (post) {\n for (const [tag] of post.tags.entries()) {\n if (ctx.cfg.threadTagsHide.has(tag)) {\n if (!hydration.profileViewers?.get(did)?.following) {\n return false\n } else {\n break\n }\n }\n }\n }\n }\n // Filter out notifications from users that need review unless moots\n if (\n item.reason === 'reply' ||\n item.reason === 'quote' ||\n item.reason === 'mention' ||\n item.reason === 'like' ||\n item.reason === 'follow'\n ) {\n if (!ctx.views.viewerSeesNeedsReview({ did, uri }, hydration)) {\n return false\n }\n }\n return true\n })\n return skeleton\n}\n\nconst presentation = (\n input: PresentationFnInput<Context, Params, SkeletonState>,\n): app.bsky.notification.listNotifications.$OutputBody => {\n const { skeleton, hydration, ctx } = input\n const { notifs, lastSeenNotifs, cursor } = skeleton\n const notifications = mapDefined(notifs, (notif) =>\n ctx.views.notification(notif, lastSeenNotifs, hydration),\n )\n return {\n notifications,\n cursor,\n seenAt: skeleton.lastSeenNotifs,\n }\n}\n\ntype Context = {\n hydrator: Hydrator\n views: Views\n cfg: ServerConfig\n}\n\ntype Params = app.bsky.notification.listNotifications.$Params & {\n hydrateCtx: HydrateCtxWithViewer\n lastSeen?: Date\n}\n\ntype SkeletonState = {\n notifs: Notification[]\n lastSeenNotifs?: DatetimeString\n cursor?: string\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"putPreferences.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/putPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"putPreferences.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/putPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAKxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAsBvD"}
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import { app } from '../../../../lexicons/index.js';
|
|
2
|
+
import { Namespaces } from '../../../../stash.js';
|
|
3
|
+
import { getNotificationPreferences } from './util.js';
|
|
2
4
|
export default function (server, ctx) {
|
|
3
5
|
server.add(app.bsky.notification.putPreferences, {
|
|
4
6
|
auth: ctx.authVerifier.standard,
|
|
5
7
|
handler: async ({ input, auth }) => {
|
|
6
8
|
const { priority } = input.body;
|
|
7
9
|
const viewer = auth.credentials.iss;
|
|
8
|
-
await ctx
|
|
10
|
+
const currentPreferences = await getNotificationPreferences(ctx, viewer);
|
|
11
|
+
const include = priority ? 'follows' : 'all';
|
|
12
|
+
const preferences = {
|
|
13
|
+
...currentPreferences,
|
|
14
|
+
reply: { ...currentPreferences.reply, include },
|
|
15
|
+
mention: { ...currentPreferences.mention, include },
|
|
16
|
+
quote: { ...currentPreferences.quote, include },
|
|
17
|
+
};
|
|
18
|
+
await ctx.stashClient.update({
|
|
9
19
|
actorDid: viewer,
|
|
10
|
-
|
|
20
|
+
namespace: Namespaces.AppBskyNotificationDefsPreferences,
|
|
21
|
+
key: 'self',
|
|
22
|
+
payload: preferences,
|
|
11
23
|
});
|
|
12
24
|
},
|
|
13
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"putPreferences.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/putPreferences.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"putPreferences.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/putPreferences.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AAEtD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE;QAC/C,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,QAAQ;QAC/B,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;YACjC,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,IAAI,CAAA;YAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAA;YACnC,MAAM,kBAAkB,GAAG,MAAM,0BAA0B,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;YACxE,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;YAC5C,MAAM,WAAW,GAAG;gBAClB,GAAG,kBAAkB;gBACrB,KAAK,EAAE,EAAE,GAAG,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE;gBAC/C,OAAO,EAAE,EAAE,GAAG,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE;gBACnD,KAAK,EAAE,EAAE,GAAG,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE;aAChD,CAAA;YACD,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC;gBAC3B,QAAQ,EAAE,MAAM;gBAChB,SAAS,EAAE,UAAU,CAAC,kCAAkC;gBACxD,GAAG,EAAE,MAAM;gBACX,OAAO,EAAE,WAAW;aACrB,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import type { Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport { app } from '../../../../lexicons/index.js'\nimport { Namespaces } from '../../../../stash.js'\nimport { getNotificationPreferences } from './util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(app.bsky.notification.putPreferences, {\n auth: ctx.authVerifier.standard,\n handler: async ({ input, auth }) => {\n const { priority } = input.body\n const viewer = auth.credentials.iss\n const currentPreferences = await getNotificationPreferences(ctx, viewer)\n const include = priority ? 'follows' : 'all'\n const preferences = {\n ...currentPreferences,\n reply: { ...currentPreferences.reply, include },\n mention: { ...currentPreferences.mention, include },\n quote: { ...currentPreferences.quote, include },\n }\n await ctx.stashClient.update({\n actorDid: viewer,\n namespace: Namespaces.AppBskyNotificationDefsPreferences,\n key: 'self',\n payload: preferences,\n })\n },\n })\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Server } from '@atproto/xrpc-server';
|
|
2
2
|
import type { AppContext } from '../../../../context.js';
|
|
3
3
|
export default function (server: Server, ctx: AppContext): void;
|
|
4
4
|
//# sourceMappingURL=putPreferencesV2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"putPreferencesV2.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/putPreferencesV2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"putPreferencesV2.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/putPreferencesV2.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AASxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAuBvD"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import { UpstreamFailureError } from '@atproto/xrpc-server';
|
|
3
1
|
import { app } from '../../../../lexicons/index.js';
|
|
4
2
|
import { Namespaces } from '../../../../stash.js';
|
|
5
|
-
import { DEFAULT_CHAT_PREFERENCE,
|
|
3
|
+
import { DEFAULT_CHAT_PREFERENCE, getNotificationPreferences, mergeNotificationPreferences, } from './util.js';
|
|
6
4
|
export default function (server, ctx) {
|
|
7
5
|
server.add(app.bsky.notification.putPreferencesV2, {
|
|
8
6
|
auth: ctx.authVerifier.standard,
|
|
@@ -26,18 +24,8 @@ export default function (server, ctx) {
|
|
|
26
24
|
});
|
|
27
25
|
}
|
|
28
26
|
const computePreferences = async (ctx, actorDid, input) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
res = await ctx.dataplane.getNotificationPreferences({
|
|
32
|
-
dids: [actorDid],
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
throw new UpstreamFailureError('cannot get current notification preferences', 'NotificationPreferencesFailed', { cause: err });
|
|
37
|
-
}
|
|
38
|
-
assert(res.preferences.length === 1, `expected exactly one preferences entry, got ${res.preferences.length}`);
|
|
39
|
-
const currentPreferences = protobufToLex(res.preferences[0]);
|
|
40
|
-
const preferences = { ...currentPreferences, ...input.body };
|
|
27
|
+
const currentPreferences = await getNotificationPreferences(ctx, actorDid);
|
|
28
|
+
const preferences = mergeNotificationPreferences(currentPreferences, input.body);
|
|
41
29
|
// NOTE: See the deprecation notice on the lexicon. This field returns a static default value and shouldn't be used.
|
|
42
30
|
// Use the chat.bsky.notification.defs#preferences type instead.
|
|
43
31
|
preferences.chat = DEFAULT_CHAT_PREFERENCE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"putPreferencesV2.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/putPreferencesV2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"putPreferencesV2.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/putPreferencesV2.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,WAAW,CAAA;AAElB,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE;QACjD,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,QAAQ;QAC/B,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;YACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAA;YACrC,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;YAElE,oGAAoG;YACpG,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC;gBAC3B,QAAQ;gBACR,SAAS,EAAE,UAAU,CAAC,kCAAkC;gBACxD,GAAG,EAAE,MAAM;gBACX,OAAO,EAAE,WAAW;aACrB,CAAC,CAAA;YAEF,OAAO;gBACL,QAAQ,EAAE,kBAAkB;gBAC5B,IAAI,EAAE;oBACJ,WAAW;iBACZ;aACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,kBAAkB,GAAG,KAAK,EAC9B,GAAe,EACf,QAAgB,EAChB,KAAoD,EACO,EAAE;IAC7D,MAAM,kBAAkB,GAAG,MAAM,0BAA0B,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC1E,MAAM,WAAW,GAAG,4BAA4B,CAC9C,kBAAkB,EAClB,KAAK,CAAC,IAAI,CACX,CAAA;IACD,oHAAoH;IACpH,gEAAgE;IAChE,WAAW,CAAC,IAAI,GAAG,uBAAuB,CAAA;IAC1C,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA","sourcesContent":["import type { Un$Typed } from '@atproto/lex'\nimport type { Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport { app } from '../../../../lexicons/index.js'\nimport { Namespaces } from '../../../../stash.js'\nimport {\n DEFAULT_CHAT_PREFERENCE,\n getNotificationPreferences,\n mergeNotificationPreferences,\n} from './util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(app.bsky.notification.putPreferencesV2, {\n auth: ctx.authVerifier.standard,\n handler: async ({ auth, input }) => {\n const actorDid = auth.credentials.iss\n const preferences = await computePreferences(ctx, actorDid, input)\n\n // Notification preferences are created automatically on the dataplane on signup, so we just update.\n await ctx.stashClient.update({\n actorDid,\n namespace: Namespaces.AppBskyNotificationDefsPreferences,\n key: 'self',\n payload: preferences,\n })\n\n return {\n encoding: 'application/json',\n body: {\n preferences,\n },\n }\n },\n })\n}\n\nconst computePreferences = async (\n ctx: AppContext,\n actorDid: string,\n input: app.bsky.notification.putPreferencesV2.$Input,\n): Promise<Un$Typed<app.bsky.notification.defs.Preferences>> => {\n const currentPreferences = await getNotificationPreferences(ctx, actorDid)\n const preferences = mergeNotificationPreferences(\n currentPreferences,\n input.body,\n )\n // NOTE: See the deprecation notice on the lexicon. This field returns a static default value and shouldn't be used.\n // Use the chat.bsky.notification.defs#preferences type instead.\n preferences.chat = DEFAULT_CHAT_PREFERENCE\n return preferences\n}\n"]}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import type { Un$Typed } from '@atproto/lex';
|
|
2
|
+
import type { AppContext } from '../../../../context.js';
|
|
1
3
|
import type { app } from '../../../../lexicons/index.js';
|
|
2
4
|
import { type NotificationPreferences } from '../../../../proto/bsky_pb.js';
|
|
3
5
|
import { AppPlatform } from '../../../../proto/courier_pb.js';
|
|
4
6
|
type DeepPartial<T> = T extends object ? {
|
|
5
7
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
6
8
|
} : T;
|
|
9
|
+
type LexNotificationPreferences = Un$Typed<app.bsky.notification.defs.Preferences>;
|
|
10
|
+
export declare const mergeNotificationPreferences: (current: LexNotificationPreferences, updates: Partial<LexNotificationPreferences>) => LexNotificationPreferences;
|
|
11
|
+
export declare const getNotificationPreferences: (ctx: AppContext, actorDid: string) => Promise<LexNotificationPreferences>;
|
|
7
12
|
export declare const DEFAULT_CHAT_PREFERENCE: app.bsky.notification.defs.ChatPreference;
|
|
8
13
|
export declare const protobufToLex: (res: DeepPartial<NotificationPreferences>) => app.bsky.notification.defs.Preferences;
|
|
9
14
|
type LexPlatform = 'ios' | 'android' | 'web';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAKL,KAAK,uBAAuB,EAC7B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAE7D,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAClC;KACG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACnC,GACD,CAAC,CAAA;AAEL,KAAK,0BAA0B,GAC7B,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;AAoBlD,eAAO,MAAM,4BAA4B,YAC9B,0BAA0B,WAC1B,OAAO,CAAC,0BAA0B,CAAC,KAC3C,0BAQF,CAAA;AAED,eAAO,MAAM,0BAA0B,QAChC,UAAU,YACL,MAAM,KACf,OAAO,CAAC,0BAA0B,CAoBpC,CAAA;AA0DD,eAAO,MAAM,uBAAuB,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,cAI9D,CAAA;AAqBH,eAAO,MAAM,aAAa,QACnB,WAAW,CAAC,uBAAuB,CAAC,KACxC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAkB7B,CAAA;AAED,KAAK,WAAW,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,CAAA;AAE5C,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,QAAQ,IAAI,WAAW,CAIjC;AAED,eAAO,MAAM,0BAA0B,aAAc,MAAM,KAAG,WAKvC,CAAA"}
|
|
@@ -1,5 +1,44 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { UpstreamFailureError } from '@atproto/xrpc-server';
|
|
1
3
|
import { NotificationInclude, } from '../../../../proto/bsky_pb.js';
|
|
2
4
|
import { AppPlatform } from '../../../../proto/courier_pb.js';
|
|
5
|
+
const notificationPreferenceKeys = Object.keys({
|
|
6
|
+
chat: true,
|
|
7
|
+
follow: true,
|
|
8
|
+
like: true,
|
|
9
|
+
likeViaRepost: true,
|
|
10
|
+
mention: true,
|
|
11
|
+
quote: true,
|
|
12
|
+
reply: true,
|
|
13
|
+
repost: true,
|
|
14
|
+
repostViaRepost: true,
|
|
15
|
+
starterpackJoined: true,
|
|
16
|
+
subscribedPost: true,
|
|
17
|
+
unverified: true,
|
|
18
|
+
verified: true,
|
|
19
|
+
});
|
|
20
|
+
export const mergeNotificationPreferences = (current, updates) => {
|
|
21
|
+
const preferences = { ...current };
|
|
22
|
+
for (const key of notificationPreferenceKeys) {
|
|
23
|
+
if (updates[key] !== undefined) {
|
|
24
|
+
Object.assign(preferences, { [key]: updates[key] });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return preferences;
|
|
28
|
+
};
|
|
29
|
+
export const getNotificationPreferences = async (ctx, actorDid) => {
|
|
30
|
+
let res;
|
|
31
|
+
try {
|
|
32
|
+
res = await ctx.dataplane.getNotificationPreferences({
|
|
33
|
+
dids: [actorDid],
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
throw new UpstreamFailureError('cannot get current notification preferences', 'NotificationPreferencesFailed', { cause: err });
|
|
38
|
+
}
|
|
39
|
+
assert(res.preferences.length === 1, `expected exactly one preferences entry, got ${res.preferences.length}`);
|
|
40
|
+
return protobufToLex(res.preferences[0]);
|
|
41
|
+
};
|
|
3
42
|
const ensureChatPreference = (p) => {
|
|
4
43
|
const includeValues = ['all', 'accepted'];
|
|
5
44
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/util.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,mBAAmB,GAGpB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAQ7D,MAAM,oBAAoB,GAAG,CAC3B,CAA0D,EACf,EAAE;IAC7C,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IACzC,OAAO;QACL,OAAO,EACL,OAAO,CAAC,EAAE,OAAO,KAAK,QAAQ,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;YACjE,CAAC,CAAC,CAAC,CAAC,OAAO;YACX,CAAC,CAAC,KAAK;QACX,IAAI,EAAE,CAAC,EAAE,IAAI,IAAI,IAAI;KACtB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,0BAA0B,GAAG,CACjC,CAAgE,EACf,EAAE;IACnD,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IACxC,OAAO;QACL,OAAO,EACL,OAAO,CAAC,EAAE,OAAO,KAAK,QAAQ,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;YACjE,CAAC,CAAC,CAAC,CAAC,OAAO;YACX,CAAC,CAAC,KAAK;QACX,IAAI,EAAE,CAAC,EAAE,IAAI,IAAI,IAAI;QACrB,IAAI,EAAE,CAAC,EAAE,IAAI,IAAI,IAAI;KACtB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG,CACvB,CAAsD,EACf,EAAE;IACzC,OAAO;QACL,IAAI,EAAE,CA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,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAA;IAC9E,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,QAAgB,EAAe,EAAE,CAC1E,QAAQ,KAAK,KAAK;IAChB,CAAC,CAAC,WAAW,CAAC,GAAG;IACjB,CAAC,CAAC,QAAQ,KAAK,SAAS;QACtB,CAAC,CAAC,WAAW,CAAC,OAAO;QACrB,CAAC,CAAC,WAAW,CAAC,GAAG,CAAA","sourcesContent":["import type { app } from '../../../../lexicons/index.js'\nimport {\n type FilterableNotificationPreference,\n NotificationInclude,\n type NotificationPreference,\n type NotificationPreferences,\n} from '../../../../proto/bsky_pb.js'\nimport { AppPlatform } from '../../../../proto/courier_pb.js'\n\ntype DeepPartial<T> = T extends object\n ? {\n [P in keyof T]?: DeepPartial<T[P]>\n }\n : T\n\nconst ensureChatPreference = (\n p?: DeepPartial<app.bsky.notification.defs.ChatPreference>,\n): app.bsky.notification.defs.ChatPreference => {\n const includeValues = ['all', 'accepted']\n return {\n include:\n typeof p?.include === 'string' && includeValues.includes(p.include)\n ? p.include\n : 'all',\n push: p?.push ?? true,\n }\n}\n\nconst ensureFilterablePreference = (\n p?: DeepPartial<app.bsky.notification.defs.FilterablePreference>,\n): app.bsky.notification.defs.FilterablePreference => {\n const includeValues = ['all', 'follows']\n return {\n include:\n typeof p?.include === 'string' && includeValues.includes(p.include)\n ? p.include\n : 'all',\n list: p?.list ?? true,\n push: p?.push ?? true,\n }\n}\n\nconst ensurePreference = (\n p?: DeepPartial<app.bsky.notification.defs.Preference>,\n): app.bsky.notification.defs.Preference => {\n return {\n list: p?.list ?? true,\n push: p?.push ?? true,\n }\n}\n\nconst ensurePreferences = (\n p: DeepPartial<app.bsky.notification.defs.Preferences>,\n): app.bsky.notification.defs.Preferences => {\n return {\n chat: ensureChatPreference(p.chat),\n follow: ensureFilterablePreference(p.follow),\n like: ensureFilterablePreference(p.like),\n likeViaRepost: ensureFilterablePreference(p.likeViaRepost),\n mention: ensureFilterablePreference(p.mention),\n quote: ensureFilterablePreference(p.quote),\n reply: ensureFilterablePreference(p.reply),\n repost: ensureFilterablePreference(p.repost),\n repostViaRepost: ensureFilterablePreference(p.repostViaRepost),\n starterpackJoined: ensurePreference(p.starterpackJoined),\n subscribedPost: ensurePreference(p.subscribedPost),\n unverified: ensurePreference(p.unverified),\n verified: ensurePreference(p.verified),\n }\n}\n\nexport const DEFAULT_CHAT_PREFERENCE: app.bsky.notification.defs.ChatPreference =\n {\n include: 'all',\n push: true,\n }\n\nconst protobufFilterablePreferenceToLex = (\n p?: DeepPartial<FilterableNotificationPreference>,\n): Partial<app.bsky.notification.defs.FilterablePreference> => {\n return {\n include: p?.include === NotificationInclude.FOLLOWS ? 'follows' : 'all',\n list: p?.list?.enabled,\n push: p?.push?.enabled,\n }\n}\n\nconst protobufPreferenceToLex = (\n p?: DeepPartial<NotificationPreference>,\n): Partial<app.bsky.notification.defs.Preference> => {\n return {\n list: p?.list?.enabled,\n push: p?.push?.enabled,\n }\n}\n\nexport const protobufToLex = (\n res: DeepPartial<NotificationPreferences>,\n): app.bsky.notification.defs.Preferences => {\n return ensurePreferences({\n // NOTE: See the deprecation notice on the lexicon. This field returns a static default value and shouldn't be used.\n // Use the chat.bsky.notification.defs#preferences type instead.\n chat: DEFAULT_CHAT_PREFERENCE,\n follow: protobufFilterablePreferenceToLex(res.follow),\n like: protobufFilterablePreferenceToLex(res.like),\n likeViaRepost: protobufFilterablePreferenceToLex(res.likeViaRepost),\n mention: protobufFilterablePreferenceToLex(res.mention),\n quote: protobufFilterablePreferenceToLex(res.quote),\n reply: protobufFilterablePreferenceToLex(res.reply),\n repost: protobufFilterablePreferenceToLex(res.repost),\n repostViaRepost: protobufFilterablePreferenceToLex(res.repostViaRepost),\n starterpackJoined: protobufPreferenceToLex(res.starterpackJoined),\n subscribedPost: protobufPreferenceToLex(res.subscribedPost),\n unverified: protobufPreferenceToLex(res.unverified),\n verified: protobufPreferenceToLex(res.verified),\n })\n}\n\ntype LexPlatform = 'ios' | 'android' | 'web'\n\nexport function assertLexPlatform(\n platform: string,\n): asserts platform is LexPlatform {\n if (platform !== 'ios' && platform !== 'android' && platform !== 'web') {\n throw new Error('Unsupported platform: must be \"ios\", \"android\", or \"web\".')\n }\n}\n\nexport const lexPlatformToProtoPlatform = (platform: string): AppPlatform =>\n platform === 'ios'\n ? AppPlatform.IOS\n : platform === 'android'\n ? AppPlatform.ANDROID\n : AppPlatform.WEB\n"]}
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/util.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAG3D,OAAO,EAGL,mBAAmB,GAGpB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAW7D,MAAM,0BAA0B,GAAG,MAAM,CAAC,IAAI,CAAC;IAC7C,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,IAAI;IACV,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,eAAe,EAAE,IAAI;IACrB,iBAAiB,EAAE,IAAI;IACvB,cAAc,EAAE,IAAI;IACpB,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,IAAI;CAC0C,CAEzD,CAAA;AAED,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,OAAmC,EACnC,OAA4C,EAChB,EAAE;IAC9B,MAAM,WAAW,GAAG,EAAE,GAAG,OAAO,EAAE,CAAA;IAClC,KAAK,MAAM,GAAG,IAAI,0BAA0B,EAAE,CAAC;QA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GAAG,CAAC,KAAK,CAAC;QACnD,MAAM,EAAE,iCAAiC,CAAC,GAAG,CAAC,MAAM,CAAC;QACrD,eAAe,EAAE,iCAAiC,CAAC,GAAG,CAAC,eAAe,CAAC;QACvE,iBAAiB,EAAE,uBAAuB,CAAC,GAAG,CAAC,iBAAiB,CAAC;QACjE,cAAc,EAAE,uBAAuB,CAAC,GAAG,CAAC,cAAc,CAAC;QAC3D,UAAU,EAAE,uBAAuB,CAAC,GAAG,CAAC,UAAU,CAAC;QACnD,QAAQ,EAAE,uBAAuB,CAAC,GAAG,CAAC,QAAQ,CAAC;KAChD,CAAC,CAAA;AACJ,CAAC,CAAA;AAID,MAAM,UAAU,iBAAiB,CAC/B,QAAgB;IAEhB,IAAI,QAAQ,KAAK,KAAK,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAA;IAC9E,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,QAAgB,EAAe,EAAE,CAC1E,QAAQ,KAAK,KAAK;IAChB,CAAC,CAAC,WAAW,CAAC,GAAG;IACjB,CAAC,CAAC,QAAQ,KAAK,SAAS;QACtB,CAAC,CAAC,WAAW,CAAC,OAAO;QACrB,CAAC,CAAC,WAAW,CAAC,GAAG,CAAA","sourcesContent":["import assert from 'node:assert'\nimport type { Un$Typed } from '@atproto/lex'\nimport { UpstreamFailureError } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport type { app } from '../../../../lexicons/index.js'\nimport {\n type FilterableNotificationPreference,\n type GetNotificationPreferencesResponse,\n NotificationInclude,\n type NotificationPreference,\n type NotificationPreferences,\n} from '../../../../proto/bsky_pb.js'\nimport { AppPlatform } from '../../../../proto/courier_pb.js'\n\ntype DeepPartial<T> = T extends object\n ? {\n [P in keyof T]?: DeepPartial<T[P]>\n }\n : T\n\ntype LexNotificationPreferences =\n Un$Typed<app.bsky.notification.defs.Preferences>\n\nconst notificationPreferenceKeys = Object.keys({\n chat: true,\n follow: true,\n like: true,\n likeViaRepost: true,\n mention: true,\n quote: true,\n reply: true,\n repost: true,\n repostViaRepost: true,\n starterpackJoined: true,\n subscribedPost: true,\n unverified: true,\n verified: true,\n} satisfies Record<keyof LexNotificationPreferences, true>) as Array<\n keyof LexNotificationPreferences\n>\n\nexport const mergeNotificationPreferences = (\n current: LexNotificationPreferences,\n updates: Partial<LexNotificationPreferences>,\n): LexNotificationPreferences => {\n const preferences = { ...current }\n for (const key of notificationPreferenceKeys) {\n if (updates[key] !== undefined) {\n Object.assign(preferences, { [key]: updates[key] })\n }\n }\n return preferences\n}\n\nexport const getNotificationPreferences = async (\n ctx: AppContext,\n actorDid: string,\n): Promise<LexNotificationPreferences> => {\n let res: GetNotificationPreferencesResponse\n try {\n res = await ctx.dataplane.getNotificationPreferences({\n dids: [actorDid],\n })\n } catch (err) {\n throw new UpstreamFailureError(\n 'cannot get current notification preferences',\n 'NotificationPreferencesFailed',\n { cause: err },\n )\n }\n\n assert(\n res.preferences.length === 1,\n `expected exactly one preferences entry, got ${res.preferences.length}`,\n )\n\n return protobufToLex(res.preferences[0])\n}\n\nconst ensureChatPreference = (\n p?: DeepPartial<app.bsky.notification.defs.ChatPreference>,\n): app.bsky.notification.defs.ChatPreference => {\n const includeValues = ['all', 'accepted']\n return {\n include:\n typeof p?.include === 'string' && includeValues.includes(p.include)\n ? p.include\n : 'all',\n push: p?.push ?? true,\n }\n}\n\nconst ensureFilterablePreference = (\n p?: DeepPartial<app.bsky.notification.defs.FilterablePreference>,\n): app.bsky.notification.defs.FilterablePreference => {\n const includeValues = ['all', 'follows']\n return {\n include:\n typeof p?.include === 'string' && includeValues.includes(p.include)\n ? p.include\n : 'all',\n list: p?.list ?? true,\n push: p?.push ?? true,\n }\n}\n\nconst ensurePreference = (\n p?: DeepPartial<app.bsky.notification.defs.Preference>,\n): app.bsky.notification.defs.Preference => {\n return {\n list: p?.list ?? true,\n push: p?.push ?? true,\n }\n}\n\nconst ensurePreferences = (\n p: DeepPartial<app.bsky.notification.defs.Preferences>,\n): app.bsky.notification.defs.Preferences => {\n return {\n chat: ensureChatPreference(p.chat),\n follow: ensureFilterablePreference(p.follow),\n like: ensureFilterablePreference(p.like),\n likeViaRepost: ensureFilterablePreference(p.likeViaRepost),\n mention: ensureFilterablePreference(p.mention),\n quote: ensureFilterablePreference(p.quote),\n reply: ensureFilterablePreference(p.reply),\n repost: ensureFilterablePreference(p.repost),\n repostViaRepost: ensureFilterablePreference(p.repostViaRepost),\n starterpackJoined: ensurePreference(p.starterpackJoined),\n subscribedPost: ensurePreference(p.subscribedPost),\n unverified: ensurePreference(p.unverified),\n verified: ensurePreference(p.verified),\n }\n}\n\nexport const DEFAULT_CHAT_PREFERENCE: app.bsky.notification.defs.ChatPreference =\n {\n include: 'all',\n push: true,\n }\n\nconst protobufFilterablePreferenceToLex = (\n p?: DeepPartial<FilterableNotificationPreference>,\n): Partial<app.bsky.notification.defs.FilterablePreference> => {\n return {\n include: p?.include === NotificationInclude.FOLLOWS ? 'follows' : 'all',\n list: p?.list?.enabled,\n push: p?.push?.enabled,\n }\n}\n\nconst protobufPreferenceToLex = (\n p?: DeepPartial<NotificationPreference>,\n): Partial<app.bsky.notification.defs.Preference> => {\n return {\n list: p?.list?.enabled,\n push: p?.push?.enabled,\n }\n}\n\nexport const protobufToLex = (\n res: DeepPartial<NotificationPreferences>,\n): app.bsky.notification.defs.Preferences => {\n return ensurePreferences({\n // NOTE: See the deprecation notice on the lexicon. This field returns a static default value and shouldn't be used.\n // Use the chat.bsky.notification.defs#preferences type instead.\n chat: DEFAULT_CHAT_PREFERENCE,\n follow: protobufFilterablePreferenceToLex(res.follow),\n like: protobufFilterablePreferenceToLex(res.like),\n likeViaRepost: protobufFilterablePreferenceToLex(res.likeViaRepost),\n mention: protobufFilterablePreferenceToLex(res.mention),\n quote: protobufFilterablePreferenceToLex(res.quote),\n reply: protobufFilterablePreferenceToLex(res.reply),\n repost: protobufFilterablePreferenceToLex(res.repost),\n repostViaRepost: protobufFilterablePreferenceToLex(res.repostViaRepost),\n starterpackJoined: protobufPreferenceToLex(res.starterpackJoined),\n subscribedPost: protobufPreferenceToLex(res.subscribedPost),\n unverified: protobufPreferenceToLex(res.unverified),\n verified: protobufPreferenceToLex(res.verified),\n })\n}\n\ntype LexPlatform = 'ios' | 'android' | 'web'\n\nexport function assertLexPlatform(\n platform: string,\n): asserts platform is LexPlatform {\n if (platform !== 'ios' && platform !== 'android' && platform !== 'web') {\n throw new Error('Unsupported platform: must be \"ios\", \"android\", or \"web\".')\n }\n}\n\nexport const lexPlatformToProtoPlatform = (platform: string): AppPlatform =>\n platform === 'ios'\n ? AppPlatform.IOS\n : platform === 'android'\n ? AppPlatform.ANDROID\n : AppPlatform.WEB\n"]}
|
package/dist/api/util.js
CHANGED
|
@@ -27,7 +27,7 @@ export const fillPage = async (opts) => {
|
|
|
27
27
|
limit: opts.limit,
|
|
28
28
|
}));
|
|
29
29
|
const items = opts.items(result);
|
|
30
|
-
let cursor = result.cursor;
|
|
30
|
+
let cursor = result.cursor || undefined;
|
|
31
31
|
for (let requests = 1; requests < maxRequests && cursor && items.length < enoughItems; requests++) {
|
|
32
32
|
const previousCursor = cursor;
|
|
33
33
|
const page = (await opts.fetch({
|
|
@@ -35,7 +35,7 @@ export const fillPage = async (opts) => {
|
|
|
35
35
|
limit: opts.limit - items.length,
|
|
36
36
|
}));
|
|
37
37
|
items.push(...opts.items(page));
|
|
38
|
-
cursor = page.cursor;
|
|
38
|
+
cursor = page.cursor || undefined;
|
|
39
39
|
if (cursor === previousCursor) {
|
|
40
40
|
cursor = undefined;
|
|
41
41
|
break;
|