@atproto/bsky 0.0.250 → 0.0.253
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 +49 -0
- package/dist/api/age-assurance/const.js +19 -19
- package/dist/api/age-assurance/const.js.map +1 -1
- package/dist/api/app/bsky/feed/getFeed.d.ts.map +1 -1
- package/dist/api/app/bsky/feed/getFeed.js +4 -0
- package/dist/api/app/bsky/feed/getFeed.js.map +1 -1
- package/dist/api/app/bsky/feed/searchPosts.js +5 -0
- package/dist/api/app/bsky/feed/searchPosts.js.map +1 -1
- package/dist/api/app/bsky/feed/searchPostsV2.js +5 -0
- package/dist/api/app/bsky/feed/searchPostsV2.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -1
- package/dist/hydration/feed.d.ts +1 -2
- package/dist/hydration/feed.d.ts.map +1 -1
- package/dist/hydration/feed.js.map +1 -1
- package/dist/kws.d.ts +8 -0
- package/dist/kws.d.ts.map +1 -1
- package/dist/kws.js +53 -4
- package/dist/kws.js.map +1 -1
- package/package.json +28 -23
- package/bin/migration-create.ts +0 -46
- package/buf.gen.yaml +0 -12
- package/proto/bsky.proto +0 -1907
- package/proto/courier.proto +0 -84
- package/proto/rolodex.proto +0 -116
- package/src/api/age-assurance/const.ts +0 -203
- package/src/api/age-assurance/index.ts +0 -34
- package/src/api/age-assurance/kws/age-verified.test.ts +0 -98
- package/src/api/age-assurance/kws/age-verified.ts +0 -81
- package/src/api/age-assurance/kws/const.ts +0 -33
- package/src/api/age-assurance/kws/external-payload.test.ts +0 -72
- package/src/api/age-assurance/kws/external-payload.ts +0 -149
- package/src/api/age-assurance/redirects/kws-age-verified.ts +0 -107
- package/src/api/age-assurance/stash.ts +0 -23
- package/src/api/age-assurance/types.ts +0 -10
- package/src/api/age-assurance/util.ts +0 -68
- package/src/api/age-assurance/webhooks/kws-age-verified.ts +0 -75
- package/src/api/app/bsky/actor/getProfile.ts +0 -106
- package/src/api/app/bsky/actor/getProfiles.ts +0 -99
- package/src/api/app/bsky/actor/getSuggestions.ts +0 -163
- package/src/api/app/bsky/actor/searchActors.ts +0 -171
- package/src/api/app/bsky/actor/searchActorsTypeahead.ts +0 -164
- package/src/api/app/bsky/ageassurance/begin.ts +0 -175
- package/src/api/app/bsky/ageassurance/getConfig.ts +0 -16
- package/src/api/app/bsky/ageassurance/getState.ts +0 -58
- package/src/api/app/bsky/bookmark/createBookmark.ts +0 -39
- package/src/api/app/bsky/bookmark/deleteBookmark.ts +0 -32
- package/src/api/app/bsky/bookmark/getBookmarks.ts +0 -97
- package/src/api/app/bsky/bookmark/util.ts +0 -13
- package/src/api/app/bsky/contact/dismissMatch.ts +0 -26
- package/src/api/app/bsky/contact/getMatches.ts +0 -111
- package/src/api/app/bsky/contact/getSyncStatus.ts +0 -38
- package/src/api/app/bsky/contact/importContacts.ts +0 -119
- package/src/api/app/bsky/contact/removeData.ts +0 -25
- package/src/api/app/bsky/contact/sendNotification.ts +0 -33
- package/src/api/app/bsky/contact/startPhoneVerification.ts +0 -26
- package/src/api/app/bsky/contact/util.ts +0 -92
- package/src/api/app/bsky/contact/verifyPhone.ts +0 -29
- package/src/api/app/bsky/draft/createDraft.ts +0 -45
- package/src/api/app/bsky/draft/deleteDraft.ts +0 -20
- package/src/api/app/bsky/draft/getDrafts.ts +0 -44
- package/src/api/app/bsky/draft/updateDraft.ts +0 -26
- package/src/api/app/bsky/embed/getEmbedExternalView.ts +0 -154
- package/src/api/app/bsky/feed/getActorFeeds.ts +0 -101
- package/src/api/app/bsky/feed/getActorLikes.ts +0 -128
- package/src/api/app/bsky/feed/getAuthorFeed.ts +0 -279
- package/src/api/app/bsky/feed/getFeed.ts +0 -277
- package/src/api/app/bsky/feed/getFeedGenerator.ts +0 -68
- package/src/api/app/bsky/feed/getFeedGenerators.ts +0 -86
- package/src/api/app/bsky/feed/getLikes.ts +0 -151
- package/src/api/app/bsky/feed/getListFeed.ts +0 -147
- package/src/api/app/bsky/feed/getPostThread.ts +0 -156
- package/src/api/app/bsky/feed/getPosts.ts +0 -100
- package/src/api/app/bsky/feed/getQuotes.ts +0 -122
- package/src/api/app/bsky/feed/getRepostedBy.ts +0 -121
- package/src/api/app/bsky/feed/getSuggestedFeeds.ts +0 -39
- package/src/api/app/bsky/feed/getTimeline.ts +0 -127
- package/src/api/app/bsky/feed/searchPosts.ts +0 -267
- package/src/api/app/bsky/feed/searchPostsV2.ts +0 -236
- package/src/api/app/bsky/graph/getActorStarterPacks.ts +0 -103
- package/src/api/app/bsky/graph/getBlocks.ts +0 -94
- package/src/api/app/bsky/graph/getFollowers.ts +0 -153
- package/src/api/app/bsky/graph/getFollows.ts +0 -151
- package/src/api/app/bsky/graph/getKnownFollowers.ts +0 -123
- package/src/api/app/bsky/graph/getList.ts +0 -152
- package/src/api/app/bsky/graph/getListBlocks.ts +0 -87
- package/src/api/app/bsky/graph/getListMutes.ts +0 -87
- package/src/api/app/bsky/graph/getLists.ts +0 -125
- package/src/api/app/bsky/graph/getListsWithMembership.ts +0 -146
- package/src/api/app/bsky/graph/getMutes.ts +0 -87
- package/src/api/app/bsky/graph/getRelationships.ts +0 -58
- package/src/api/app/bsky/graph/getStarterPack.ts +0 -82
- package/src/api/app/bsky/graph/getStarterPacks.ts +0 -86
- package/src/api/app/bsky/graph/getStarterPacksWithMembership.ts +0 -136
- package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +0 -171
- package/src/api/app/bsky/graph/muteActor.ts +0 -24
- package/src/api/app/bsky/graph/muteActorList.ts +0 -19
- package/src/api/app/bsky/graph/muteThread.ts +0 -19
- package/src/api/app/bsky/graph/searchStarterPacks.ts +0 -169
- package/src/api/app/bsky/graph/unmuteActor.ts +0 -21
- package/src/api/app/bsky/graph/unmuteActorList.ts +0 -19
- package/src/api/app/bsky/graph/unmuteThread.ts +0 -19
- package/src/api/app/bsky/labeler/getServices.ts +0 -41
- package/src/api/app/bsky/notification/getPreferences.ts +0 -49
- package/src/api/app/bsky/notification/getUnreadCount.ts +0 -83
- package/src/api/app/bsky/notification/listActivitySubscriptions.ts +0 -116
- package/src/api/app/bsky/notification/listNotifications.ts +0 -272
- package/src/api/app/bsky/notification/putActivitySubscription.ts +0 -69
- package/src/api/app/bsky/notification/putPreferences.ts +0 -17
- package/src/api/app/bsky/notification/putPreferencesV2.ts +0 -64
- package/src/api/app/bsky/notification/registerPush.ts +0 -40
- package/src/api/app/bsky/notification/unregisterPush.ts +0 -39
- package/src/api/app/bsky/notification/updateSeen.ts +0 -52
- package/src/api/app/bsky/notification/util.ts +0 -134
- package/src/api/app/bsky/unspecced/getAgeAssuranceState.ts +0 -48
- package/src/api/app/bsky/unspecced/getConfig.ts +0 -20
- package/src/api/app/bsky/unspecced/getOnboardingSuggestedStarterPacks.ts +0 -162
- package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +0 -91
- package/src/api/app/bsky/unspecced/getPostThreadOtherV2.ts +0 -126
- package/src/api/app/bsky/unspecced/getPostThreadV2.ts +0 -148
- package/src/api/app/bsky/unspecced/getSuggestedFeeds.ts +0 -100
- package/src/api/app/bsky/unspecced/getSuggestedOnboardingUsers.ts +0 -143
- package/src/api/app/bsky/unspecced/getSuggestedStarterPacks.ts +0 -165
- package/src/api/app/bsky/unspecced/getSuggestedUsers.ts +0 -183
- package/src/api/app/bsky/unspecced/getSuggestedUsersForDiscover.ts +0 -175
- package/src/api/app/bsky/unspecced/getSuggestedUsersForExplore.ts +0 -178
- package/src/api/app/bsky/unspecced/getSuggestedUsersForSeeMore.ts +0 -178
- package/src/api/app/bsky/unspecced/getTaggedSuggestions.ts +0 -27
- package/src/api/app/bsky/unspecced/getTrendingTopics.ts +0 -96
- package/src/api/app/bsky/unspecced/getTrends.ts +0 -162
- package/src/api/app/bsky/unspecced/initAgeAssurance.ts +0 -150
- package/src/api/blob-dispatcher.ts +0 -41
- package/src/api/blob-resolver.ts +0 -401
- package/src/api/com/atproto/admin/getAccountInfos.ts +0 -49
- package/src/api/com/atproto/admin/getSubjectStatus.ts +0 -79
- package/src/api/com/atproto/admin/updateSubjectStatus.ts +0 -80
- package/src/api/com/atproto/identity/resolveHandle.ts +0 -19
- package/src/api/com/atproto/label/queryLabels.ts +0 -42
- package/src/api/com/atproto/repo/getRecord.ts +0 -44
- package/src/api/com/atproto/temp/fetchLabels.ts +0 -9
- package/src/api/external.ts +0 -15
- package/src/api/health.ts +0 -47
- package/src/api/index.ts +0 -216
- package/src/api/internal/bsky/actor/getProfiles.ts +0 -87
- package/src/api/kws/api.ts +0 -113
- package/src/api/kws/index.ts +0 -29
- package/src/api/kws/types.ts +0 -78
- package/src/api/kws/util.test.ts +0 -50
- package/src/api/kws/util.ts +0 -109
- package/src/api/kws/webhook.ts +0 -134
- package/src/api/sitemap.ts +0 -76
- package/src/api/util.ts +0 -45
- package/src/api/well-known.ts +0 -44
- package/src/auth-verifier.ts +0 -522
- package/src/bsync.ts +0 -41
- package/src/cache/read-through.ts +0 -157
- package/src/config.ts +0 -710
- package/src/context.ts +0 -143
- package/src/courier.ts +0 -41
- package/src/data-plane/client/hosts.ts +0 -103
- package/src/data-plane/client/index.ts +0 -125
- package/src/data-plane/client/util.test.ts +0 -29
- package/src/data-plane/client/util.ts +0 -74
- package/src/data-plane/index.ts +0 -2
- package/src/data-plane/server/background.ts +0 -66
- package/src/data-plane/server/bsync-subscription.ts +0 -590
- package/src/data-plane/server/db/database-schema.ts +0 -90
- package/src/data-plane/server/db/db.ts +0 -204
- package/src/data-plane/server/db/index.ts +0 -2
- package/src/data-plane/server/db/migrations/20230309T045948368Z-init.ts +0 -305
- package/src/data-plane/server/db/migrations/20230408T152211201Z-notification-init.ts +0 -25
- package/src/data-plane/server/db/migrations/20230417T210628672Z-moderation-init.ts +0 -127
- package/src/data-plane/server/db/migrations/20230420T211446071Z-did-cache.ts +0 -14
- package/src/data-plane/server/db/migrations/20230427T194702079Z-notif-record-index.ts +0 -14
- package/src/data-plane/server/db/migrations/20230605T144730094Z-post-profile-aggs.ts +0 -23
- package/src/data-plane/server/db/migrations/20230607T211442112Z-feed-generator-init.ts +0 -34
- package/src/data-plane/server/db/migrations/20230608T155101190Z-algo-whats-hot-view.ts +0 -85
- package/src/data-plane/server/db/migrations/20230608T201813132Z-mute-lists.ts +0 -78
- package/src/data-plane/server/db/migrations/20230608T205147239Z-mutes.ts +0 -15
- package/src/data-plane/server/db/migrations/20230609T153623961Z-blocks.ts +0 -33
- package/src/data-plane/server/db/migrations/20230609T232122649Z-actor-deletion-indexes.ts +0 -27
- package/src/data-plane/server/db/migrations/20230610T203555962Z-suggested-follows.ts +0 -13
- package/src/data-plane/server/db/migrations/20230611T215300060Z-actor-state.ts +0 -13
- package/src/data-plane/server/db/migrations/20230620T161134972Z-post-langs.ts +0 -9
- package/src/data-plane/server/db/migrations/20230627T212437895Z-optional-handle.ts +0 -15
- package/src/data-plane/server/db/migrations/20230629T220835893Z-remove-post-hierarchy.ts +0 -32
- package/src/data-plane/server/db/migrations/20230703T045536691Z-feed-and-label-indices.ts +0 -31
- package/src/data-plane/server/db/migrations/20230720T164800037Z-posts-cursor-idx.ts +0 -19
- package/src/data-plane/server/db/migrations/20230807T035309811Z-feed-item-delete-invite-for-user-idx.ts +0 -14
- package/src/data-plane/server/db/migrations/20230808T172902639Z-repo-rev.ts +0 -12
- package/src/data-plane/server/db/migrations/20230810T203349843Z-action-duration.ts +0 -23
- package/src/data-plane/server/db/migrations/20230817T195936007Z-native-notifications.ts +0 -16
- package/src/data-plane/server/db/migrations/20230830T205507322Z-suggested-feeds.ts +0 -13
- package/src/data-plane/server/db/migrations/20230904T211011773Z-block-lists.ts +0 -24
- package/src/data-plane/server/db/migrations/20230906T222220386Z-thread-gating.ts +0 -27
- package/src/data-plane/server/db/migrations/20230920T213858047Z-add-tags-to-post.ts +0 -9
- package/src/data-plane/server/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +0 -40
- package/src/data-plane/server/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +0 -123
- package/src/data-plane/server/db/migrations/20231220T225126090Z-blob-takedowns.ts +0 -66
- package/src/data-plane/server/db/migrations/20240124T023719200Z-tagged-suggestions.ts +0 -15
- package/src/data-plane/server/db/migrations/20240226T225725627Z-labelers.ts +0 -27
- package/src/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.ts +0 -12
- package/src/data-plane/server/db/migrations/20240606T171229898Z-thread-mutes.ts +0 -15
- package/src/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.ts +0 -45
- package/src/data-plane/server/db/migrations/20240719T203853939Z-priority-notifs.ts +0 -25
- package/src/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.ts +0 -12
- package/src/data-plane/server/db/migrations/20240723T220703655Z-quotes.ts +0 -28
- package/src/data-plane/server/db/migrations/20240801T193939827Z-post-gate.ts +0 -17
- package/src/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.ts +0 -25
- package/src/data-plane/server/db/migrations/20240829T211238293Z-simplify-actor-sync.ts +0 -23
- package/src/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.ts +0 -17
- package/src/data-plane/server/db/migrations/20241114T153108102Z-add-starter-packs-name.ts +0 -19
- package/src/data-plane/server/db/migrations/20250116T222618297Z-post-embed-video.ts +0 -17
- package/src/data-plane/server/db/migrations/20250207T174822012Z-add-label-exp.ts +0 -9
- package/src/data-plane/server/db/migrations/20250404T163421487Z-verifications.ts +0 -39
- package/src/data-plane/server/db/migrations/20250526T023712742Z-like-repost-via.ts +0 -17
- package/src/data-plane/server/db/migrations/20250528T221913281Z-add-record-tags.ts +0 -9
- package/src/data-plane/server/db/migrations/20250602T190357447Z-add-private-data.ts +0 -22
- package/src/data-plane/server/db/migrations/20250611T140649895Z-add-activity-subscription.ts +0 -22
- package/src/data-plane/server/db/migrations/20250627T025331240Z-add-actor-age-assurance-columns.ts +0 -22
- package/src/data-plane/server/db/migrations/20250812T183735692Z-add-bookmarks.ts +0 -23
- package/src/data-plane/server/db/migrations/20250813T174955711Z-add-post-agg-bookmarks.ts +0 -12
- package/src/data-plane/server/db/migrations/20251120T004738098Z-update-actor-age-assurance-v2.ts +0 -28
- package/src/data-plane/server/db/migrations/20260112T133951271Z-add-drafts.ts +0 -24
- package/src/data-plane/server/db/migrations/20260604T224952774Z-post-embed-gallery-image.ts +0 -19
- package/src/data-plane/server/db/migrations/index.ts +0 -60
- package/src/data-plane/server/db/migrations/provider.ts +0 -26
- package/src/data-plane/server/db/pagination.ts +0 -341
- package/src/data-plane/server/db/tables/activity-subscription.ts +0 -12
- package/src/data-plane/server/db/tables/actor-block.ts +0 -14
- package/src/data-plane/server/db/tables/actor-state.ts +0 -10
- package/src/data-plane/server/db/tables/actor-sync.ts +0 -9
- package/src/data-plane/server/db/tables/actor.ts +0 -19
- package/src/data-plane/server/db/tables/algo.ts +0 -11
- package/src/data-plane/server/db/tables/blob-takedown.ts +0 -9
- package/src/data-plane/server/db/tables/bookmark.ts +0 -11
- package/src/data-plane/server/db/tables/did-cache.ts +0 -13
- package/src/data-plane/server/db/tables/draft.ts +0 -11
- package/src/data-plane/server/db/tables/duplicate-record.ts +0 -12
- package/src/data-plane/server/db/tables/feed-generator.ts +0 -21
- package/src/data-plane/server/db/tables/feed-item.ts +0 -12
- package/src/data-plane/server/db/tables/follow.ts +0 -15
- package/src/data-plane/server/db/tables/label.ts +0 -13
- package/src/data-plane/server/db/tables/labeler.ts +0 -16
- package/src/data-plane/server/db/tables/like.ts +0 -18
- package/src/data-plane/server/db/tables/list-block.ts +0 -15
- package/src/data-plane/server/db/tables/list-item.ts +0 -16
- package/src/data-plane/server/db/tables/list-mute.ts +0 -9
- package/src/data-plane/server/db/tables/list.ts +0 -19
- package/src/data-plane/server/db/tables/mute.ts +0 -9
- package/src/data-plane/server/db/tables/notification-push-token.ts +0 -10
- package/src/data-plane/server/db/tables/notification.ts +0 -16
- package/src/data-plane/server/db/tables/post-agg.ts +0 -16
- package/src/data-plane/server/db/tables/post-embed.ts +0 -47
- package/src/data-plane/server/db/tables/post-gate.ts +0 -12
- package/src/data-plane/server/db/tables/post.ts +0 -28
- package/src/data-plane/server/db/tables/private-data.ts +0 -13
- package/src/data-plane/server/db/tables/profile-agg.ts +0 -14
- package/src/data-plane/server/db/tables/profile.ts +0 -17
- package/src/data-plane/server/db/tables/quote.ts +0 -15
- package/src/data-plane/server/db/tables/record.ts +0 -15
- package/src/data-plane/server/db/tables/repost.ts +0 -18
- package/src/data-plane/server/db/tables/starter-pack.ts +0 -17
- package/src/data-plane/server/db/tables/subscription.ts +0 -9
- package/src/data-plane/server/db/tables/suggested-feed.ts +0 -10
- package/src/data-plane/server/db/tables/suggested-follow.ts +0 -10
- package/src/data-plane/server/db/tables/tagged-suggestion.ts +0 -11
- package/src/data-plane/server/db/tables/thread-gate.ts +0 -12
- package/src/data-plane/server/db/tables/thread-mute.ts +0 -9
- package/src/data-plane/server/db/tables/verification.ts +0 -20
- package/src/data-plane/server/db/tables/view-param.ts +0 -12
- package/src/data-plane/server/db/types.ts +0 -12
- package/src/data-plane/server/db/util.ts +0 -67
- package/src/data-plane/server/index.ts +0 -44
- package/src/data-plane/server/indexing/index.ts +0 -458
- package/src/data-plane/server/indexing/plugins/block.ts +0 -84
- package/src/data-plane/server/indexing/plugins/chat-declaration.ts +0 -60
- package/src/data-plane/server/indexing/plugins/feed-generator.ts +0 -80
- package/src/data-plane/server/indexing/plugins/follow.ts +0 -132
- package/src/data-plane/server/indexing/plugins/germ-declaration.ts +0 -57
- package/src/data-plane/server/indexing/plugins/labeler.ts +0 -74
- package/src/data-plane/server/indexing/plugins/like.ts +0 -151
- package/src/data-plane/server/indexing/plugins/list-block.ts +0 -84
- package/src/data-plane/server/indexing/plugins/list-item.ts +0 -92
- package/src/data-plane/server/indexing/plugins/list.ts +0 -80
- package/src/data-plane/server/indexing/plugins/notif-declaration.ts +0 -57
- package/src/data-plane/server/indexing/plugins/post-gate.ts +0 -101
- package/src/data-plane/server/indexing/plugins/post.ts +0 -675
- package/src/data-plane/server/indexing/plugins/profile.ts +0 -90
- package/src/data-plane/server/indexing/plugins/repost.ts +0 -176
- package/src/data-plane/server/indexing/plugins/starter-pack.ts +0 -74
- package/src/data-plane/server/indexing/plugins/status.ts +0 -57
- package/src/data-plane/server/indexing/plugins/thread-gate.ts +0 -101
- package/src/data-plane/server/indexing/plugins/verification.ts +0 -113
- package/src/data-plane/server/indexing/processor.ts +0 -292
- package/src/data-plane/server/routes/activity-subscription.ts +0 -84
- package/src/data-plane/server/routes/blocks.ts +0 -127
- package/src/data-plane/server/routes/bookmarks.ts +0 -83
- package/src/data-plane/server/routes/drafts.ts +0 -37
- package/src/data-plane/server/routes/feed-gens.ts +0 -89
- package/src/data-plane/server/routes/feeds.ts +0 -176
- package/src/data-plane/server/routes/follows.ts +0 -141
- package/src/data-plane/server/routes/identity.ts +0 -59
- package/src/data-plane/server/routes/index.ts +0 -67
- package/src/data-plane/server/routes/interactions.ts +0 -120
- package/src/data-plane/server/routes/labels.ts +0 -55
- package/src/data-plane/server/routes/likes.ts +0 -92
- package/src/data-plane/server/routes/lists.ts +0 -88
- package/src/data-plane/server/routes/moderation.ts +0 -102
- package/src/data-plane/server/routes/mutes.ts +0 -195
- package/src/data-plane/server/routes/notifs.ts +0 -239
- package/src/data-plane/server/routes/profile.ts +0 -220
- package/src/data-plane/server/routes/quotes.ts +0 -32
- package/src/data-plane/server/routes/records.ts +0 -119
- package/src/data-plane/server/routes/relationships.ts +0 -174
- package/src/data-plane/server/routes/reposts.ts +0 -76
- package/src/data-plane/server/routes/search.ts +0 -181
- package/src/data-plane/server/routes/site-standard.ts +0 -12
- package/src/data-plane/server/routes/sitemap.ts +0 -43
- package/src/data-plane/server/routes/starter-packs.ts +0 -32
- package/src/data-plane/server/routes/suggestions.ts +0 -175
- package/src/data-plane/server/routes/sync.ts +0 -16
- package/src/data-plane/server/routes/threads.ts +0 -33
- package/src/data-plane/server/subscription.ts +0 -152
- package/src/data-plane/server/util.ts +0 -202
- package/src/error.ts +0 -12
- package/src/etcd.ts +0 -90
- package/src/feature-gates/README.md +0 -83
- package/src/feature-gates/gates.ts +0 -25
- package/src/feature-gates/index.ts +0 -235
- package/src/feature-gates/metrics.test.ts +0 -196
- package/src/feature-gates/metrics.ts +0 -107
- package/src/feature-gates/types.ts +0 -62
- package/src/feature-gates/utils.test.ts +0 -66
- package/src/feature-gates/utils.ts +0 -135
- package/src/hydration/actor.ts +0 -578
- package/src/hydration/external.test.ts +0 -281
- package/src/hydration/external.ts +0 -268
- package/src/hydration/feed.ts +0 -456
- package/src/hydration/graph.ts +0 -354
- package/src/hydration/hydrator.ts +0 -1835
- package/src/hydration/label.ts +0 -207
- package/src/hydration/util.ts +0 -199
- package/src/image/index.ts +0 -2
- package/src/image/invalidator.ts +0 -33
- package/src/image/logger.ts +0 -6
- package/src/image/server.ts +0 -228
- package/src/image/sharp.ts +0 -89
- package/src/image/uri.ts +0 -114
- package/src/image/util.ts +0 -41
- package/src/index.ts +0 -312
- package/src/kws.ts +0 -197
- package/src/logger.ts +0 -40
- package/src/pipeline.ts +0 -60
- package/src/redis.ts +0 -205
- package/src/rolodex.ts +0 -42
- package/src/stash.ts +0 -76
- package/src/util/debug.ts +0 -10
- package/src/util/http.ts +0 -42
- package/src/util/retry.ts +0 -10
- package/src/util/standard-site.test.ts +0 -423
- package/src/util/standard-site.ts +0 -196
- package/src/util/uris.ts +0 -38
- package/src/util.ts +0 -48
- package/src/views/index.ts +0 -2783
- package/src/views/threads-v2.ts +0 -510
- package/src/views/types.ts +0 -193
- package/src/views/util.ts +0 -114
- package/test.env +0 -2
- package/tests/__snapshots__/feed-generation.test.ts.snap +0 -2463
- package/tests/_util.ts +0 -292
- package/tests/admin/admin-auth.test.ts +0 -190
- package/tests/admin/moderation.test.ts +0 -222
- package/tests/auth.test.ts +0 -90
- package/tests/blob-resolver.test.ts +0 -125
- package/tests/data-plane/__snapshots__/indexing.test.ts.snap +0 -887
- package/tests/data-plane/db.test.ts +0 -189
- package/tests/data-plane/duplicate-records.test.ts +0 -156
- package/tests/data-plane/handle-invalidation.test.ts +0 -153
- package/tests/data-plane/indexing.test.ts +0 -827
- package/tests/data-plane/subscription.test.ts +0 -128
- package/tests/data-plane/thread-mutes.test.ts +0 -175
- package/tests/entryway-auth.test.ts +0 -177
- package/tests/etcd.test.ts +0 -302
- package/tests/feed-generation.test.ts +0 -919
- package/tests/hydration/util.test.ts +0 -119
- package/tests/image/server.test.ts +0 -97
- package/tests/image/sharp.test.ts +0 -199
- package/tests/image/uri.test.ts +0 -106
- package/tests/label-hydration.test.ts +0 -245
- package/tests/postgates.test.ts +0 -182
- package/tests/query-labels.test.ts +0 -85
- package/tests/redis-cache.test.ts +0 -230
- package/tests/seed/feed-hidden-replies.ts +0 -63
- package/tests/seed/get-suggested-starter-packs.ts +0 -64
- package/tests/seed/get-trends.ts +0 -71
- package/tests/seed/known-followers.ts +0 -111
- package/tests/seed/postgates.ts +0 -57
- package/tests/server.test.ts +0 -115
- package/tests/sitemap.test.ts +0 -75
- package/tests/stash.test.ts +0 -180
- package/tests/utils.test.ts +0 -36
- package/tests/views/__snapshots__/actor-search.test.ts.snap +0 -155
- package/tests/views/__snapshots__/author-feed.test.ts.snap +0 -6301
- package/tests/views/__snapshots__/block-lists.test.ts.snap +0 -690
- package/tests/views/__snapshots__/blocks.test.ts.snap +0 -462
- package/tests/views/__snapshots__/bookmarks.test.ts.snap +0 -379
- package/tests/views/__snapshots__/follows.test.ts.snap +0 -798
- package/tests/views/__snapshots__/labeler-service.test.ts.snap +0 -233
- package/tests/views/__snapshots__/likes.test.ts.snap +0 -124
- package/tests/views/__snapshots__/list-feed.test.ts.snap +0 -883
- package/tests/views/__snapshots__/lists.test.ts.snap +0 -650
- package/tests/views/__snapshots__/mute-lists.test.ts.snap +0 -705
- package/tests/views/__snapshots__/mutes.test.ts.snap +0 -353
- package/tests/views/__snapshots__/notifications.test.ts.snap +0 -3074
- package/tests/views/__snapshots__/posts.test.ts.snap +0 -1019
- package/tests/views/__snapshots__/profile.test.ts.snap +0 -811
- package/tests/views/__snapshots__/quotes.test.ts.snap +0 -445
- package/tests/views/__snapshots__/reposts.test.ts.snap +0 -112
- package/tests/views/__snapshots__/starter-packs.test.ts.snap +0 -836
- package/tests/views/__snapshots__/thread-v2.test.ts.snap +0 -1298
- package/tests/views/__snapshots__/thread.test.ts.snap +0 -2051
- package/tests/views/__snapshots__/threadgating.test.ts.snap +0 -189
- package/tests/views/__snapshots__/timeline.test.ts.snap +0 -7252
- package/tests/views/account-deactivation.test.ts +0 -81
- package/tests/views/actor-likes.test.ts +0 -138
- package/tests/views/actor-search.test.ts +0 -261
- package/tests/views/age-assurance-v2.test.ts +0 -823
- package/tests/views/age-assurance.test.ts +0 -479
- package/tests/views/author-feed.test.ts +0 -694
- package/tests/views/block-lists.test.ts +0 -661
- package/tests/views/blocks.test.ts +0 -889
- package/tests/views/bookmarks.test.ts +0 -345
- package/tests/views/drafts.test.ts +0 -430
- package/tests/views/feed-hidden-replies.test.ts +0 -243
- package/tests/views/feed-view-post.test.ts +0 -501
- package/tests/views/follows.test.ts +0 -372
- package/tests/views/get-config.test.ts +0 -64
- package/tests/views/get-suggested-onboarding-users.test.ts +0 -193
- package/tests/views/get-suggested-starter-packs.test.ts +0 -137
- package/tests/views/get-trends.test.ts +0 -141
- package/tests/views/internal-actor.test.ts +0 -127
- package/tests/views/known-followers.test.ts +0 -193
- package/tests/views/labeler-service.test.ts +0 -242
- package/tests/views/labels-needs-review.test.ts +0 -316
- package/tests/views/labels-takedown.test.ts +0 -247
- package/tests/views/likes.test.ts +0 -192
- package/tests/views/list-feed.test.ts +0 -195
- package/tests/views/lists.test.ts +0 -412
- package/tests/views/mute-lists.test.ts +0 -509
- package/tests/views/mutes.test.ts +0 -308
- package/tests/views/notifications.test.ts +0 -1581
- package/tests/views/post-search.test.ts +0 -200
- package/tests/views/posts-debug.test.ts +0 -79
- package/tests/views/posts.test.ts +0 -427
- package/tests/views/profile-debug.test.ts +0 -75
- package/tests/views/profile.test.ts +0 -795
- package/tests/views/quotes.test.ts +0 -133
- package/tests/views/reposts.test.ts +0 -112
- package/tests/views/starter-packs.test.ts +0 -395
- package/tests/views/suggestions.test.ts +0 -145
- package/tests/views/thread-v2.test.ts +0 -2005
- package/tests/views/thread.test.ts +0 -637
- package/tests/views/threadgating.test.ts +0 -843
- package/tests/views/timeline.test.ts +0 -328
- package/tests/views/verification.test.ts +0 -296
- package/tsconfig.build.json +0 -10
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.json +0 -7
- package/tsconfig.tests.json +0 -8
- package/vitest.config.ts +0 -10
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { mapDefined } from '@atproto/common'
|
|
2
|
-
import { AtUriString, DatetimeString, DidString } from '@atproto/syntax'
|
|
3
|
-
import { InvalidRequestError, Server } from '@atproto/xrpc-server'
|
|
4
|
-
import { ServerConfig } from '../../../../config.js'
|
|
5
|
-
import { AppContext } from '../../../../context.js'
|
|
6
|
-
import {
|
|
7
|
-
HydrateCtxWithViewer,
|
|
8
|
-
Hydrator,
|
|
9
|
-
} from '../../../../hydration/hydrator.js'
|
|
10
|
-
import { app } from '../../../../lexicons/index.js'
|
|
11
|
-
import {
|
|
12
|
-
HydrationFnInput,
|
|
13
|
-
PresentationFnInput,
|
|
14
|
-
RulesFnInput,
|
|
15
|
-
SkeletonFnInput,
|
|
16
|
-
createPipeline,
|
|
17
|
-
} from '../../../../pipeline.js'
|
|
18
|
-
import { Notification } from '../../../../proto/bsky_pb.js'
|
|
19
|
-
import { uriToDid as didFromUri } from '../../../../util/uris.js'
|
|
20
|
-
import { Views } from '../../../../views/index.js'
|
|
21
|
-
import { isPostRecordType } from '../../../../views/types.js'
|
|
22
|
-
import { resHeaders } from '../../../util.js'
|
|
23
|
-
|
|
24
|
-
export default function (server: Server, ctx: AppContext) {
|
|
25
|
-
const listNotifications = createPipeline(
|
|
26
|
-
skeleton,
|
|
27
|
-
hydration,
|
|
28
|
-
noBlockOrMutesOrNeedsFiltering,
|
|
29
|
-
presentation,
|
|
30
|
-
)
|
|
31
|
-
server.add(app.bsky.notification.listNotifications, {
|
|
32
|
-
auth: ctx.authVerifier.standard,
|
|
33
|
-
handler: async ({ params, auth, req }) => {
|
|
34
|
-
const viewer = auth.credentials.iss
|
|
35
|
-
const labelers = ctx.reqLabelers(req)
|
|
36
|
-
const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer })
|
|
37
|
-
const result = await listNotifications({ ...params, hydrateCtx }, ctx)
|
|
38
|
-
return {
|
|
39
|
-
encoding: 'application/json',
|
|
40
|
-
body: result,
|
|
41
|
-
headers: resHeaders({ labelers: hydrateCtx.labelers }),
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const paginateNotifications = async (opts: {
|
|
48
|
-
ctx: Context
|
|
49
|
-
priority: boolean
|
|
50
|
-
reasons?: string[]
|
|
51
|
-
cursor?: string
|
|
52
|
-
limit: number
|
|
53
|
-
viewer: string
|
|
54
|
-
}) => {
|
|
55
|
-
const { ctx, priority, reasons, limit, viewer } = opts
|
|
56
|
-
|
|
57
|
-
// if not filtering, then just pass through the response from dataplane
|
|
58
|
-
if (!reasons) {
|
|
59
|
-
const res = await ctx.hydrator.dataplane.getNotifications({
|
|
60
|
-
actorDid: viewer,
|
|
61
|
-
priority,
|
|
62
|
-
cursor: opts.cursor,
|
|
63
|
-
limit,
|
|
64
|
-
})
|
|
65
|
-
return {
|
|
66
|
-
notifications: res.notifications,
|
|
67
|
-
cursor: res.cursor,
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
let nextCursor: string | undefined = opts.cursor
|
|
72
|
-
let toReturn: Notification[] = []
|
|
73
|
-
const maxAttempts = 10
|
|
74
|
-
const attemptSize = Math.ceil(limit / 2)
|
|
75
|
-
for (let i = 0; i < maxAttempts; i++) {
|
|
76
|
-
const res = await ctx.hydrator.dataplane.getNotifications({
|
|
77
|
-
actorDid: viewer,
|
|
78
|
-
priority,
|
|
79
|
-
cursor: nextCursor,
|
|
80
|
-
limit,
|
|
81
|
-
})
|
|
82
|
-
const filtered = res.notifications.filter((notif) =>
|
|
83
|
-
reasons.includes(notif.reason),
|
|
84
|
-
)
|
|
85
|
-
toReturn = [...toReturn, ...filtered]
|
|
86
|
-
nextCursor = res.cursor ?? undefined
|
|
87
|
-
if (toReturn.length >= attemptSize || !nextCursor) {
|
|
88
|
-
break
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
notifications: toReturn,
|
|
93
|
-
cursor: nextCursor,
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Applies a configurable delay to the datetime string of a cursor,
|
|
99
|
-
* effectively allowing for a delay on listing the notifications.
|
|
100
|
-
* This is useful to allow time for services to process notifications
|
|
101
|
-
* before they are listed to the user.
|
|
102
|
-
*/
|
|
103
|
-
export const delayCursor = (
|
|
104
|
-
cursorStr: string | undefined,
|
|
105
|
-
delayMs: number,
|
|
106
|
-
): string => {
|
|
107
|
-
const nowMinusDelay = Date.now() - delayMs
|
|
108
|
-
if (cursorStr === undefined) return new Date(nowMinusDelay).toISOString()
|
|
109
|
-
const cursor = new Date(cursorStr).getTime()
|
|
110
|
-
if (isNaN(cursor)) return cursorStr
|
|
111
|
-
return new Date(Math.min(cursor, nowMinusDelay)).toISOString()
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const skeleton = async (
|
|
115
|
-
input: SkeletonFnInput<Context, Params>,
|
|
116
|
-
): Promise<SkeletonState> => {
|
|
117
|
-
const { params, ctx } = input
|
|
118
|
-
if (params.seenAt) {
|
|
119
|
-
throw new InvalidRequestError('The seenAt parameter is unsupported')
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const originalCursor = params.cursor
|
|
123
|
-
const delayedCursor = delayCursor(
|
|
124
|
-
originalCursor,
|
|
125
|
-
ctx.cfg.notificationsDelayMs,
|
|
126
|
-
)
|
|
127
|
-
const viewer = params.hydrateCtx.viewer
|
|
128
|
-
const priority = params.priority ?? (await getPriority(ctx, viewer))
|
|
129
|
-
const [res, lastSeenRes] = await Promise.all([
|
|
130
|
-
paginateNotifications({
|
|
131
|
-
ctx,
|
|
132
|
-
priority,
|
|
133
|
-
reasons: params.reasons,
|
|
134
|
-
cursor: delayedCursor,
|
|
135
|
-
limit: params.limit,
|
|
136
|
-
viewer,
|
|
137
|
-
}),
|
|
138
|
-
ctx.hydrator.dataplane.getNotificationSeen({
|
|
139
|
-
actorDid: viewer,
|
|
140
|
-
priority,
|
|
141
|
-
}),
|
|
142
|
-
])
|
|
143
|
-
// @NOTE for the first page of results if there's no last-seen time, consider top notification unread
|
|
144
|
-
// rather than all notifications. bit of a hack to be more graceful when seen times are out of sync.
|
|
145
|
-
let lastSeenDate = lastSeenRes.timestamp?.toDate()
|
|
146
|
-
if (!lastSeenDate && !originalCursor) {
|
|
147
|
-
lastSeenDate = res.notifications.at(0)?.timestamp?.toDate()
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
notifs: res.notifications,
|
|
151
|
-
cursor: res.cursor || undefined,
|
|
152
|
-
priority,
|
|
153
|
-
lastSeenNotifs: lastSeenDate
|
|
154
|
-
? (lastSeenDate.toISOString() as DatetimeString)
|
|
155
|
-
: undefined,
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const hydration = async (
|
|
160
|
-
input: HydrationFnInput<Context, Params, SkeletonState>,
|
|
161
|
-
) => {
|
|
162
|
-
const { skeleton, params, ctx } = input
|
|
163
|
-
return ctx.hydrator.hydrateNotifications(skeleton.notifs, params.hydrateCtx)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const noBlockOrMutesOrNeedsFiltering = (
|
|
167
|
-
input: RulesFnInput<Context, Params, SkeletonState>,
|
|
168
|
-
) => {
|
|
169
|
-
const { skeleton, hydration, ctx, params } = input
|
|
170
|
-
skeleton.notifs = skeleton.notifs.filter((item) => {
|
|
171
|
-
const uri = item.uri as AtUriString
|
|
172
|
-
const did = didFromUri(uri)
|
|
173
|
-
if (
|
|
174
|
-
ctx.views.viewerBlockExists(did, hydration) ||
|
|
175
|
-
ctx.views.viewerMuteExists(did, hydration)
|
|
176
|
-
) {
|
|
177
|
-
return false
|
|
178
|
-
}
|
|
179
|
-
// Filter out hidden replies only if the viewer owns
|
|
180
|
-
// the threadgate and they hid the reply.
|
|
181
|
-
if (item.reason === 'reply') {
|
|
182
|
-
const post = hydration.posts?.get(uri)
|
|
183
|
-
if (post) {
|
|
184
|
-
const rootPostUri = isPostRecordType(post.record)
|
|
185
|
-
? post.record.reply?.root.uri
|
|
186
|
-
: undefined
|
|
187
|
-
const isRootPostByViewer =
|
|
188
|
-
rootPostUri && didFromUri(rootPostUri) === params.hydrateCtx?.viewer
|
|
189
|
-
const isHiddenByThreadgate = isRootPostByViewer
|
|
190
|
-
? ctx.views.replyIsHiddenByThreadgate(uri, rootPostUri, hydration)
|
|
191
|
-
: false
|
|
192
|
-
if (isHiddenByThreadgate) {
|
|
193
|
-
return false
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
// Filter out notifications from users that have thread hide tags and are from people they
|
|
198
|
-
// are not following
|
|
199
|
-
if (
|
|
200
|
-
item.reason === 'reply' ||
|
|
201
|
-
item.reason === 'quote' ||
|
|
202
|
-
item.reason === 'mention'
|
|
203
|
-
) {
|
|
204
|
-
const post = hydration.posts?.get(uri)
|
|
205
|
-
if (post) {
|
|
206
|
-
for (const [tag] of post.tags.entries()) {
|
|
207
|
-
if (ctx.cfg.threadTagsHide.has(tag)) {
|
|
208
|
-
if (!hydration.profileViewers?.get(did)?.following) {
|
|
209
|
-
return false
|
|
210
|
-
} else {
|
|
211
|
-
break
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
// Filter out notifications from users that need review unless moots
|
|
218
|
-
if (
|
|
219
|
-
item.reason === 'reply' ||
|
|
220
|
-
item.reason === 'quote' ||
|
|
221
|
-
item.reason === 'mention' ||
|
|
222
|
-
item.reason === 'like' ||
|
|
223
|
-
item.reason === 'follow'
|
|
224
|
-
) {
|
|
225
|
-
if (!ctx.views.viewerSeesNeedsReview({ did, uri }, hydration)) {
|
|
226
|
-
return false
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return true
|
|
230
|
-
})
|
|
231
|
-
return skeleton
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const presentation = (
|
|
235
|
-
input: PresentationFnInput<Context, Params, SkeletonState>,
|
|
236
|
-
): app.bsky.notification.listNotifications.$OutputBody => {
|
|
237
|
-
const { skeleton, hydration, ctx } = input
|
|
238
|
-
const { notifs, lastSeenNotifs, cursor } = skeleton
|
|
239
|
-
const notifications = mapDefined(notifs, (notif) =>
|
|
240
|
-
ctx.views.notification(notif, lastSeenNotifs, hydration),
|
|
241
|
-
)
|
|
242
|
-
return {
|
|
243
|
-
notifications,
|
|
244
|
-
cursor,
|
|
245
|
-
priority: skeleton.priority,
|
|
246
|
-
seenAt: skeleton.lastSeenNotifs,
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
type Context = {
|
|
251
|
-
hydrator: Hydrator
|
|
252
|
-
views: Views
|
|
253
|
-
cfg: ServerConfig
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
type Params = app.bsky.notification.listNotifications.$Params & {
|
|
257
|
-
hydrateCtx: HydrateCtxWithViewer
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
type SkeletonState = {
|
|
261
|
-
notifs: Notification[]
|
|
262
|
-
priority: boolean
|
|
263
|
-
lastSeenNotifs?: DatetimeString
|
|
264
|
-
cursor?: string
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const getPriority = async (ctx: Context, did: DidString) => {
|
|
268
|
-
const actors = await ctx.hydrator.actor.getActors([did], {
|
|
269
|
-
skipCacheForDids: [did],
|
|
270
|
-
})
|
|
271
|
-
return !!actors.get(did)?.priorityNotifications
|
|
272
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { TID } from '@atproto/common'
|
|
2
|
-
import { InvalidRequestError, Server } from '@atproto/xrpc-server'
|
|
3
|
-
import { AppContext } from '../../../../context.js'
|
|
4
|
-
import { isActivitySubscriptionEnabled } from '../../../../hydration/util.js'
|
|
5
|
-
import { app } from '../../../../lexicons/index.js'
|
|
6
|
-
import { Namespaces } from '../../../../stash.js'
|
|
7
|
-
|
|
8
|
-
export default function (server: Server, ctx: AppContext) {
|
|
9
|
-
server.add(app.bsky.notification.putActivitySubscription, {
|
|
10
|
-
auth: ctx.authVerifier.standard,
|
|
11
|
-
handler: async ({ input, auth }) => {
|
|
12
|
-
const actorDid = auth.credentials.iss
|
|
13
|
-
const { subject, activitySubscription } = input.body
|
|
14
|
-
if (actorDid === subject) {
|
|
15
|
-
throw new InvalidRequestError('Cannot subscribe to own activity')
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const existingKey = await getExistingKey(ctx, actorDid, subject)
|
|
19
|
-
const enabled = isActivitySubscriptionEnabled(activitySubscription)
|
|
20
|
-
|
|
21
|
-
const stashInput = {
|
|
22
|
-
actorDid,
|
|
23
|
-
namespace:
|
|
24
|
-
Namespaces.AppBskyNotificationDefsSubjectActivitySubscription,
|
|
25
|
-
payload: {
|
|
26
|
-
subject,
|
|
27
|
-
activitySubscription,
|
|
28
|
-
},
|
|
29
|
-
key: existingKey ?? TID.nextStr(),
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (existingKey) {
|
|
33
|
-
if (enabled) {
|
|
34
|
-
await ctx.stashClient.update(stashInput)
|
|
35
|
-
} else {
|
|
36
|
-
await ctx.stashClient.delete(stashInput)
|
|
37
|
-
}
|
|
38
|
-
} else {
|
|
39
|
-
if (enabled) {
|
|
40
|
-
await ctx.stashClient.create(stashInput)
|
|
41
|
-
} else {
|
|
42
|
-
// no-op: subscription already doesn't exist
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
encoding: 'application/json',
|
|
48
|
-
body: {
|
|
49
|
-
subject,
|
|
50
|
-
activitySubscription: enabled ? activitySubscription : undefined,
|
|
51
|
-
},
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const getExistingKey = async (
|
|
58
|
-
ctx: AppContext,
|
|
59
|
-
actorDid: string,
|
|
60
|
-
subject: string,
|
|
61
|
-
): Promise<string | null> => {
|
|
62
|
-
const res = await ctx.dataplane.getActivitySubscriptionsByActorAndSubjects({
|
|
63
|
-
actorDid,
|
|
64
|
-
subjectDids: [subject],
|
|
65
|
-
})
|
|
66
|
-
const [existing] = res.subscriptions
|
|
67
|
-
const key = existing.key
|
|
68
|
-
return key || null
|
|
69
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Server } from '@atproto/xrpc-server'
|
|
2
|
-
import { AppContext } from '../../../../context.js'
|
|
3
|
-
import { app } from '../../../../lexicons/index.js'
|
|
4
|
-
|
|
5
|
-
export default function (server: Server, ctx: AppContext) {
|
|
6
|
-
server.add(app.bsky.notification.putPreferences, {
|
|
7
|
-
auth: ctx.authVerifier.standard,
|
|
8
|
-
handler: async ({ input, auth }) => {
|
|
9
|
-
const { priority } = input.body
|
|
10
|
-
const viewer = auth.credentials.iss
|
|
11
|
-
await ctx.bsyncClient.addNotifOperation({
|
|
12
|
-
actorDid: viewer,
|
|
13
|
-
priority,
|
|
14
|
-
})
|
|
15
|
-
},
|
|
16
|
-
})
|
|
17
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert'
|
|
2
|
-
import { Un$Typed } from '@atproto/lex'
|
|
3
|
-
import { Server, UpstreamFailureError } from '@atproto/xrpc-server'
|
|
4
|
-
import { AppContext } from '../../../../context.js'
|
|
5
|
-
import { app } from '../../../../lexicons/index.js'
|
|
6
|
-
import { GetNotificationPreferencesResponse } from '../../../../proto/bsky_pb.js'
|
|
7
|
-
import { Namespaces } from '../../../../stash.js'
|
|
8
|
-
import { DEFAULT_CHAT_PREFERENCE, protobufToLex } from './util.js'
|
|
9
|
-
|
|
10
|
-
export default function (server: Server, ctx: AppContext) {
|
|
11
|
-
server.add(app.bsky.notification.putPreferencesV2, {
|
|
12
|
-
auth: ctx.authVerifier.standard,
|
|
13
|
-
handler: async ({ auth, input }) => {
|
|
14
|
-
const actorDid = auth.credentials.iss
|
|
15
|
-
const preferences = await computePreferences(ctx, actorDid, input)
|
|
16
|
-
|
|
17
|
-
// Notification preferences are created automatically on the dataplane on signup, so we just update.
|
|
18
|
-
await ctx.stashClient.update({
|
|
19
|
-
actorDid,
|
|
20
|
-
namespace: Namespaces.AppBskyNotificationDefsPreferences,
|
|
21
|
-
key: 'self',
|
|
22
|
-
payload: preferences,
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
encoding: 'application/json',
|
|
27
|
-
body: {
|
|
28
|
-
preferences,
|
|
29
|
-
},
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const computePreferences = async (
|
|
36
|
-
ctx: AppContext,
|
|
37
|
-
actorDid: string,
|
|
38
|
-
input: app.bsky.notification.putPreferencesV2.$Input,
|
|
39
|
-
): Promise<Un$Typed<app.bsky.notification.defs.Preferences>> => {
|
|
40
|
-
let res: GetNotificationPreferencesResponse
|
|
41
|
-
try {
|
|
42
|
-
res = await ctx.dataplane.getNotificationPreferences({
|
|
43
|
-
dids: [actorDid],
|
|
44
|
-
})
|
|
45
|
-
} catch (err) {
|
|
46
|
-
throw new UpstreamFailureError(
|
|
47
|
-
'cannot get current notification preferences',
|
|
48
|
-
'NotificationPreferencesFailed',
|
|
49
|
-
{ cause: err },
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
assert(
|
|
54
|
-
res.preferences.length === 1,
|
|
55
|
-
`expected exactly one preferences entry, got ${res.preferences.length}`,
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
const currentPreferences = protobufToLex(res.preferences[0])
|
|
59
|
-
const preferences = { ...currentPreferences, ...input.body }
|
|
60
|
-
// NOTE: See the deprecation notice on the lexicon. This field returns a static default value and shouldn't be used.
|
|
61
|
-
// Use the chat.bsky.notification.defs#preferences type instead.
|
|
62
|
-
preferences.chat = DEFAULT_CHAT_PREFERENCE
|
|
63
|
-
return preferences
|
|
64
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
InvalidRequestError,
|
|
3
|
-
MethodNotImplementedError,
|
|
4
|
-
Server,
|
|
5
|
-
} from '@atproto/xrpc-server'
|
|
6
|
-
import { AppContext } from '../../../../context.js'
|
|
7
|
-
import { app } from '../../../../lexicons/index.js'
|
|
8
|
-
import { assertLexPlatform, lexPlatformToProtoPlatform } from './util.js'
|
|
9
|
-
|
|
10
|
-
export default function (server: Server, ctx: AppContext) {
|
|
11
|
-
server.add(app.bsky.notification.registerPush, {
|
|
12
|
-
auth: ctx.authVerifier.standard,
|
|
13
|
-
handler: async ({ auth, input }) => {
|
|
14
|
-
if (!ctx.courierClient) {
|
|
15
|
-
throw new MethodNotImplementedError(
|
|
16
|
-
'This service is not configured to support push token registration.',
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
const { token, platform, serviceDid, appId, ageRestricted } = input.body
|
|
20
|
-
const did = auth.credentials.iss
|
|
21
|
-
if (serviceDid !== auth.credentials.aud) {
|
|
22
|
-
throw new InvalidRequestError('Invalid serviceDid.')
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
assertLexPlatform(platform)
|
|
26
|
-
} catch (err) {
|
|
27
|
-
throw new InvalidRequestError(
|
|
28
|
-
'Unsupported platform: must be "ios", "android", or "web".',
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
await ctx.courierClient.registerDeviceToken({
|
|
32
|
-
did,
|
|
33
|
-
token,
|
|
34
|
-
platform: lexPlatformToProtoPlatform(platform),
|
|
35
|
-
appId,
|
|
36
|
-
ageRestricted,
|
|
37
|
-
})
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
InvalidRequestError,
|
|
3
|
-
MethodNotImplementedError,
|
|
4
|
-
Server,
|
|
5
|
-
} from '@atproto/xrpc-server'
|
|
6
|
-
import { AppContext } from '../../../../context.js'
|
|
7
|
-
import { app } from '../../../../lexicons/index.js'
|
|
8
|
-
import { assertLexPlatform, lexPlatformToProtoPlatform } from './util.js'
|
|
9
|
-
|
|
10
|
-
export default function (server: Server, ctx: AppContext) {
|
|
11
|
-
server.add(app.bsky.notification.unregisterPush, {
|
|
12
|
-
auth: ctx.authVerifier.standard,
|
|
13
|
-
handler: async ({ auth, input }) => {
|
|
14
|
-
if (!ctx.courierClient) {
|
|
15
|
-
throw new MethodNotImplementedError(
|
|
16
|
-
'This service is not configured to support push token registration.',
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
const { token, platform, serviceDid, appId } = input.body
|
|
20
|
-
const did = auth.credentials.iss
|
|
21
|
-
if (serviceDid !== auth.credentials.aud) {
|
|
22
|
-
throw new InvalidRequestError('Invalid serviceDid.')
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
assertLexPlatform(platform)
|
|
26
|
-
} catch (err) {
|
|
27
|
-
throw new InvalidRequestError(
|
|
28
|
-
'Unsupported platform: must be "ios", "android", or "web".',
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
await ctx.courierClient.unregisterDeviceToken({
|
|
32
|
-
did,
|
|
33
|
-
token,
|
|
34
|
-
platform: lexPlatformToProtoPlatform(platform),
|
|
35
|
-
appId,
|
|
36
|
-
})
|
|
37
|
-
},
|
|
38
|
-
})
|
|
39
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Struct, Timestamp } from '@bufbuild/protobuf'
|
|
2
|
-
// eslint-disable-next-line import/no-named-as-default-member
|
|
3
|
-
import murmur from 'murmurhash'
|
|
4
|
-
import { Server } from '@atproto/xrpc-server'
|
|
5
|
-
import { AppContext } from '../../../../context.js'
|
|
6
|
-
import { app } from '../../../../lexicons/index.js'
|
|
7
|
-
|
|
8
|
-
export default function (server: Server, ctx: AppContext) {
|
|
9
|
-
server.add(app.bsky.notification.updateSeen, {
|
|
10
|
-
auth: ctx.authVerifier.standard,
|
|
11
|
-
handler: async ({ input, auth }) => {
|
|
12
|
-
const viewer = auth.credentials.iss
|
|
13
|
-
const seenAt = new Date(input.body.seenAt)
|
|
14
|
-
// For now we keep separate seen times behind the scenes for priority, but treat them as a single seen time.
|
|
15
|
-
await Promise.all([
|
|
16
|
-
ctx.dataplane.updateNotificationSeen({
|
|
17
|
-
actorDid: viewer,
|
|
18
|
-
timestamp: Timestamp.fromDate(seenAt),
|
|
19
|
-
priority: false,
|
|
20
|
-
}),
|
|
21
|
-
ctx.dataplane.updateNotificationSeen({
|
|
22
|
-
actorDid: viewer,
|
|
23
|
-
timestamp: Timestamp.fromDate(seenAt),
|
|
24
|
-
priority: true,
|
|
25
|
-
}),
|
|
26
|
-
ctx.courierClient?.pushNotifications({
|
|
27
|
-
notifications: [
|
|
28
|
-
{
|
|
29
|
-
id: getNotifId(viewer, seenAt),
|
|
30
|
-
clientControlled: true,
|
|
31
|
-
recipientDid: viewer,
|
|
32
|
-
alwaysDeliver: false,
|
|
33
|
-
collapseKey: 'mark-read-generic',
|
|
34
|
-
timestamp: Timestamp.fromDate(new Date()),
|
|
35
|
-
additional: Struct.fromJson({
|
|
36
|
-
reason: 'mark-read-generic',
|
|
37
|
-
}),
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
}),
|
|
41
|
-
])
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getNotifId(viewer: string, seenAt: Date) {
|
|
47
|
-
const key = ['mark-read-generic', viewer, seenAt.getTime().toString()].join(
|
|
48
|
-
'::',
|
|
49
|
-
)
|
|
50
|
-
// eslint-disable-next-line import/no-named-as-default-member
|
|
51
|
-
return murmur.v3(key).toString(16)
|
|
52
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { app } from '../../../../lexicons/index.js'
|
|
2
|
-
import {
|
|
3
|
-
FilterableNotificationPreference,
|
|
4
|
-
NotificationInclude,
|
|
5
|
-
NotificationPreference,
|
|
6
|
-
NotificationPreferences,
|
|
7
|
-
} from '../../../../proto/bsky_pb.js'
|
|
8
|
-
import { AppPlatform } from '../../../../proto/courier_pb.js'
|
|
9
|
-
|
|
10
|
-
type DeepPartial<T> = T extends object
|
|
11
|
-
? {
|
|
12
|
-
[P in keyof T]?: DeepPartial<T[P]>
|
|
13
|
-
}
|
|
14
|
-
: T
|
|
15
|
-
|
|
16
|
-
const ensureChatPreference = (
|
|
17
|
-
p?: DeepPartial<app.bsky.notification.defs.ChatPreference>,
|
|
18
|
-
): app.bsky.notification.defs.ChatPreference => {
|
|
19
|
-
const includeValues = ['all', 'accepted']
|
|
20
|
-
return {
|
|
21
|
-
include:
|
|
22
|
-
typeof p?.include === 'string' && includeValues.includes(p.include)
|
|
23
|
-
? p.include
|
|
24
|
-
: 'all',
|
|
25
|
-
push: p?.push ?? true,
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const ensureFilterablePreference = (
|
|
30
|
-
p?: DeepPartial<app.bsky.notification.defs.FilterablePreference>,
|
|
31
|
-
): app.bsky.notification.defs.FilterablePreference => {
|
|
32
|
-
const includeValues = ['all', 'follows']
|
|
33
|
-
return {
|
|
34
|
-
include:
|
|
35
|
-
typeof p?.include === 'string' && includeValues.includes(p.include)
|
|
36
|
-
? p.include
|
|
37
|
-
: 'all',
|
|
38
|
-
list: p?.list ?? true,
|
|
39
|
-
push: p?.push ?? true,
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const ensurePreference = (
|
|
44
|
-
p?: DeepPartial<app.bsky.notification.defs.Preference>,
|
|
45
|
-
): app.bsky.notification.defs.Preference => {
|
|
46
|
-
return {
|
|
47
|
-
list: p?.list ?? true,
|
|
48
|
-
push: p?.push ?? true,
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const ensurePreferences = (
|
|
53
|
-
p: DeepPartial<app.bsky.notification.defs.Preferences>,
|
|
54
|
-
): app.bsky.notification.defs.Preferences => {
|
|
55
|
-
return {
|
|
56
|
-
chat: ensureChatPreference(p.chat),
|
|
57
|
-
follow: ensureFilterablePreference(p.follow),
|
|
58
|
-
like: ensureFilterablePreference(p.like),
|
|
59
|
-
likeViaRepost: ensureFilterablePreference(p.likeViaRepost),
|
|
60
|
-
mention: ensureFilterablePreference(p.mention),
|
|
61
|
-
quote: ensureFilterablePreference(p.quote),
|
|
62
|
-
reply: ensureFilterablePreference(p.reply),
|
|
63
|
-
repost: ensureFilterablePreference(p.repost),
|
|
64
|
-
repostViaRepost: ensureFilterablePreference(p.repostViaRepost),
|
|
65
|
-
starterpackJoined: ensurePreference(p.starterpackJoined),
|
|
66
|
-
subscribedPost: ensurePreference(p.subscribedPost),
|
|
67
|
-
unverified: ensurePreference(p.unverified),
|
|
68
|
-
verified: ensurePreference(p.verified),
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export const DEFAULT_CHAT_PREFERENCE: app.bsky.notification.defs.ChatPreference =
|
|
73
|
-
{
|
|
74
|
-
include: 'all',
|
|
75
|
-
push: true,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const protobufFilterablePreferenceToLex = (
|
|
79
|
-
p?: DeepPartial<FilterableNotificationPreference>,
|
|
80
|
-
): Partial<app.bsky.notification.defs.FilterablePreference> => {
|
|
81
|
-
return {
|
|
82
|
-
include: p?.include === NotificationInclude.FOLLOWS ? 'follows' : 'all',
|
|
83
|
-
list: p?.list?.enabled,
|
|
84
|
-
push: p?.push?.enabled,
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const protobufPreferenceToLex = (
|
|
89
|
-
p?: DeepPartial<NotificationPreference>,
|
|
90
|
-
): Partial<app.bsky.notification.defs.Preference> => {
|
|
91
|
-
return {
|
|
92
|
-
list: p?.list?.enabled,
|
|
93
|
-
push: p?.push?.enabled,
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export const protobufToLex = (
|
|
98
|
-
res: DeepPartial<NotificationPreferences>,
|
|
99
|
-
): app.bsky.notification.defs.Preferences => {
|
|
100
|
-
return ensurePreferences({
|
|
101
|
-
// NOTE: See the deprecation notice on the lexicon. This field returns a static default value and shouldn't be used.
|
|
102
|
-
// Use the chat.bsky.notification.defs#preferences type instead.
|
|
103
|
-
chat: DEFAULT_CHAT_PREFERENCE,
|
|
104
|
-
follow: protobufFilterablePreferenceToLex(res.follow),
|
|
105
|
-
like: protobufFilterablePreferenceToLex(res.like),
|
|
106
|
-
likeViaRepost: protobufFilterablePreferenceToLex(res.likeViaRepost),
|
|
107
|
-
mention: protobufFilterablePreferenceToLex(res.mention),
|
|
108
|
-
quote: protobufFilterablePreferenceToLex(res.quote),
|
|
109
|
-
reply: protobufFilterablePreferenceToLex(res.reply),
|
|
110
|
-
repost: protobufFilterablePreferenceToLex(res.repost),
|
|
111
|
-
repostViaRepost: protobufFilterablePreferenceToLex(res.repostViaRepost),
|
|
112
|
-
starterpackJoined: protobufPreferenceToLex(res.starterpackJoined),
|
|
113
|
-
subscribedPost: protobufPreferenceToLex(res.subscribedPost),
|
|
114
|
-
unverified: protobufPreferenceToLex(res.unverified),
|
|
115
|
-
verified: protobufPreferenceToLex(res.verified),
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
type LexPlatform = 'ios' | 'android' | 'web'
|
|
120
|
-
|
|
121
|
-
export function assertLexPlatform(
|
|
122
|
-
platform: string,
|
|
123
|
-
): asserts platform is LexPlatform {
|
|
124
|
-
if (platform !== 'ios' && platform !== 'android' && platform !== 'web') {
|
|
125
|
-
throw new Error('Unsupported platform: must be "ios", "android", or "web".')
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export const lexPlatformToProtoPlatform = (platform: string): AppPlatform =>
|
|
130
|
-
platform === 'ios'
|
|
131
|
-
? AppPlatform.IOS
|
|
132
|
-
: platform === 'android'
|
|
133
|
-
? AppPlatform.ANDROID
|
|
134
|
-
: AppPlatform.WEB
|