@atproto/api 0.11.0-next → 0.11.0
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 +23 -0
- package/README.md +41 -58
- package/definitions/labels.json +3 -60
- package/dist/agent.d.ts +11 -5
- package/dist/bsky-agent.d.ts +5 -3
- package/dist/client/lexicons.d.ts +34 -3
- package/dist/client/types/app/bsky/actor/defs.d.ts +7 -7
- package/dist/client/types/app/bsky/feed/defs.d.ts +1 -0
- package/dist/client/types/app/bsky/graph/defs.d.ts +3 -0
- package/dist/client/types/com/atproto/label/defs.d.ts +2 -0
- package/dist/const.d.ts +1 -1
- package/dist/index.js +581 -204
- package/dist/index.js.map +3 -3
- package/dist/mocker.d.ts +2 -1
- package/dist/moderation/const/labels.d.ts +3 -3
- package/dist/moderation/decision.d.ts +2 -0
- package/dist/moderation/index.d.ts +1 -0
- package/dist/moderation/mutewords.d.ts +8 -0
- package/dist/moderation/subjects/feed-generator.d.ts +1 -1
- package/dist/moderation/subjects/user-list.d.ts +1 -1
- package/dist/moderation/types.d.ts +22 -6
- package/dist/moderation/util.d.ts +3 -3
- package/dist/types.d.ts +3 -4
- package/docs/moderation.md +204 -95
- package/package.json +9 -9
- package/scripts/code/labels.mjs +2 -2
- package/src/agent.ts +61 -16
- package/src/bsky-agent.ts +190 -71
- package/src/client/lexicons.ts +37 -5
- package/src/client/types/app/bsky/actor/defs.ts +11 -11
- package/src/client/types/app/bsky/feed/defs.ts +1 -0
- package/src/client/types/app/bsky/graph/defs.ts +3 -0
- package/src/client/types/com/atproto/label/defs.ts +4 -0
- package/src/const.ts +1 -1
- package/src/mocker.ts +4 -0
- package/src/moderation/const/labels.ts +9 -72
- package/src/moderation/decision.ts +82 -36
- package/src/moderation/index.ts +5 -24
- package/src/moderation/mutewords.ts +125 -0
- package/src/moderation/subjects/feed-generator.ts +18 -4
- package/src/moderation/subjects/notification.ts +7 -1
- package/src/moderation/subjects/post.ts +260 -1
- package/src/moderation/subjects/user-list.ts +38 -4
- package/src/moderation/types.ts +51 -12
- package/src/moderation/util.ts +33 -16
- package/src/types.ts +7 -3
- package/tests/agent.test.ts +71 -5
- package/tests/bsky-agent.test.ts +150 -217
- package/tests/moderation-behaviors.test.ts +5 -60
- package/tests/moderation-custom-labels.test.ts +46 -71
- package/tests/moderation-mutewords.test.ts +691 -0
- package/tests/moderation-prefs.test.ts +157 -92
- package/tests/moderation-quoteposts.test.ts +277 -0
- package/tests/moderation.test.ts +302 -38
- package/tests/util/moderation-behavior.ts +3 -1
- package/dist/client/types/app/bsky/actor/createScene.d.ts +0 -32
- package/dist/client/types/app/bsky/actor/ref.d.ts +0 -28
- package/dist/client/types/app/bsky/actor/search.d.ts +0 -22
- package/dist/client/types/app/bsky/actor/searchActor.d.ts +0 -22
- package/dist/client/types/app/bsky/actor/searchActorTypeahead.d.ts +0 -20
- package/dist/client/types/app/bsky/actor/searchTypeahead.d.ts +0 -20
- package/dist/client/types/app/bsky/actor/updateProfile.d.ts +0 -47
- package/dist/client/types/app/bsky/feed/bookmarkFeed.d.ts +0 -17
- package/dist/client/types/app/bsky/feed/feedViewPost.d.ts +0 -28
- package/dist/client/types/app/bsky/feed/getBookmarkedFeeds.d.ts +0 -21
- package/dist/client/types/app/bsky/feed/getSavedFeeds.d.ts +0 -21
- package/dist/client/types/app/bsky/feed/getVotes.d.ts +0 -36
- package/dist/client/types/app/bsky/feed/saveFeed.d.ts +0 -17
- package/dist/client/types/app/bsky/feed/setVote.d.ts +0 -25
- package/dist/client/types/app/bsky/feed/trend.d.ts +0 -9
- package/dist/client/types/app/bsky/feed/unbookmarkFeed.d.ts +0 -17
- package/dist/client/types/app/bsky/feed/unsaveFeed.d.ts +0 -17
- package/dist/client/types/app/bsky/feed/vote.d.ts +0 -10
- package/dist/client/types/app/bsky/graph/assertCreator.d.ts +0 -1
- package/dist/client/types/app/bsky/graph/assertMember.d.ts +0 -1
- package/dist/client/types/app/bsky/graph/assertion.d.ts +0 -10
- package/dist/client/types/app/bsky/graph/confirmation.d.ts +0 -11
- package/dist/client/types/app/bsky/graph/getAssertions.d.ts +0 -48
- package/dist/client/types/app/bsky/graph/getMembers.d.ts +0 -36
- package/dist/client/types/app/bsky/graph/getMemberships.d.ts +0 -36
- package/dist/client/types/app/bsky/graph/mute.d.ts +0 -17
- package/dist/client/types/app/bsky/graph/unmute.d.ts +0 -17
- package/dist/client/types/app/bsky/moderation/defs.d.ts +0 -41
- package/dist/client/types/app/bsky/moderation/getService.d.ts +0 -16
- package/dist/client/types/app/bsky/moderation/getServices.d.ts +0 -23
- package/dist/client/types/app/bsky/moderation/service.d.ts +0 -14
- package/dist/client/types/app/bsky/notification/getCount.d.ts +0 -17
- package/dist/client/types/app/bsky/notification/list.d.ts +0 -35
- package/dist/client/types/app/bsky/system/actorScene.d.ts +0 -1
- package/dist/client/types/app/bsky/system/actorUser.d.ts +0 -1
- package/dist/client/types/app/bsky/system/declRef.d.ts +0 -8
- package/dist/client/types/app/bsky/system/declaration.d.ts +0 -7
- package/dist/client/types/app/bsky/unspecced/applyLabels.d.ts +0 -18
- package/dist/client/types/app/bsky/unspecced/getPopular.d.ts +0 -22
- package/dist/client/types/app/bsky/unspecced/getTimelineSkeleton.d.ts +0 -24
- package/dist/client/types/com/atproto/account/create.d.ts +0 -41
- package/dist/client/types/com/atproto/account/createInviteCode.d.ts +0 -22
- package/dist/client/types/com/atproto/account/delete.d.ts +0 -25
- package/dist/client/types/com/atproto/account/get.d.ts +0 -12
- package/dist/client/types/com/atproto/account/requestDelete.d.ts +0 -13
- package/dist/client/types/com/atproto/account/requestPasswordReset.d.ts +0 -17
- package/dist/client/types/com/atproto/account/resetPassword.d.ts +0 -24
- package/dist/client/types/com/atproto/admin/blob.d.ts +0 -37
- package/dist/client/types/com/atproto/admin/createCommunicationTemplate.d.ts +0 -23
- package/dist/client/types/com/atproto/admin/deleteCommunicationTemplate.d.ts +0 -17
- package/dist/client/types/com/atproto/admin/emitModerationEvent.d.ts +0 -33
- package/dist/client/types/com/atproto/admin/getInviteCodeUsage.d.ts +0 -29
- package/dist/client/types/com/atproto/admin/getModerationAction.d.ts +0 -16
- package/dist/client/types/com/atproto/admin/getModerationActions.d.ts +0 -22
- package/dist/client/types/com/atproto/admin/getModerationEvent.d.ts +0 -16
- package/dist/client/types/com/atproto/admin/getModerationReport.d.ts +0 -16
- package/dist/client/types/com/atproto/admin/getModerationReports.d.ts +0 -28
- package/dist/client/types/com/atproto/admin/getRecord.d.ts +0 -20
- package/dist/client/types/com/atproto/admin/getRepo.d.ts +0 -19
- package/dist/client/types/com/atproto/admin/getSubjectState.d.ts +0 -26
- package/dist/client/types/com/atproto/admin/getUserAccountInfo.d.ts +0 -16
- package/dist/client/types/com/atproto/admin/listCommunicationTemplates.d.ts +0 -18
- package/dist/client/types/com/atproto/admin/moderationAction.d.ts +0 -60
- package/dist/client/types/com/atproto/admin/moderationReport.d.ts +0 -37
- package/dist/client/types/com/atproto/admin/queryModerationEvents.d.ts +0 -35
- package/dist/client/types/com/atproto/admin/queryModerationStatuses.d.ts +0 -37
- package/dist/client/types/com/atproto/admin/rebaseRepo.d.ts +0 -24
- package/dist/client/types/com/atproto/admin/record.d.ts +0 -43
- package/dist/client/types/com/atproto/admin/repo.d.ts +0 -45
- package/dist/client/types/com/atproto/admin/resolveModerationReports.d.ts +0 -22
- package/dist/client/types/com/atproto/admin/reverseModerationAction.d.ts +0 -22
- package/dist/client/types/com/atproto/admin/searchRepos.d.ts +0 -23
- package/dist/client/types/com/atproto/admin/takeModerationAction.d.ts +0 -34
- package/dist/client/types/com/atproto/admin/updateCommunicationTemplate.d.ts +0 -25
- package/dist/client/types/com/atproto/admin/updateSubjectState.d.ts +0 -32
- package/dist/client/types/com/atproto/blob/upload.d.ts +0 -19
- package/dist/client/types/com/atproto/handle/resolve.d.ts +0 -18
- package/dist/client/types/com/atproto/handle/update.d.ts +0 -17
- package/dist/client/types/com/atproto/repo/batchWrite.d.ts +0 -46
- package/dist/client/types/com/atproto/repo/describe.d.ts +0 -22
- package/dist/client/types/com/atproto/repo/rebaseRepo.d.ts +0 -24
- package/dist/client/types/com/atproto/repo/recordRef.d.ts +0 -8
- package/dist/client/types/com/atproto/repo/repoRef.d.ts +0 -7
- package/dist/client/types/com/atproto/repo/uploadRepo.d.ts +0 -19
- package/dist/client/types/com/atproto/report/create.d.ts +0 -39
- package/dist/client/types/com/atproto/report/reasonType.d.ts +0 -3
- package/dist/client/types/com/atproto/report/subject.d.ts +0 -23
- package/dist/client/types/com/atproto/server/getAccountsConfig.d.ts +0 -27
- package/dist/client/types/com/atproto/server/getUserInviteCodes.d.ts +0 -31
- package/dist/client/types/com/atproto/session/create.d.ts +0 -29
- package/dist/client/types/com/atproto/session/delete.d.ts +0 -13
- package/dist/client/types/com/atproto/session/get.d.ts +0 -18
- package/dist/client/types/com/atproto/session/refresh.d.ts +0 -24
- package/dist/client/types/com/atproto/sync/getCommitPath.d.ts +0 -20
- package/dist/client/types/com/atproto/sync/getCurrent.d.ts +0 -22
- package/dist/client/types/com/atproto/sync/getRoot.d.ts +0 -21
- package/dist/client/types/com/atproto/sync/importRepo.d.ts +0 -16
- package/dist/client/types/com/atproto/sync/subscribeAllRepos.d.ts +0 -9
- package/dist/client/types/com/atproto/sync/updateRepo.d.ts +0 -15
- package/dist/client/types/com/atproto/temp/importRepo.d.ts +0 -16
- package/dist/client/types/com/atproto/temp/pushBlob.d.ts +0 -15
- package/dist/client/types/com/atproto/temp/transferAccount.d.ts +0 -48
- package/dist/client/types/com/atproto/temp/upgradeRepoVersion.d.ts +0 -18
- package/dist/moderation/accumulator.d.ts +0 -16
- package/dist/moderation/const/label-groups.d.ts +0 -2
- package/dist/moderation/subjects/quoted-post.d.ts +0 -6
- package/dist/session.d.ts +0 -42
- package/dist/src/client/index.d.ts +0 -462
- package/dist/src/client/lexicons.d.ts +0 -2910
- package/dist/src/client/schemas.d.ts +0 -17
- package/dist/src/client/types/app/bsky/actor/createScene.d.ts +0 -32
- package/dist/src/client/types/app/bsky/actor/getProfile.d.ts +0 -36
- package/dist/src/client/types/app/bsky/actor/getSuggestions.d.ts +0 -36
- package/dist/src/client/types/app/bsky/actor/profile.d.ts +0 -15
- package/dist/src/client/types/app/bsky/actor/ref.d.ts +0 -14
- package/dist/src/client/types/app/bsky/actor/search.d.ts +0 -32
- package/dist/src/client/types/app/bsky/actor/searchTypeahead.d.ts +0 -28
- package/dist/src/client/types/app/bsky/actor/updateProfile.d.ts +0 -48
- package/dist/src/client/types/app/bsky/badge.d.ts +0 -22
- package/dist/src/client/types/app/bsky/badgeAccept.d.ts +0 -11
- package/dist/src/client/types/app/bsky/badgeOffer.d.ts +0 -11
- package/dist/src/client/types/app/bsky/declaration.d.ts +0 -6
- package/dist/src/client/types/app/bsky/embed/external.d.ts +0 -26
- package/dist/src/client/types/app/bsky/embed/images.d.ts +0 -23
- package/dist/src/client/types/app/bsky/feed/embed.d.ts +0 -36
- package/dist/src/client/types/app/bsky/feed/feedViewPost.d.ts +0 -26
- package/dist/src/client/types/app/bsky/feed/getAuthorFeed.d.ts +0 -22
- package/dist/src/client/types/app/bsky/feed/getPostThread.d.ts +0 -43
- package/dist/src/client/types/app/bsky/feed/getRepostedBy.d.ts +0 -35
- package/dist/src/client/types/app/bsky/feed/getTimeline.d.ts +0 -22
- package/dist/src/client/types/app/bsky/feed/getVotes.d.ts +0 -33
- package/dist/src/client/types/app/bsky/feed/mediaEmbed.d.ts +0 -18
- package/dist/src/client/types/app/bsky/feed/post.d.ts +0 -54
- package/dist/src/client/types/app/bsky/feed/repost.d.ts +0 -6
- package/dist/src/client/types/app/bsky/feed/setVote.d.ts +0 -25
- package/dist/src/client/types/app/bsky/feed/trend.d.ts +0 -6
- package/dist/src/client/types/app/bsky/feed/vote.d.ts +0 -7
- package/dist/src/client/types/app/bsky/follow.d.ts +0 -9
- package/dist/src/client/types/app/bsky/getAuthorFeed.d.ts +0 -56
- package/dist/src/client/types/app/bsky/getBadgeMembers.d.ts +0 -29
- package/dist/src/client/types/app/bsky/getHomeFeed.d.ts +0 -56
- package/dist/src/client/types/app/bsky/getLikedBy.d.ts +0 -29
- package/dist/src/client/types/app/bsky/getNotificationCount.d.ts +0 -16
- package/dist/src/client/types/app/bsky/getNotifications.d.ts +0 -33
- package/dist/src/client/types/app/bsky/getPostThread.d.ts +0 -55
- package/dist/src/client/types/app/bsky/getProfile.d.ts +0 -26
- package/dist/src/client/types/app/bsky/getRepostedBy.d.ts +0 -29
- package/dist/src/client/types/app/bsky/getTimeline.d.ts +0 -56
- package/dist/src/client/types/app/bsky/getUserFollowers.d.ts +0 -31
- package/dist/src/client/types/app/bsky/getUserFollows.d.ts +0 -31
- package/dist/src/client/types/app/bsky/getUsersSearch.d.ts +0 -26
- package/dist/src/client/types/app/bsky/getUsersTypeahead.d.ts +0 -22
- package/dist/src/client/types/app/bsky/graph/assertCreator.d.ts +0 -1
- package/dist/src/client/types/app/bsky/graph/assertMember.d.ts +0 -1
- package/dist/src/client/types/app/bsky/graph/assertion.d.ts +0 -7
- package/dist/src/client/types/app/bsky/graph/confirmation.d.ts +0 -8
- package/dist/src/client/types/app/bsky/graph/follow.d.ts +0 -6
- package/dist/src/client/types/app/bsky/graph/getAssertions.d.ts +0 -43
- package/dist/src/client/types/app/bsky/graph/getFollowers.d.ts +0 -34
- package/dist/src/client/types/app/bsky/graph/getFollows.d.ts +0 -33
- package/dist/src/client/types/app/bsky/graph/getMembers.d.ts +0 -33
- package/dist/src/client/types/app/bsky/graph/getMemberships.d.ts +0 -33
- package/dist/src/client/types/app/bsky/invite.d.ts +0 -10
- package/dist/src/client/types/app/bsky/inviteAccept.d.ts +0 -14
- package/dist/src/client/types/app/bsky/like.d.ts +0 -10
- package/dist/src/client/types/app/bsky/mediaEmbed.d.ts +0 -15
- package/dist/src/client/types/app/bsky/notification/getCount.d.ts +0 -17
- package/dist/src/client/types/app/bsky/notification/list.d.ts +0 -32
- package/dist/src/client/types/app/bsky/notification/updateSeen.d.ts +0 -17
- package/dist/src/client/types/app/bsky/post.d.ts +0 -23
- package/dist/src/client/types/app/bsky/postNotificationsSeen.d.ts +0 -20
- package/dist/src/client/types/app/bsky/profile.d.ts +0 -5
- package/dist/src/client/types/app/bsky/repost.d.ts +0 -10
- package/dist/src/client/types/app/bsky/system/actorScene.d.ts +0 -1
- package/dist/src/client/types/app/bsky/system/actorUser.d.ts +0 -1
- package/dist/src/client/types/app/bsky/system/declRef.d.ts +0 -5
- package/dist/src/client/types/app/bsky/system/declaration.d.ts +0 -4
- package/dist/src/client/types/app/bsky/updateProfile.d.ts +0 -23
- package/dist/src/client/types/com/atproto/account/create.d.ts +0 -41
- package/dist/src/client/types/com/atproto/account/createInviteCode.d.ts +0 -22
- package/dist/src/client/types/com/atproto/account/delete.d.ts +0 -13
- package/dist/src/client/types/com/atproto/account/get.d.ts +0 -12
- package/dist/src/client/types/com/atproto/account/requestPasswordReset.d.ts +0 -17
- package/dist/src/client/types/com/atproto/account/resetPassword.d.ts +0 -24
- package/dist/src/client/types/com/atproto/blob/upload.d.ts +0 -19
- package/dist/src/client/types/com/atproto/createAccount.d.ts +0 -40
- package/dist/src/client/types/com/atproto/createInviteCode.d.ts +0 -20
- package/dist/src/client/types/com/atproto/createSession.d.ts +0 -24
- package/dist/src/client/types/com/atproto/data/uploadFile.d.ts +0 -19
- package/dist/src/client/types/com/atproto/deleteAccount.d.ts +0 -20
- package/dist/src/client/types/com/atproto/deleteSession.d.ts +0 -17
- package/dist/src/client/types/com/atproto/getAccount.d.ts +0 -16
- package/dist/src/client/types/com/atproto/getAccountsConfig.d.ts +0 -17
- package/dist/src/client/types/com/atproto/getSession.d.ts +0 -17
- package/dist/src/client/types/com/atproto/handle/resolve.d.ts +0 -18
- package/dist/src/client/types/com/atproto/refreshSession.d.ts +0 -20
- package/dist/src/client/types/com/atproto/repo/batchWrite.d.ts +0 -39
- package/dist/src/client/types/com/atproto/repo/createRecord.d.ts +0 -26
- package/dist/src/client/types/com/atproto/repo/deleteRecord.d.ts +0 -19
- package/dist/src/client/types/com/atproto/repo/describe.d.ts +0 -22
- package/dist/src/client/types/com/atproto/repo/getRecord.d.ts +0 -23
- package/dist/src/client/types/com/atproto/repo/listRecords.d.ts +0 -30
- package/dist/src/client/types/com/atproto/repo/putRecord.d.ts +0 -27
- package/dist/src/client/types/com/atproto/repo/strongRef.d.ts +0 -5
- package/dist/src/client/types/com/atproto/repoBatchWrite.d.ts +0 -36
- package/dist/src/client/types/com/atproto/repoCreateRecord.d.ts +0 -24
- package/dist/src/client/types/com/atproto/repoDeleteRecord.d.ts +0 -18
- package/dist/src/client/types/com/atproto/repoDescribe.d.ts +0 -21
- package/dist/src/client/types/com/atproto/repoGetRecord.d.ts +0 -22
- package/dist/src/client/types/com/atproto/repoListRecords.d.ts +0 -27
- package/dist/src/client/types/com/atproto/repoPutRecord.d.ts +0 -25
- package/dist/src/client/types/com/atproto/requestAccountPasswordReset.d.ts +0 -19
- package/dist/src/client/types/com/atproto/resetAccountPassword.d.ts +0 -26
- package/dist/src/client/types/com/atproto/resolveHandle.d.ts +0 -17
- package/dist/src/client/types/com/atproto/resolveName.d.ts +0 -17
- package/dist/src/client/types/com/atproto/server/getAccountsConfig.d.ts +0 -24
- package/dist/src/client/types/com/atproto/session/create.d.ts +0 -26
- package/dist/src/client/types/com/atproto/session/delete.d.ts +0 -13
- package/dist/src/client/types/com/atproto/session/get.d.ts +0 -18
- package/dist/src/client/types/com/atproto/session/refresh.d.ts +0 -21
- package/dist/src/client/types/com/atproto/sync/getRepo.d.ts +0 -15
- package/dist/src/client/types/com/atproto/sync/getRoot.d.ts +0 -18
- package/dist/src/client/types/com/atproto/sync/updateRepo.d.ts +0 -15
- package/dist/src/client/types/com/atproto/syncGetRepo.d.ts +0 -15
- package/dist/src/client/types/com/atproto/syncGetRoot.d.ts +0 -17
- package/dist/src/client/types/com/atproto/syncUpdateRepo.d.ts +0 -15
- package/dist/src/index.d.ts +0 -4
- package/dist/src/schemas.d.ts +0 -19
- package/dist/src/session.d.ts +0 -42
- package/dist/src/types/app/bsky/acceptedBadge.d.ts +0 -10
- package/dist/src/types/app/bsky/badge.d.ts +0 -22
- package/dist/src/types/app/bsky/badgeAccept.d.ts +0 -11
- package/dist/src/types/app/bsky/badgeOffer.d.ts +0 -11
- package/dist/src/types/app/bsky/declaration.d.ts +0 -6
- package/dist/src/types/app/bsky/follow.d.ts +0 -9
- package/dist/src/types/app/bsky/getAuthorFeed.d.ts +0 -56
- package/dist/src/types/app/bsky/getBadgeMembers.d.ts +0 -29
- package/dist/src/types/app/bsky/getHomeFeed.d.ts +0 -56
- package/dist/src/types/app/bsky/getLikedBy.d.ts +0 -29
- package/dist/src/types/app/bsky/getNotificationCount.d.ts +0 -16
- package/dist/src/types/app/bsky/getNotifications.d.ts +0 -33
- package/dist/src/types/app/bsky/getPostThread.d.ts +0 -55
- package/dist/src/types/app/bsky/getProfile.d.ts +0 -42
- package/dist/src/types/app/bsky/getRepostedBy.d.ts +0 -29
- package/dist/src/types/app/bsky/getUserFollowers.d.ts +0 -31
- package/dist/src/types/app/bsky/getUserFollows.d.ts +0 -31
- package/dist/src/types/app/bsky/getUsersSearch.d.ts +0 -26
- package/dist/src/types/app/bsky/getUsersTypeahead.d.ts +0 -22
- package/dist/src/types/app/bsky/invite.d.ts +0 -10
- package/dist/src/types/app/bsky/inviteAccept.d.ts +0 -14
- package/dist/src/types/app/bsky/like.d.ts +0 -10
- package/dist/src/types/app/bsky/mediaEmbed.d.ts +0 -15
- package/dist/src/types/app/bsky/post.d.ts +0 -23
- package/dist/src/types/app/bsky/postNotificationsSeen.d.ts +0 -19
- package/dist/src/types/app/bsky/profile.d.ts +0 -11
- package/dist/src/types/app/bsky/repost.d.ts +0 -10
- package/dist/src/types/app/bsky/updateProfile.d.ts +0 -27
- package/dist/src/types/com/atproto/createAccount.d.ts +0 -39
- package/dist/src/types/com/atproto/createInviteCode.d.ts +0 -19
- package/dist/src/types/com/atproto/createSession.d.ts +0 -23
- package/dist/src/types/com/atproto/deleteAccount.d.ts +0 -19
- package/dist/src/types/com/atproto/deleteSession.d.ts +0 -16
- package/dist/src/types/com/atproto/getAccount.d.ts +0 -19
- package/dist/src/types/com/atproto/getAccountsConfig.d.ts +0 -17
- package/dist/src/types/com/atproto/getSession.d.ts +0 -17
- package/dist/src/types/com/atproto/refreshSession.d.ts +0 -19
- package/dist/src/types/com/atproto/repoBatchWrite.d.ts +0 -35
- package/dist/src/types/com/atproto/repoCreateRecord.d.ts +0 -23
- package/dist/src/types/com/atproto/repoDeleteRecord.d.ts +0 -15
- package/dist/src/types/com/atproto/repoDescribe.d.ts +0 -21
- package/dist/src/types/com/atproto/repoGetRecord.d.ts +0 -22
- package/dist/src/types/com/atproto/repoListRecords.d.ts +0 -27
- package/dist/src/types/com/atproto/repoPutRecord.d.ts +0 -24
- package/dist/src/types/com/atproto/requestAccountPasswordReset.d.ts +0 -18
- package/dist/src/types/com/atproto/resetAccountPassword.d.ts +0 -25
- package/dist/src/types/com/atproto/resolveName.d.ts +0 -17
- package/dist/src/types/com/atproto/syncGetRepo.d.ts +0 -15
- package/dist/src/types/com/atproto/syncGetRoot.d.ts +0 -17
- package/dist/src/types/com/atproto/syncUpdateRepo.d.ts +0 -14
- package/dist/src/types/todo/adx/createAccount.d.ts +0 -36
- package/dist/src/types/todo/adx/createInviteCode.d.ts +0 -19
- package/dist/src/types/todo/adx/createSession.d.ts +0 -22
- package/dist/src/types/todo/adx/deleteAccount.d.ts +0 -19
- package/dist/src/types/todo/adx/deleteSession.d.ts +0 -19
- package/dist/src/types/todo/adx/getAccount.d.ts +0 -19
- package/dist/src/types/todo/adx/getAccountsConfig.d.ts +0 -17
- package/dist/src/types/todo/adx/getSession.d.ts +0 -17
- package/dist/src/types/todo/adx/repoBatchWrite.d.ts +0 -34
- package/dist/src/types/todo/adx/repoCreateRecord.d.ts +0 -22
- package/dist/src/types/todo/adx/repoDeleteRecord.d.ts +0 -15
- package/dist/src/types/todo/adx/repoDescribe.d.ts +0 -21
- package/dist/src/types/todo/adx/repoGetRecord.d.ts +0 -20
- package/dist/src/types/todo/adx/repoListRecords.d.ts +0 -25
- package/dist/src/types/todo/adx/repoPutRecord.d.ts +0 -23
- package/dist/src/types/todo/adx/requestAccountPasswordReset.d.ts +0 -18
- package/dist/src/types/todo/adx/resetAccountPassword.d.ts +0 -25
- package/dist/src/types/todo/adx/resolveName.d.ts +0 -17
- package/dist/src/types/todo/adx/syncGetRepo.d.ts +0 -15
- package/dist/src/types/todo/adx/syncGetRoot.d.ts +0 -17
- package/dist/src/types/todo/adx/syncUpdateRepo.d.ts +0 -14
- package/dist/src/types/todo/social/badge.d.ts +0 -23
- package/dist/src/types/todo/social/follow.d.ts +0 -5
- package/dist/src/types/todo/social/getAuthorFeed.d.ts +0 -55
- package/dist/src/types/todo/social/getFeed.d.ts +0 -55
- package/dist/src/types/todo/social/getHomeFeed.d.ts +0 -55
- package/dist/src/types/todo/social/getLikedBy.d.ts +0 -26
- package/dist/src/types/todo/social/getNotificationCount.d.ts +0 -16
- package/dist/src/types/todo/social/getNotifications.d.ts +0 -31
- package/dist/src/types/todo/social/getPostThread.d.ts +0 -54
- package/dist/src/types/todo/social/getProfile.d.ts +0 -40
- package/dist/src/types/todo/social/getRepostedBy.d.ts +0 -26
- package/dist/src/types/todo/social/getUserFollowers.d.ts +0 -30
- package/dist/src/types/todo/social/getUserFollows.d.ts +0 -30
- package/dist/src/types/todo/social/like.d.ts +0 -5
- package/dist/src/types/todo/social/mediaEmbed.d.ts +0 -15
- package/dist/src/types/todo/social/post.d.ts +0 -18
- package/dist/src/types/todo/social/postNotificationsSeen.d.ts +0 -19
- package/dist/src/types/todo/social/profile.d.ts +0 -10
- package/dist/src/types/todo/social/repost.d.ts +0 -5
- package/docs/labels.md +0 -108
- package/scripts/docs/labels.mjs +0 -87
- package/scripts/generate-docs.mjs +0 -3
package/src/agent.ts
CHANGED
|
@@ -17,9 +17,12 @@ import {
|
|
|
17
17
|
AtpAgentGlobalOpts,
|
|
18
18
|
AtpPersistSessionHandler,
|
|
19
19
|
AtpAgentOpts,
|
|
20
|
+
AtprotoServiceType,
|
|
20
21
|
} from './types'
|
|
21
|
-
import {
|
|
22
|
+
import { BSKY_LABELER_DID } from './const'
|
|
22
23
|
|
|
24
|
+
const MAX_MOD_AUTHORITIES = 3
|
|
25
|
+
const MAX_LABELERS = 10
|
|
23
26
|
const REFRESH_SESSION = 'com.atproto.server.refreshSession'
|
|
24
27
|
|
|
25
28
|
/**
|
|
@@ -30,16 +33,13 @@ export class AtpAgent {
|
|
|
30
33
|
service: URL
|
|
31
34
|
api: AtpServiceClient
|
|
32
35
|
session?: AtpSessionData
|
|
33
|
-
labelersHeader: string[] = [
|
|
36
|
+
labelersHeader: string[] = []
|
|
37
|
+
proxyHeader: string | undefined
|
|
38
|
+
pdsUrl: URL | undefined // The PDS URL, driven by the did doc. May be undefined.
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
pdsUrl: URL | undefined
|
|
39
|
-
|
|
40
|
-
private _baseClient: AtpBaseClient
|
|
41
|
-
private _persistSession?: AtpPersistSessionHandler
|
|
42
|
-
private _refreshSessionPromise: Promise<void> | undefined
|
|
40
|
+
protected _baseClient: AtpBaseClient
|
|
41
|
+
protected _persistSession?: AtpPersistSessionHandler
|
|
42
|
+
protected _refreshSessionPromise: Promise<void> | undefined
|
|
43
43
|
|
|
44
44
|
get com() {
|
|
45
45
|
return this.api.com
|
|
@@ -50,11 +50,21 @@ export class AtpAgent {
|
|
|
50
50
|
*/
|
|
51
51
|
static fetch: AtpAgentFetchHandler | undefined = defaultFetchHandler
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* The labelers to be used across all requests with the takedown capability
|
|
55
|
+
*/
|
|
56
|
+
static appLabelers: string[] = [BSKY_LABELER_DID]
|
|
57
|
+
|
|
53
58
|
/**
|
|
54
59
|
* Configures the API globally.
|
|
55
60
|
*/
|
|
56
61
|
static configure(opts: AtpAgentGlobalOpts) {
|
|
57
|
-
|
|
62
|
+
if (opts.fetch) {
|
|
63
|
+
AtpAgent.fetch = opts.fetch
|
|
64
|
+
}
|
|
65
|
+
if (opts.appLabelers) {
|
|
66
|
+
AtpAgent.appLabelers = opts.appLabelers
|
|
67
|
+
}
|
|
58
68
|
}
|
|
59
69
|
|
|
60
70
|
constructor(opts: AtpAgentOpts) {
|
|
@@ -68,6 +78,27 @@ export class AtpAgent {
|
|
|
68
78
|
this.api = this._baseClient.service(opts.service)
|
|
69
79
|
}
|
|
70
80
|
|
|
81
|
+
clone() {
|
|
82
|
+
const inst = new AtpAgent({
|
|
83
|
+
service: this.service,
|
|
84
|
+
})
|
|
85
|
+
this.copyInto(inst)
|
|
86
|
+
return inst
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
copyInto(inst: AtpAgent) {
|
|
90
|
+
inst.session = this.session
|
|
91
|
+
inst.labelersHeader = this.labelersHeader
|
|
92
|
+
inst.proxyHeader = this.proxyHeader
|
|
93
|
+
inst.pdsUrl = this.pdsUrl
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
withProxy(serviceType: AtprotoServiceType, did: string) {
|
|
97
|
+
const inst = this.clone()
|
|
98
|
+
inst.configureProxyHeader(serviceType, did)
|
|
99
|
+
return inst
|
|
100
|
+
}
|
|
101
|
+
|
|
71
102
|
/**
|
|
72
103
|
* Is there any active session?
|
|
73
104
|
*/
|
|
@@ -92,6 +123,15 @@ export class AtpAgent {
|
|
|
92
123
|
this.labelersHeader = labelerDids
|
|
93
124
|
}
|
|
94
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Configures the atproto-proxy header to be applied on requests
|
|
128
|
+
*/
|
|
129
|
+
configureProxyHeader(serviceType: AtprotoServiceType, did: string) {
|
|
130
|
+
if (did.startsWith('did:')) {
|
|
131
|
+
this.proxyHeader = `${did}#${serviceType}`
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
95
135
|
/**
|
|
96
136
|
* Create a new account and hydrate its session in this agent.
|
|
97
137
|
*/
|
|
@@ -212,15 +252,20 @@ export class AtpAgent {
|
|
|
212
252
|
authorization: `Bearer ${this.session.accessJwt}`,
|
|
213
253
|
}
|
|
214
254
|
}
|
|
215
|
-
if (this.
|
|
255
|
+
if (this.proxyHeader) {
|
|
216
256
|
reqHeaders = {
|
|
217
257
|
...reqHeaders,
|
|
218
|
-
'atproto-
|
|
219
|
-
.filter((str) => str.startsWith('did:'))
|
|
220
|
-
.slice(0, 10)
|
|
221
|
-
.join(','),
|
|
258
|
+
'atproto-proxy': this.proxyHeader,
|
|
222
259
|
}
|
|
223
260
|
}
|
|
261
|
+
reqHeaders = {
|
|
262
|
+
...reqHeaders,
|
|
263
|
+
'atproto-accept-labelers': AtpAgent.appLabelers
|
|
264
|
+
.map((str) => `${str};redact`)
|
|
265
|
+
.concat(this.labelersHeader.filter((str) => str.startsWith('did:')))
|
|
266
|
+
.slice(0, MAX_LABELERS)
|
|
267
|
+
.join(', '),
|
|
268
|
+
}
|
|
224
269
|
return reqHeaders
|
|
225
270
|
}
|
|
226
271
|
|
package/src/bsky-agent.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
AppBskyFeedPost,
|
|
5
5
|
AppBskyActorProfile,
|
|
6
6
|
AppBskyActorDefs,
|
|
7
|
+
AppBskyLabelerDefs,
|
|
7
8
|
ComAtprotoRepoPutRecord,
|
|
8
9
|
} from './client'
|
|
9
10
|
import {
|
|
@@ -12,10 +13,14 @@ import {
|
|
|
12
13
|
BskyThreadViewPreference,
|
|
13
14
|
BskyInterestsPreference,
|
|
14
15
|
} from './types'
|
|
15
|
-
import {
|
|
16
|
-
|
|
16
|
+
import {
|
|
17
|
+
InterpretedLabelValueDefinition,
|
|
18
|
+
LabelPreference,
|
|
19
|
+
ModerationPrefs,
|
|
20
|
+
} from './moderation/types'
|
|
17
21
|
import { DEFAULT_LABEL_SETTINGS } from './moderation/const/labels'
|
|
18
22
|
import { sanitizeMutedWordValue } from './util'
|
|
23
|
+
import { interpretLabelValueDefinitions } from './moderation'
|
|
19
24
|
|
|
20
25
|
const FEED_VIEW_PREF_DEFAULTS = {
|
|
21
26
|
hideReplies: false,
|
|
@@ -39,6 +44,14 @@ declare global {
|
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
export class BskyAgent extends AtpAgent {
|
|
47
|
+
clone() {
|
|
48
|
+
const inst = new BskyAgent({
|
|
49
|
+
service: this.service,
|
|
50
|
+
})
|
|
51
|
+
this.copyInto(inst)
|
|
52
|
+
return inst
|
|
53
|
+
}
|
|
54
|
+
|
|
42
55
|
get app() {
|
|
43
56
|
return this.api.app
|
|
44
57
|
}
|
|
@@ -103,6 +116,37 @@ export class BskyAgent extends AtpAgent {
|
|
|
103
116
|
getLabelers: typeof this.api.app.bsky.labeler.getServices = (params, opts) =>
|
|
104
117
|
this.api.app.bsky.labeler.getServices(params, opts)
|
|
105
118
|
|
|
119
|
+
async getLabelDefinitions(
|
|
120
|
+
prefs: BskyPreferences | ModerationPrefs | string[],
|
|
121
|
+
): Promise<Record<string, InterpretedLabelValueDefinition[]>> {
|
|
122
|
+
// collect the labeler dids
|
|
123
|
+
let dids: string[] = BskyAgent.appLabelers
|
|
124
|
+
if (isBskyPrefs(prefs)) {
|
|
125
|
+
dids = dids.concat(prefs.moderationPrefs.labelers.map((l) => l.did))
|
|
126
|
+
} else if (isModPrefs(prefs)) {
|
|
127
|
+
dids = dids.concat(prefs.labelers.map((l) => l.did))
|
|
128
|
+
} else {
|
|
129
|
+
dids = dids.concat(prefs)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// fetch their definitions
|
|
133
|
+
const labelers = await this.getLabelers({
|
|
134
|
+
dids,
|
|
135
|
+
detailed: true,
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
// assemble a map of labeler dids to the interpretted label value definitions
|
|
139
|
+
const labelDefs = {}
|
|
140
|
+
if (labelers.data) {
|
|
141
|
+
for (const labeler of labelers.data
|
|
142
|
+
.views as AppBskyLabelerDefs.LabelerViewDetailed[]) {
|
|
143
|
+
labelDefs[labeler.creator.did] = interpretLabelValueDefinitions(labeler)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return labelDefs
|
|
148
|
+
}
|
|
149
|
+
|
|
106
150
|
async post(
|
|
107
151
|
record: Partial<AppBskyFeedPost.Record> &
|
|
108
152
|
Omit<AppBskyFeedPost.Record, 'createdAt'>,
|
|
@@ -330,14 +374,14 @@ export class BskyAgent extends AtpAgent {
|
|
|
330
374
|
moderationPrefs: {
|
|
331
375
|
adultContentEnabled: false,
|
|
332
376
|
labels: { ...DEFAULT_LABEL_SETTINGS },
|
|
333
|
-
|
|
377
|
+
labelers: BskyAgent.appLabelers.map((did) => ({ did, labels: {} })),
|
|
378
|
+
mutedWords: [],
|
|
379
|
+
hiddenPosts: [],
|
|
334
380
|
},
|
|
335
381
|
birthDate: undefined,
|
|
336
382
|
interests: {
|
|
337
383
|
tags: [],
|
|
338
384
|
},
|
|
339
|
-
mutedWords: [],
|
|
340
|
-
hiddenPosts: [],
|
|
341
385
|
}
|
|
342
386
|
const res = await this.app.bsky.actor.getPreferences({})
|
|
343
387
|
const labelPrefs: AppBskyActorDefs.ContentLabelPref[] = []
|
|
@@ -356,14 +400,18 @@ export class BskyAgent extends AtpAgent {
|
|
|
356
400
|
const adjustedPref = adjustLegacyContentLabelPref(pref)
|
|
357
401
|
labelPrefs.push(adjustedPref)
|
|
358
402
|
} else if (
|
|
359
|
-
AppBskyActorDefs.
|
|
360
|
-
AppBskyActorDefs.
|
|
403
|
+
AppBskyActorDefs.isLabelersPref(pref) &&
|
|
404
|
+
AppBskyActorDefs.validateLabelersPref(pref).success
|
|
361
405
|
) {
|
|
362
|
-
//
|
|
363
|
-
prefs.moderationPrefs.
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
406
|
+
// labelers preferences
|
|
407
|
+
prefs.moderationPrefs.labelers = BskyAgent.appLabelers
|
|
408
|
+
.map((did) => ({ did, labels: {} }))
|
|
409
|
+
.concat(
|
|
410
|
+
pref.labelers.map((labeler) => ({
|
|
411
|
+
...labeler,
|
|
412
|
+
labels: {},
|
|
413
|
+
})),
|
|
414
|
+
)
|
|
367
415
|
} else if (
|
|
368
416
|
AppBskyActorDefs.isSavedFeedsPref(pref) &&
|
|
369
417
|
AppBskyActorDefs.validateSavedFeedsPref(pref).success
|
|
@@ -408,42 +456,35 @@ export class BskyAgent extends AtpAgent {
|
|
|
408
456
|
) {
|
|
409
457
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
410
458
|
const { $type, ...v } = pref
|
|
411
|
-
prefs.mutedWords = v.items
|
|
459
|
+
prefs.moderationPrefs.mutedWords = v.items
|
|
412
460
|
} else if (
|
|
413
461
|
AppBskyActorDefs.isHiddenPostsPref(pref) &&
|
|
414
462
|
AppBskyActorDefs.validateHiddenPostsPref(pref).success
|
|
415
463
|
) {
|
|
416
464
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
417
465
|
const { $type, ...v } = pref
|
|
418
|
-
prefs.hiddenPosts = v.items
|
|
466
|
+
prefs.moderationPrefs.hiddenPosts = v.items
|
|
419
467
|
}
|
|
420
468
|
}
|
|
421
469
|
|
|
422
|
-
// ensure the bluesky moderation is configured
|
|
423
|
-
const bskyModeration = prefs.moderationPrefs.mods.find(
|
|
424
|
-
(modPref) => modPref.did === BSKY_MODSERVICE_DID,
|
|
425
|
-
)
|
|
426
|
-
if (!bskyModeration) {
|
|
427
|
-
prefs.moderationPrefs.mods.unshift({
|
|
428
|
-
did: BSKY_MODSERVICE_DID,
|
|
429
|
-
labels: {},
|
|
430
|
-
})
|
|
431
|
-
}
|
|
432
|
-
|
|
433
470
|
// apply the label prefs
|
|
434
471
|
for (const pref of labelPrefs) {
|
|
435
472
|
if (pref.labelerDid) {
|
|
436
|
-
const
|
|
437
|
-
(
|
|
473
|
+
const labeler = prefs.moderationPrefs.labelers.find(
|
|
474
|
+
(labeler) => labeler.did === pref.labelerDid,
|
|
438
475
|
)
|
|
439
|
-
if (!
|
|
440
|
-
|
|
476
|
+
if (!labeler) continue
|
|
477
|
+
labeler.labels[pref.label] = pref.visibility as LabelPreference
|
|
441
478
|
} else {
|
|
442
479
|
prefs.moderationPrefs.labels[pref.label] =
|
|
443
480
|
pref.visibility as LabelPreference
|
|
444
481
|
}
|
|
445
482
|
}
|
|
446
483
|
|
|
484
|
+
prefs.moderationPrefs.labels = remapLegacyLabels(
|
|
485
|
+
prefs.moderationPrefs.labels,
|
|
486
|
+
)
|
|
487
|
+
|
|
447
488
|
// automatically configure the client
|
|
448
489
|
this.configureLabelersHeader(prefsArrayToLabelerDids(res.data.preferences))
|
|
449
490
|
|
|
@@ -522,6 +563,8 @@ export class BskyAgent extends AtpAgent {
|
|
|
522
563
|
pref.label === key &&
|
|
523
564
|
pref.labelerDid === labelerDid,
|
|
524
565
|
)
|
|
566
|
+
let legacyLabelPref: AppBskyActorDefs.ContentLabelPref | undefined
|
|
567
|
+
|
|
525
568
|
if (labelPref) {
|
|
526
569
|
labelPref.visibility = value
|
|
527
570
|
} else {
|
|
@@ -532,6 +575,40 @@ export class BskyAgent extends AtpAgent {
|
|
|
532
575
|
visibility: value,
|
|
533
576
|
}
|
|
534
577
|
}
|
|
578
|
+
|
|
579
|
+
if (AppBskyActorDefs.isContentLabelPref(labelPref)) {
|
|
580
|
+
// is global
|
|
581
|
+
if (!labelPref.labelerDid) {
|
|
582
|
+
const legacyLabelValue = {
|
|
583
|
+
'graphic-media': 'gore',
|
|
584
|
+
porn: 'nsfw',
|
|
585
|
+
sexual: 'suggestive',
|
|
586
|
+
}[labelPref.label]
|
|
587
|
+
|
|
588
|
+
// if it's a legacy label, double-write the legacy label
|
|
589
|
+
if (legacyLabelValue) {
|
|
590
|
+
legacyLabelPref = prefs.findLast(
|
|
591
|
+
(pref) =>
|
|
592
|
+
AppBskyActorDefs.isContentLabelPref(pref) &&
|
|
593
|
+
AppBskyActorDefs.validateContentLabelPref(pref).success &&
|
|
594
|
+
pref.label === legacyLabelValue &&
|
|
595
|
+
pref.labelerDid === undefined,
|
|
596
|
+
) as AppBskyActorDefs.ContentLabelPref | undefined
|
|
597
|
+
|
|
598
|
+
if (legacyLabelPref) {
|
|
599
|
+
legacyLabelPref.visibility = value
|
|
600
|
+
} else {
|
|
601
|
+
legacyLabelPref = {
|
|
602
|
+
$type: 'app.bsky.actor.defs#contentLabelPref',
|
|
603
|
+
label: legacyLabelValue,
|
|
604
|
+
labelerDid: undefined,
|
|
605
|
+
visibility: value,
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
535
612
|
return prefs
|
|
536
613
|
.filter(
|
|
537
614
|
(pref) =>
|
|
@@ -539,63 +616,78 @@ export class BskyAgent extends AtpAgent {
|
|
|
539
616
|
!(pref.label === key && pref.labelerDid === labelerDid),
|
|
540
617
|
)
|
|
541
618
|
.concat([labelPref])
|
|
619
|
+
.filter((pref) => {
|
|
620
|
+
if (!legacyLabelPref) return true
|
|
621
|
+
return (
|
|
622
|
+
!AppBskyActorDefs.isContentLabelPref(pref) ||
|
|
623
|
+
!(
|
|
624
|
+
pref.label === legacyLabelPref.label &&
|
|
625
|
+
pref.labelerDid === undefined
|
|
626
|
+
)
|
|
627
|
+
)
|
|
628
|
+
})
|
|
629
|
+
.concat(legacyLabelPref ? [legacyLabelPref] : [])
|
|
542
630
|
})
|
|
543
631
|
}
|
|
544
632
|
|
|
545
|
-
async
|
|
633
|
+
async addLabeler(did: string) {
|
|
546
634
|
const prefs = await updatePreferences(
|
|
547
635
|
this,
|
|
548
636
|
(prefs: AppBskyActorDefs.Preferences) => {
|
|
549
|
-
let
|
|
637
|
+
let labelersPref = prefs.findLast(
|
|
550
638
|
(pref) =>
|
|
551
|
-
AppBskyActorDefs.
|
|
552
|
-
AppBskyActorDefs.
|
|
639
|
+
AppBskyActorDefs.isLabelersPref(pref) &&
|
|
640
|
+
AppBskyActorDefs.validateLabelersPref(pref).success,
|
|
553
641
|
)
|
|
554
|
-
if (!
|
|
555
|
-
|
|
556
|
-
$type: 'app.bsky.actor.defs#
|
|
557
|
-
|
|
642
|
+
if (!labelersPref) {
|
|
643
|
+
labelersPref = {
|
|
644
|
+
$type: 'app.bsky.actor.defs#labelersPref',
|
|
645
|
+
labelers: [],
|
|
558
646
|
}
|
|
559
647
|
}
|
|
560
|
-
if (AppBskyActorDefs.
|
|
561
|
-
let
|
|
562
|
-
|
|
563
|
-
|
|
648
|
+
if (AppBskyActorDefs.isLabelersPref(labelersPref)) {
|
|
649
|
+
let labelerPrefItem = labelersPref.labelers.find(
|
|
650
|
+
(labeler) => labeler.did === did,
|
|
651
|
+
)
|
|
652
|
+
if (!labelerPrefItem) {
|
|
653
|
+
labelerPrefItem = {
|
|
564
654
|
did,
|
|
565
655
|
}
|
|
566
|
-
|
|
656
|
+
labelersPref.labelers.push(labelerPrefItem)
|
|
567
657
|
}
|
|
568
658
|
}
|
|
569
659
|
return prefs
|
|
570
|
-
.filter((pref) => !AppBskyActorDefs.
|
|
571
|
-
.concat([
|
|
660
|
+
.filter((pref) => !AppBskyActorDefs.isLabelersPref(pref))
|
|
661
|
+
.concat([labelersPref])
|
|
572
662
|
},
|
|
573
663
|
)
|
|
574
664
|
// automatically configure the client
|
|
575
665
|
this.configureLabelersHeader(prefsArrayToLabelerDids(prefs))
|
|
576
666
|
}
|
|
577
667
|
|
|
578
|
-
async
|
|
668
|
+
async removeLabeler(did: string) {
|
|
579
669
|
const prefs = await updatePreferences(
|
|
580
670
|
this,
|
|
581
671
|
(prefs: AppBskyActorDefs.Preferences) => {
|
|
582
|
-
let
|
|
672
|
+
let labelersPref = prefs.findLast(
|
|
583
673
|
(pref) =>
|
|
584
|
-
AppBskyActorDefs.
|
|
585
|
-
AppBskyActorDefs.
|
|
674
|
+
AppBskyActorDefs.isLabelersPref(pref) &&
|
|
675
|
+
AppBskyActorDefs.validateLabelersPref(pref).success,
|
|
586
676
|
)
|
|
587
|
-
if (!
|
|
588
|
-
|
|
589
|
-
$type: 'app.bsky.actor.defs#
|
|
590
|
-
|
|
677
|
+
if (!labelersPref) {
|
|
678
|
+
labelersPref = {
|
|
679
|
+
$type: 'app.bsky.actor.defs#labelersPref',
|
|
680
|
+
labelers: [],
|
|
591
681
|
}
|
|
592
682
|
}
|
|
593
|
-
if (AppBskyActorDefs.
|
|
594
|
-
|
|
683
|
+
if (AppBskyActorDefs.isLabelersPref(labelersPref)) {
|
|
684
|
+
labelersPref.labelers = labelersPref.labelers.filter(
|
|
685
|
+
(labeler) => labeler.did !== did,
|
|
686
|
+
)
|
|
595
687
|
}
|
|
596
688
|
return prefs
|
|
597
|
-
.filter((pref) => !AppBskyActorDefs.
|
|
598
|
-
.concat([
|
|
689
|
+
.filter((pref) => !AppBskyActorDefs.isLabelersPref(pref))
|
|
690
|
+
.concat([labelersPref])
|
|
599
691
|
},
|
|
600
692
|
)
|
|
601
693
|
// automatically configure the client
|
|
@@ -859,7 +951,6 @@ async function updateFeedPreferences(
|
|
|
859
951
|
function adjustLegacyContentLabelPref(
|
|
860
952
|
pref: AppBskyActorDefs.ContentLabelPref,
|
|
861
953
|
): AppBskyActorDefs.ContentLabelPref {
|
|
862
|
-
let label = pref.label
|
|
863
954
|
let visibility = pref.visibility
|
|
864
955
|
|
|
865
956
|
// adjust legacy values
|
|
@@ -867,15 +958,31 @@ function adjustLegacyContentLabelPref(
|
|
|
867
958
|
visibility = 'ignore'
|
|
868
959
|
}
|
|
869
960
|
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
961
|
+
return { ...pref, visibility }
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* Re-maps legacy labels to new labels on READ. Does not save these changes to
|
|
966
|
+
* the user's preferences.
|
|
967
|
+
*/
|
|
968
|
+
function remapLegacyLabels(
|
|
969
|
+
labels: BskyPreferences['moderationPrefs']['labels'],
|
|
970
|
+
) {
|
|
971
|
+
const _labels = { ...labels }
|
|
972
|
+
const legacyToNewMap: Record<string, string | undefined> = {
|
|
973
|
+
gore: 'graphic-media',
|
|
974
|
+
nsfw: 'porn',
|
|
975
|
+
suggestive: 'sexual',
|
|
873
976
|
}
|
|
874
|
-
|
|
875
|
-
|
|
977
|
+
|
|
978
|
+
for (const labelName in _labels) {
|
|
979
|
+
const newLabelName = legacyToNewMap[labelName]!
|
|
980
|
+
if (newLabelName) {
|
|
981
|
+
_labels[newLabelName] = _labels[labelName]
|
|
982
|
+
}
|
|
876
983
|
}
|
|
877
984
|
|
|
878
|
-
return
|
|
985
|
+
return _labels
|
|
879
986
|
}
|
|
880
987
|
|
|
881
988
|
/**
|
|
@@ -884,17 +991,16 @@ function adjustLegacyContentLabelPref(
|
|
|
884
991
|
function prefsArrayToLabelerDids(
|
|
885
992
|
prefs: AppBskyActorDefs.Preferences,
|
|
886
993
|
): string[] {
|
|
887
|
-
const
|
|
994
|
+
const labelersPref = prefs.findLast(
|
|
888
995
|
(pref) =>
|
|
889
|
-
AppBskyActorDefs.
|
|
890
|
-
AppBskyActorDefs.
|
|
996
|
+
AppBskyActorDefs.isLabelersPref(pref) &&
|
|
997
|
+
AppBskyActorDefs.validateLabelersPref(pref).success,
|
|
891
998
|
)
|
|
892
999
|
let dids: string[] = []
|
|
893
|
-
if (
|
|
894
|
-
dids = (
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
dids.unshift(BSKY_MODSERVICE_DID)
|
|
1000
|
+
if (labelersPref) {
|
|
1001
|
+
dids = (labelersPref as AppBskyActorDefs.LabelersPref).labelers.map(
|
|
1002
|
+
(labeler) => labeler.did,
|
|
1003
|
+
)
|
|
898
1004
|
}
|
|
899
1005
|
return dids
|
|
900
1006
|
}
|
|
@@ -928,3 +1034,16 @@ async function updateHiddenPost(
|
|
|
928
1034
|
.concat([{ ...pref, $type: 'app.bsky.actor.defs#hiddenPostsPref' }])
|
|
929
1035
|
})
|
|
930
1036
|
}
|
|
1037
|
+
|
|
1038
|
+
function isBskyPrefs(v: any): v is BskyPreferences {
|
|
1039
|
+
return (
|
|
1040
|
+
v &&
|
|
1041
|
+
typeof v === 'object' &&
|
|
1042
|
+
'moderationPrefs' in v &&
|
|
1043
|
+
isModPrefs(v.moderationPrefs)
|
|
1044
|
+
)
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
function isModPrefs(v: any): v is ModerationPrefs {
|
|
1048
|
+
return v && typeof v === 'object' && 'labelers' in v
|
|
1049
|
+
}
|
package/src/client/lexicons.ts
CHANGED
|
@@ -855,6 +855,17 @@ export const schemaDict = {
|
|
|
855
855
|
"What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.",
|
|
856
856
|
knownValues: ['content', 'media', 'none'],
|
|
857
857
|
},
|
|
858
|
+
defaultSetting: {
|
|
859
|
+
type: 'string',
|
|
860
|
+
description: 'The default setting for this label.',
|
|
861
|
+
knownValues: ['ignore', 'warn', 'hide'],
|
|
862
|
+
default: 'warn',
|
|
863
|
+
},
|
|
864
|
+
adultOnly: {
|
|
865
|
+
type: 'boolean',
|
|
866
|
+
description:
|
|
867
|
+
'Does the user need to have adult content enabled in order to configure this label?',
|
|
868
|
+
},
|
|
858
869
|
locales: {
|
|
859
870
|
type: 'array',
|
|
860
871
|
items: {
|
|
@@ -3958,20 +3969,20 @@ export const schemaDict = {
|
|
|
3958
3969
|
},
|
|
3959
3970
|
},
|
|
3960
3971
|
},
|
|
3961
|
-
|
|
3972
|
+
labelersPref: {
|
|
3962
3973
|
type: 'object',
|
|
3963
|
-
required: ['
|
|
3974
|
+
required: ['labelers'],
|
|
3964
3975
|
properties: {
|
|
3965
|
-
|
|
3976
|
+
labelers: {
|
|
3966
3977
|
type: 'array',
|
|
3967
3978
|
items: {
|
|
3968
3979
|
type: 'ref',
|
|
3969
|
-
ref: 'lex:app.bsky.actor.defs#
|
|
3980
|
+
ref: 'lex:app.bsky.actor.defs#labelerPrefItem',
|
|
3970
3981
|
},
|
|
3971
3982
|
},
|
|
3972
3983
|
},
|
|
3973
3984
|
},
|
|
3974
|
-
|
|
3985
|
+
labelerPrefItem: {
|
|
3975
3986
|
type: 'object',
|
|
3976
3987
|
required: ['did'],
|
|
3977
3988
|
properties: {
|
|
@@ -4859,6 +4870,13 @@ export const schemaDict = {
|
|
|
4859
4870
|
type: 'integer',
|
|
4860
4871
|
minimum: 0,
|
|
4861
4872
|
},
|
|
4873
|
+
labels: {
|
|
4874
|
+
type: 'array',
|
|
4875
|
+
items: {
|
|
4876
|
+
type: 'ref',
|
|
4877
|
+
ref: 'lex:com.atproto.label.defs#label',
|
|
4878
|
+
},
|
|
4879
|
+
},
|
|
4862
4880
|
viewer: {
|
|
4863
4881
|
type: 'ref',
|
|
4864
4882
|
ref: 'lex:app.bsky.feed.defs#generatorViewerState',
|
|
@@ -6163,6 +6181,13 @@ export const schemaDict = {
|
|
|
6163
6181
|
avatar: {
|
|
6164
6182
|
type: 'string',
|
|
6165
6183
|
},
|
|
6184
|
+
labels: {
|
|
6185
|
+
type: 'array',
|
|
6186
|
+
items: {
|
|
6187
|
+
type: 'ref',
|
|
6188
|
+
ref: 'lex:com.atproto.label.defs#label',
|
|
6189
|
+
},
|
|
6190
|
+
},
|
|
6166
6191
|
viewer: {
|
|
6167
6192
|
type: 'ref',
|
|
6168
6193
|
ref: 'lex:app.bsky.graph.defs#listViewerState',
|
|
@@ -6213,6 +6238,13 @@ export const schemaDict = {
|
|
|
6213
6238
|
avatar: {
|
|
6214
6239
|
type: 'string',
|
|
6215
6240
|
},
|
|
6241
|
+
labels: {
|
|
6242
|
+
type: 'array',
|
|
6243
|
+
items: {
|
|
6244
|
+
type: 'ref',
|
|
6245
|
+
ref: 'lex:com.atproto.label.defs#label',
|
|
6246
|
+
},
|
|
6247
|
+
},
|
|
6216
6248
|
viewer: {
|
|
6217
6249
|
type: 'ref',
|
|
6218
6250
|
ref: 'lex:app.bsky.graph.defs#listViewerState',
|
|
@@ -338,36 +338,36 @@ export function validateHiddenPostsPref(v: unknown): ValidationResult {
|
|
|
338
338
|
return lexicons.validate('app.bsky.actor.defs#hiddenPostsPref', v)
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
export interface
|
|
342
|
-
|
|
341
|
+
export interface LabelersPref {
|
|
342
|
+
labelers: LabelerPrefItem[]
|
|
343
343
|
[k: string]: unknown
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
export function
|
|
346
|
+
export function isLabelersPref(v: unknown): v is LabelersPref {
|
|
347
347
|
return (
|
|
348
348
|
isObj(v) &&
|
|
349
349
|
hasProp(v, '$type') &&
|
|
350
|
-
v.$type === 'app.bsky.actor.defs#
|
|
350
|
+
v.$type === 'app.bsky.actor.defs#labelersPref'
|
|
351
351
|
)
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
export function
|
|
355
|
-
return lexicons.validate('app.bsky.actor.defs#
|
|
354
|
+
export function validateLabelersPref(v: unknown): ValidationResult {
|
|
355
|
+
return lexicons.validate('app.bsky.actor.defs#labelersPref', v)
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
-
export interface
|
|
358
|
+
export interface LabelerPrefItem {
|
|
359
359
|
did: string
|
|
360
360
|
[k: string]: unknown
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
export function
|
|
363
|
+
export function isLabelerPrefItem(v: unknown): v is LabelerPrefItem {
|
|
364
364
|
return (
|
|
365
365
|
isObj(v) &&
|
|
366
366
|
hasProp(v, '$type') &&
|
|
367
|
-
v.$type === 'app.bsky.actor.defs#
|
|
367
|
+
v.$type === 'app.bsky.actor.defs#labelerPrefItem'
|
|
368
368
|
)
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
-
export function
|
|
372
|
-
return lexicons.validate('app.bsky.actor.defs#
|
|
371
|
+
export function validateLabelerPrefItem(v: unknown): ValidationResult {
|
|
372
|
+
return lexicons.validate('app.bsky.actor.defs#labelerPrefItem', v)
|
|
373
373
|
}
|