@atproto/ozone 0.0.7 → 0.0.9
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 +14 -0
- package/LICENSE.txt +1 -1
- package/dist/db/index.js +295 -16
- package/dist/db/index.js.map +3 -3
- package/dist/db/migrations/20240201T051104136Z-mod-event-blobs.d.ts +3 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/db/schema/moderation_event.d.ts +1 -0
- package/dist/db/types.d.ts +1 -0
- package/dist/index.js +1151 -604
- package/dist/index.js.map +3 -3
- package/dist/lexicon/index.d.ts +0 -2
- package/dist/lexicon/lexicons.d.ts +134 -52
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts +1 -0
- package/dist/lexicon/types/app/bsky/actor/getPreferences.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/actor/getProfile.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/actor/getProfiles.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/actor/getSuggestions.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/actor/searchActors.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/actor/searchActorsTypeahead.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/describeFeedGenerator.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getActorFeeds.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getActorLikes.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getAuthorFeed.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getFeed.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getFeedGenerator.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getFeedGenerators.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getFeedSkeleton.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getLikes.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getListFeed.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getPostThread.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getPosts.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getRepostedBy.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getSuggestedFeeds.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/getTimeline.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/feed/searchPosts.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/graph/getBlocks.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/graph/getFollowers.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/graph/getFollows.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/graph/getList.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/graph/getListBlocks.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/graph/getListMutes.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/graph/getLists.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/graph/getMutes.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/graph/getRelationships.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/graph/getSuggestedFollowsByActor.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/notification/getUnreadCount.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/notification/listNotifications.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/unspecced/getPopularFeedGenerators.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/unspecced/getTaggedSuggestions.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/unspecced/searchActorsSkeleton.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/unspecced/searchPostsSkeleton.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/createCommunicationTemplate.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/defs.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/emitModerationEvent.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/getAccountInfo.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/getAccountInfos.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/getInviteCodes.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/getModerationEvent.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/getRecord.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/getRepo.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/getSubjectStatus.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/listCommunicationTemplates.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/queryModerationEvents.d.ts +9 -2
- package/dist/lexicon/types/com/atproto/admin/queryModerationStatuses.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/searchRepos.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/sendEmail.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/updateCommunicationTemplate.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/admin/updateSubjectStatus.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/identity/resolveHandle.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/label/queryLabels.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/moderation/createReport.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/repo/createRecord.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/repo/describeRepo.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/repo/getRecord.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/repo/listRecords.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/repo/putRecord.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/repo/uploadBlob.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/createAccount.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/createAppPassword.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/createInviteCode.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/createInviteCodes.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/createSession.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/describeServer.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/getAccountInviteCodes.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/getSession.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/listAppPasswords.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/requestEmailUpdate.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/server/reserveSigningKey.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/sync/getBlob.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/sync/getBlocks.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/sync/getCheckout.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/sync/getHead.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/sync/getLatestCommit.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/sync/getRecord.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/sync/getRepo.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/sync/listBlobs.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/temp/checkSignupQueue.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/temp/fetchLabels.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/temp/importRepo.d.ts +2 -2
- package/dist/lexicon/types/com/atproto/temp/transferAccount.d.ts +2 -2
- package/dist/mod-service/index.d.ts +13 -4
- package/dist/mod-service/subject.d.ts +3 -0
- package/dist/mod-service/types.d.ts +2 -0
- package/package.json +5 -5
- package/src/api/admin/emitModerationEvent.ts +9 -6
- package/src/api/admin/queryModerationEvents.ts +14 -0
- package/src/api/moderation/util.ts +1 -0
- package/src/api/temp/fetchLabels.ts +36 -21
- package/src/context.ts +1 -0
- package/src/daemon/context.ts +1 -0
- package/src/db/migrations/20240201T051104136Z-mod-event-blobs.ts +15 -0
- package/src/db/migrations/index.ts +1 -0
- package/src/db/schema/moderation_event.ts +1 -0
- package/src/db/types.ts +6 -1
- package/src/lexicon/index.ts +0 -12
- package/src/lexicon/lexicons.ts +382 -173
- package/src/lexicon/types/app/bsky/actor/defs.ts +2 -0
- package/src/lexicon/types/app/bsky/actor/getPreferences.ts +2 -2
- package/src/lexicon/types/app/bsky/actor/getProfile.ts +3 -2
- package/src/lexicon/types/app/bsky/actor/getProfiles.ts +2 -2
- package/src/lexicon/types/app/bsky/actor/getSuggestions.ts +2 -2
- package/src/lexicon/types/app/bsky/actor/profile.ts +3 -0
- package/src/lexicon/types/app/bsky/actor/putPreferences.ts +1 -1
- package/src/lexicon/types/app/bsky/actor/searchActors.ts +2 -2
- package/src/lexicon/types/app/bsky/actor/searchActorsTypeahead.ts +2 -2
- package/src/lexicon/types/app/bsky/embed/external.ts +1 -0
- package/src/lexicon/types/app/bsky/embed/images.ts +4 -0
- package/src/lexicon/types/app/bsky/embed/record.ts +1 -0
- package/src/lexicon/types/app/bsky/feed/defs.ts +1 -0
- package/src/lexicon/types/app/bsky/feed/describeFeedGenerator.ts +2 -2
- package/src/lexicon/types/app/bsky/feed/getActorFeeds.ts +2 -2
- package/src/lexicon/types/app/bsky/feed/getActorLikes.ts +2 -2
- package/src/lexicon/types/app/bsky/feed/getAuthorFeed.ts +3 -2
- package/src/lexicon/types/app/bsky/feed/getFeed.ts +2 -2
- package/src/lexicon/types/app/bsky/feed/getFeedGenerator.ts +5 -2
- package/src/lexicon/types/app/bsky/feed/getFeedGenerators.ts +2 -2
- package/src/lexicon/types/app/bsky/feed/getFeedSkeleton.ts +3 -2
- package/src/lexicon/types/app/bsky/feed/getLikes.ts +4 -2
- package/src/lexicon/types/app/bsky/feed/getListFeed.ts +3 -2
- package/src/lexicon/types/app/bsky/feed/getPostThread.ts +5 -2
- package/src/lexicon/types/app/bsky/feed/getPosts.ts +3 -2
- package/src/lexicon/types/app/bsky/feed/getRepostedBy.ts +4 -2
- package/src/lexicon/types/app/bsky/feed/getSuggestedFeeds.ts +2 -2
- package/src/lexicon/types/app/bsky/feed/getTimeline.ts +3 -2
- package/src/lexicon/types/app/bsky/feed/post.ts +5 -1
- package/src/lexicon/types/app/bsky/feed/searchPosts.ts +2 -2
- package/src/lexicon/types/app/bsky/feed/threadgate.ts +1 -0
- package/src/lexicon/types/app/bsky/graph/block.ts +1 -0
- package/src/lexicon/types/app/bsky/graph/getBlocks.ts +2 -2
- package/src/lexicon/types/app/bsky/graph/getFollowers.ts +2 -2
- package/src/lexicon/types/app/bsky/graph/getFollows.ts +2 -2
- package/src/lexicon/types/app/bsky/graph/getList.ts +3 -2
- package/src/lexicon/types/app/bsky/graph/getListBlocks.ts +2 -2
- package/src/lexicon/types/app/bsky/graph/getListMutes.ts +2 -2
- package/src/lexicon/types/app/bsky/graph/getLists.ts +3 -2
- package/src/lexicon/types/app/bsky/graph/getMutes.ts +2 -2
- package/src/lexicon/types/app/bsky/graph/getRelationships.ts +4 -2
- package/src/lexicon/types/app/bsky/graph/getSuggestedFollowsByActor.ts +2 -2
- package/src/lexicon/types/app/bsky/graph/list.ts +1 -0
- package/src/lexicon/types/app/bsky/graph/listblock.ts +1 -0
- package/src/lexicon/types/app/bsky/graph/listitem.ts +2 -0
- package/src/lexicon/types/app/bsky/graph/muteActor.ts +1 -1
- package/src/lexicon/types/app/bsky/graph/muteActorList.ts +1 -1
- package/src/lexicon/types/app/bsky/graph/unmuteActor.ts +1 -1
- package/src/lexicon/types/app/bsky/graph/unmuteActorList.ts +1 -1
- package/src/lexicon/types/app/bsky/notification/getUnreadCount.ts +2 -2
- package/src/lexicon/types/app/bsky/notification/listNotifications.ts +2 -2
- package/src/lexicon/types/app/bsky/notification/registerPush.ts +1 -1
- package/src/lexicon/types/app/bsky/notification/updateSeen.ts +1 -1
- package/src/lexicon/types/app/bsky/richtext/facet.ts +5 -4
- package/src/lexicon/types/app/bsky/unspecced/getPopularFeedGenerators.ts +2 -2
- package/src/lexicon/types/app/bsky/unspecced/getTaggedSuggestions.ts +2 -2
- package/src/lexicon/types/app/bsky/unspecced/searchActorsSkeleton.ts +2 -2
- package/src/lexicon/types/app/bsky/unspecced/searchPostsSkeleton.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/createCommunicationTemplate.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/defs.ts +2 -0
- package/src/lexicon/types/com/atproto/admin/deleteAccount.ts +1 -1
- package/src/lexicon/types/com/atproto/admin/deleteCommunicationTemplate.ts +1 -1
- package/src/lexicon/types/com/atproto/admin/disableAccountInvites.ts +1 -1
- package/src/lexicon/types/com/atproto/admin/disableInviteCodes.ts +1 -1
- package/src/lexicon/types/com/atproto/admin/emitModerationEvent.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/enableAccountInvites.ts +1 -1
- package/src/lexicon/types/com/atproto/admin/getAccountInfo.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/getAccountInfos.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/getInviteCodes.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/getModerationEvent.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/getRecord.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/getRepo.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/getSubjectStatus.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/listCommunicationTemplates.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/queryModerationEvents.ts +15 -2
- package/src/lexicon/types/com/atproto/admin/queryModerationStatuses.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/searchRepos.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/sendEmail.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/updateAccountEmail.ts +1 -1
- package/src/lexicon/types/com/atproto/admin/updateAccountHandle.ts +1 -1
- package/src/lexicon/types/com/atproto/admin/updateCommunicationTemplate.ts +2 -2
- package/src/lexicon/types/com/atproto/admin/updateSubjectStatus.ts +2 -2
- package/src/lexicon/types/com/atproto/identity/resolveHandle.ts +2 -2
- package/src/lexicon/types/com/atproto/identity/updateHandle.ts +2 -1
- package/src/lexicon/types/com/atproto/label/queryLabels.ts +2 -2
- package/src/lexicon/types/com/atproto/label/subscribeLabels.ts +1 -1
- package/src/lexicon/types/com/atproto/moderation/createReport.ts +3 -2
- package/src/lexicon/types/com/atproto/repo/applyWrites.ts +7 -6
- package/src/lexicon/types/com/atproto/repo/createRecord.ts +6 -6
- package/src/lexicon/types/com/atproto/repo/deleteRecord.ts +3 -3
- package/src/lexicon/types/com/atproto/repo/describeRepo.ts +5 -2
- package/src/lexicon/types/com/atproto/repo/getRecord.ts +3 -3
- package/src/lexicon/types/com/atproto/repo/listRecords.ts +2 -2
- package/src/lexicon/types/com/atproto/repo/putRecord.ts +6 -6
- package/src/lexicon/types/com/atproto/repo/uploadBlob.ts +2 -2
- package/src/lexicon/types/com/atproto/server/confirmEmail.ts +1 -1
- package/src/lexicon/types/com/atproto/server/createAccount.ts +10 -2
- package/src/lexicon/types/com/atproto/server/createAppPassword.ts +3 -2
- package/src/lexicon/types/com/atproto/server/createInviteCode.ts +2 -2
- package/src/lexicon/types/com/atproto/server/createInviteCodes.ts +2 -2
- package/src/lexicon/types/com/atproto/server/createSession.ts +2 -2
- package/src/lexicon/types/com/atproto/server/deleteAccount.ts +1 -1
- package/src/lexicon/types/com/atproto/server/deleteSession.ts +1 -1
- package/src/lexicon/types/com/atproto/server/describeServer.ts +5 -2
- package/src/lexicon/types/com/atproto/server/getAccountInviteCodes.ts +3 -2
- package/src/lexicon/types/com/atproto/server/getSession.ts +2 -2
- package/src/lexicon/types/com/atproto/server/listAppPasswords.ts +2 -2
- package/src/lexicon/types/com/atproto/server/refreshSession.ts +2 -2
- package/src/lexicon/types/com/atproto/server/requestAccountDelete.ts +1 -1
- package/src/lexicon/types/com/atproto/server/requestEmailConfirmation.ts +1 -1
- package/src/lexicon/types/com/atproto/server/requestEmailUpdate.ts +2 -2
- package/src/lexicon/types/com/atproto/server/requestPasswordReset.ts +1 -1
- package/src/lexicon/types/com/atproto/server/reserveSigningKey.ts +4 -4
- package/src/lexicon/types/com/atproto/server/resetPassword.ts +1 -1
- package/src/lexicon/types/com/atproto/server/revokeAppPassword.ts +1 -1
- package/src/lexicon/types/com/atproto/server/updateEmail.ts +1 -1
- package/src/lexicon/types/com/atproto/sync/getBlob.ts +3 -3
- package/src/lexicon/types/com/atproto/sync/getBlocks.ts +2 -2
- package/src/lexicon/types/com/atproto/sync/getCheckout.ts +2 -2
- package/src/lexicon/types/com/atproto/sync/getHead.ts +2 -2
- package/src/lexicon/types/com/atproto/sync/getLatestCommit.ts +2 -2
- package/src/lexicon/types/com/atproto/sync/getRecord.ts +3 -2
- package/src/lexicon/types/com/atproto/sync/getRepo.ts +3 -3
- package/src/lexicon/types/com/atproto/sync/listBlobs.ts +2 -2
- package/src/lexicon/types/com/atproto/sync/listRepos.ts +3 -2
- package/src/lexicon/types/com/atproto/sync/notifyOfUpdate.ts +2 -2
- package/src/lexicon/types/com/atproto/sync/requestCrawl.ts +2 -2
- package/src/lexicon/types/com/atproto/sync/subscribeRepos.ts +17 -5
- package/src/lexicon/types/com/atproto/temp/checkSignupQueue.ts +2 -2
- package/src/lexicon/types/com/atproto/temp/fetchLabels.ts +2 -2
- package/src/lexicon/types/com/atproto/temp/importRepo.ts +2 -2
- package/src/lexicon/types/com/atproto/temp/pushBlob.ts +1 -1
- package/src/lexicon/types/com/atproto/temp/requestPhoneVerification.ts +1 -1
- package/src/lexicon/types/com/atproto/temp/transferAccount.ts +2 -2
- package/src/mod-service/index.ts +142 -64
- package/src/mod-service/status.ts +3 -2
- package/src/mod-service/subject.ts +9 -2
- package/src/mod-service/types.ts +4 -0
- package/src/mod-service/views.ts +1 -1
- package/tests/__snapshots__/get-record.test.ts.snap +16 -0
- package/tests/__snapshots__/get-repo.test.ts.snap +9 -1
- package/tests/moderation-appeals.test.ts +1 -1
- package/tests/moderation-events.test.ts +161 -8
- package/tests/moderation-statuses.test.ts +55 -0
- package/tests/moderation.test.ts +133 -34
- package/dist/lexicon/types/app/bsky/unspecced/getTimelineSkeleton.d.ts +0 -35
- package/src/lexicon/types/app/bsky/unspecced/getTimelineSkeleton.ts +0 -49
|
@@ -6,7 +6,7 @@ import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
|
6
6
|
import { lexicons } from '../../../../lexicons'
|
|
7
7
|
import { isObj, hasProp } from '../../../../util'
|
|
8
8
|
import { CID } from 'multiformats/cid'
|
|
9
|
-
import { HandlerAuth } from '@atproto/xrpc-server'
|
|
9
|
+
import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
|
|
10
10
|
|
|
11
11
|
export interface QueryParams {}
|
|
12
12
|
|
|
@@ -49,7 +49,7 @@ export interface HandlerError {
|
|
|
49
49
|
| 'IncompatibleDidDoc'
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export type HandlerOutput = HandlerError | HandlerSuccess
|
|
52
|
+
export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
|
|
53
53
|
export type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
|
54
54
|
auth: HA
|
|
55
55
|
params: QueryParams
|
package/src/mod-service/index.ts
CHANGED
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
ModerationEventRow,
|
|
25
25
|
ModerationSubjectStatusRow,
|
|
26
26
|
ReversibleModerationEvent,
|
|
27
|
+
UNSPECCED_TAKEDOWN_BLOBS_LABEL,
|
|
28
|
+
UNSPECCED_TAKEDOWN_LABEL,
|
|
27
29
|
} from './types'
|
|
28
30
|
import { ModerationEvent } from '../db/schema/moderation_event'
|
|
29
31
|
import { StatusKeyset, TimeIdKeyset, paginate } from '../db/pagination'
|
|
@@ -39,6 +41,7 @@ import {
|
|
|
39
41
|
import { BlobPushEvent } from '../db/schema/blob_push_event'
|
|
40
42
|
import { BackgroundQueue } from '../background'
|
|
41
43
|
import { EventPusher } from '../daemon'
|
|
44
|
+
import { jsonb } from '../db/types'
|
|
42
45
|
|
|
43
46
|
export type ModerationServiceCreator = (db: Database) => ModerationService
|
|
44
47
|
|
|
@@ -49,6 +52,7 @@ export class ModerationService {
|
|
|
49
52
|
public eventPusher: EventPusher,
|
|
50
53
|
public appviewAgent: AtpAgent,
|
|
51
54
|
private appviewAuth: AppviewAuth,
|
|
55
|
+
public serverDid: string,
|
|
52
56
|
) {}
|
|
53
57
|
|
|
54
58
|
static creator(
|
|
@@ -56,6 +60,7 @@ export class ModerationService {
|
|
|
56
60
|
eventPusher: EventPusher,
|
|
57
61
|
appviewAgent: AtpAgent,
|
|
58
62
|
appviewAuth: AppviewAuth,
|
|
63
|
+
serverDid: string,
|
|
59
64
|
) {
|
|
60
65
|
return (db: Database) =>
|
|
61
66
|
new ModerationService(
|
|
@@ -64,6 +69,7 @@ export class ModerationService {
|
|
|
64
69
|
eventPusher,
|
|
65
70
|
appviewAgent,
|
|
66
71
|
appviewAuth,
|
|
72
|
+
serverDid,
|
|
67
73
|
)
|
|
68
74
|
}
|
|
69
75
|
|
|
@@ -91,6 +97,13 @@ export class ModerationService {
|
|
|
91
97
|
includeAllUserRecords: boolean
|
|
92
98
|
types: ModerationEvent['action'][]
|
|
93
99
|
sortDirection?: 'asc' | 'desc'
|
|
100
|
+
hasComment?: boolean
|
|
101
|
+
comment?: string
|
|
102
|
+
createdAfter?: string
|
|
103
|
+
createdBefore?: string
|
|
104
|
+
addedLabels: string[]
|
|
105
|
+
removedLabels: string[]
|
|
106
|
+
reportTypes?: string[]
|
|
94
107
|
}): Promise<{ cursor?: string; events: ModerationEventRow[] }> {
|
|
95
108
|
const {
|
|
96
109
|
subject,
|
|
@@ -100,6 +113,13 @@ export class ModerationService {
|
|
|
100
113
|
includeAllUserRecords,
|
|
101
114
|
sortDirection = 'desc',
|
|
102
115
|
types,
|
|
116
|
+
hasComment,
|
|
117
|
+
comment,
|
|
118
|
+
createdAfter,
|
|
119
|
+
createdBefore,
|
|
120
|
+
addedLabels,
|
|
121
|
+
removedLabels,
|
|
122
|
+
reportTypes,
|
|
103
123
|
} = opts
|
|
104
124
|
let builder = this.db.db.selectFrom('moderation_event').selectAll()
|
|
105
125
|
if (subject) {
|
|
@@ -134,6 +154,33 @@ export class ModerationService {
|
|
|
134
154
|
if (createdBy) {
|
|
135
155
|
builder = builder.where('createdBy', '=', createdBy)
|
|
136
156
|
}
|
|
157
|
+
if (createdAfter) {
|
|
158
|
+
builder = builder.where('createdAt', '>=', createdAfter)
|
|
159
|
+
}
|
|
160
|
+
if (createdBefore) {
|
|
161
|
+
builder = builder.where('createdAt', '<=', createdBefore)
|
|
162
|
+
}
|
|
163
|
+
if (comment) {
|
|
164
|
+
builder = builder.where('comment', 'ilike', `%${comment}%`)
|
|
165
|
+
}
|
|
166
|
+
if (hasComment) {
|
|
167
|
+
builder = builder.where('comment', 'is not', null)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// If multiple labels are passed, then only retrieve events where all those labels exist
|
|
171
|
+
if (addedLabels.length) {
|
|
172
|
+
addedLabels.forEach((label) => {
|
|
173
|
+
builder = builder.where('createLabelVals', 'ilike', `%${label}%`)
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
if (removedLabels.length) {
|
|
177
|
+
removedLabels.forEach((label) => {
|
|
178
|
+
builder = builder.where('negateLabelVals', 'ilike', `%${label}%`)
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
if (reportTypes?.length) {
|
|
182
|
+
builder = builder.where(sql`meta->>'reportType'`, 'in', reportTypes)
|
|
183
|
+
}
|
|
137
184
|
|
|
138
185
|
const { ref } = this.db.db.dynamic
|
|
139
186
|
const keyset = new TimeIdKeyset(
|
|
@@ -218,6 +265,8 @@ export class ModerationService {
|
|
|
218
265
|
meta.subjectLine = event.subjectLine
|
|
219
266
|
}
|
|
220
267
|
|
|
268
|
+
const subjectInfo = subject.info()
|
|
269
|
+
|
|
221
270
|
const modEvent = await this.db.db
|
|
222
271
|
.insertInto('moderation_event')
|
|
223
272
|
.values({
|
|
@@ -236,7 +285,11 @@ export class ModerationService {
|
|
|
236
285
|
event.durationInHours
|
|
237
286
|
? addHoursToDate(event.durationInHours, createdAt).toISOString()
|
|
238
287
|
: undefined,
|
|
239
|
-
|
|
288
|
+
subjectType: subjectInfo.subjectType,
|
|
289
|
+
subjectDid: subjectInfo.subjectDid,
|
|
290
|
+
subjectUri: subjectInfo.subjectUri,
|
|
291
|
+
subjectCid: subjectInfo.subjectCid,
|
|
292
|
+
subjectBlobCids: jsonb(subjectInfo.subjectBlobCids),
|
|
240
293
|
})
|
|
241
294
|
.returningAll()
|
|
242
295
|
.executeTakeFirstOrThrow()
|
|
@@ -359,19 +412,25 @@ export class ModerationService {
|
|
|
359
412
|
subjectDid: subject.did,
|
|
360
413
|
takedownRef,
|
|
361
414
|
}))
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
.
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
415
|
+
|
|
416
|
+
const [repoEvts] = await Promise.all([
|
|
417
|
+
this.db.db
|
|
418
|
+
.insertInto('repo_push_event')
|
|
419
|
+
.values(values)
|
|
420
|
+
.onConflict((oc) =>
|
|
421
|
+
oc.columns(['subjectDid', 'eventType']).doUpdateSet({
|
|
422
|
+
takedownRef,
|
|
423
|
+
confirmedAt: null,
|
|
424
|
+
attempts: 0,
|
|
425
|
+
lastAttempted: null,
|
|
426
|
+
}),
|
|
427
|
+
)
|
|
428
|
+
.returning('id')
|
|
429
|
+
.execute(),
|
|
430
|
+
this.formatAndCreateLabels(subject.did, null, {
|
|
431
|
+
create: [UNSPECCED_TAKEDOWN_LABEL],
|
|
432
|
+
}),
|
|
433
|
+
])
|
|
375
434
|
|
|
376
435
|
this.db.onCommit(() => {
|
|
377
436
|
this.backgroundQueue.add(async () => {
|
|
@@ -383,18 +442,23 @@ export class ModerationService {
|
|
|
383
442
|
}
|
|
384
443
|
|
|
385
444
|
async reverseTakedownRepo(subject: RepoSubject) {
|
|
386
|
-
const repoEvts = await
|
|
387
|
-
.
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
445
|
+
const [repoEvts] = await Promise.all([
|
|
446
|
+
this.db.db
|
|
447
|
+
.updateTable('repo_push_event')
|
|
448
|
+
.where('eventType', 'in', TAKEDOWNS)
|
|
449
|
+
.where('subjectDid', '=', subject.did)
|
|
450
|
+
.set({
|
|
451
|
+
takedownRef: null,
|
|
452
|
+
confirmedAt: null,
|
|
453
|
+
attempts: 0,
|
|
454
|
+
lastAttempted: null,
|
|
455
|
+
})
|
|
456
|
+
.returning('id')
|
|
457
|
+
.execute(),
|
|
458
|
+
this.formatAndCreateLabels(subject.did, null, {
|
|
459
|
+
negate: [UNSPECCED_TAKEDOWN_LABEL],
|
|
460
|
+
}),
|
|
461
|
+
])
|
|
398
462
|
|
|
399
463
|
this.db.onCommit(() => {
|
|
400
464
|
this.backgroundQueue.add(async () => {
|
|
@@ -415,19 +479,27 @@ export class ModerationService {
|
|
|
415
479
|
subjectCid: subject.cid,
|
|
416
480
|
takedownRef,
|
|
417
481
|
}))
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
.
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
482
|
+
const blobCids = subject.blobCids
|
|
483
|
+
const labels: string[] = [UNSPECCED_TAKEDOWN_LABEL]
|
|
484
|
+
if (blobCids && blobCids.length > 0) {
|
|
485
|
+
labels.push(UNSPECCED_TAKEDOWN_BLOBS_LABEL)
|
|
486
|
+
}
|
|
487
|
+
const [recordEvts] = await Promise.all([
|
|
488
|
+
this.db.db
|
|
489
|
+
.insertInto('record_push_event')
|
|
490
|
+
.values(values)
|
|
491
|
+
.onConflict((oc) =>
|
|
492
|
+
oc.columns(['subjectUri', 'eventType']).doUpdateSet({
|
|
493
|
+
takedownRef,
|
|
494
|
+
confirmedAt: null,
|
|
495
|
+
attempts: 0,
|
|
496
|
+
lastAttempted: null,
|
|
497
|
+
}),
|
|
498
|
+
)
|
|
499
|
+
.returning('id')
|
|
500
|
+
.execute(),
|
|
501
|
+
this.formatAndCreateLabels(subject.uri, subject.cid, { create: labels }),
|
|
502
|
+
])
|
|
431
503
|
|
|
432
504
|
this.db.onCommit(() => {
|
|
433
505
|
this.backgroundQueue.add(async () => {
|
|
@@ -437,7 +509,6 @@ export class ModerationService {
|
|
|
437
509
|
})
|
|
438
510
|
})
|
|
439
511
|
|
|
440
|
-
const blobCids = subject.blobCids
|
|
441
512
|
if (blobCids && blobCids.length > 0) {
|
|
442
513
|
const blobValues: Insertable<BlobPushEvent>[] = []
|
|
443
514
|
for (const eventType of TAKEDOWNS) {
|
|
@@ -478,19 +549,27 @@ export class ModerationService {
|
|
|
478
549
|
|
|
479
550
|
async reverseTakedownRecord(subject: RecordSubject) {
|
|
480
551
|
this.db.assertTransaction()
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
.
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
552
|
+
const labels: string[] = [UNSPECCED_TAKEDOWN_LABEL]
|
|
553
|
+
const blobCids = subject.blobCids
|
|
554
|
+
if (blobCids && blobCids.length > 0) {
|
|
555
|
+
labels.push(UNSPECCED_TAKEDOWN_BLOBS_LABEL)
|
|
556
|
+
}
|
|
557
|
+
const [recordEvts] = await Promise.all([
|
|
558
|
+
this.db.db
|
|
559
|
+
.updateTable('record_push_event')
|
|
560
|
+
.where('eventType', 'in', TAKEDOWNS)
|
|
561
|
+
.where('subjectDid', '=', subject.did)
|
|
562
|
+
.where('subjectUri', '=', subject.uri)
|
|
563
|
+
.set({
|
|
564
|
+
takedownRef: null,
|
|
565
|
+
confirmedAt: null,
|
|
566
|
+
attempts: 0,
|
|
567
|
+
lastAttempted: null,
|
|
568
|
+
})
|
|
569
|
+
.returning('id')
|
|
570
|
+
.execute(),
|
|
571
|
+
this.formatAndCreateLabels(subject.uri, subject.cid, { negate: labels }),
|
|
572
|
+
])
|
|
494
573
|
this.db.onCommit(() => {
|
|
495
574
|
this.backgroundQueue.add(async () => {
|
|
496
575
|
await Promise.all(
|
|
@@ -499,7 +578,6 @@ export class ModerationService {
|
|
|
499
578
|
})
|
|
500
579
|
})
|
|
501
580
|
|
|
502
|
-
const blobCids = subject.blobCids
|
|
503
581
|
if (blobCids && blobCids.length > 0) {
|
|
504
582
|
const blobEvts = await this.db.db
|
|
505
583
|
.updateTable('blob_push_event')
|
|
@@ -683,26 +761,26 @@ export class ModerationService {
|
|
|
683
761
|
}
|
|
684
762
|
}
|
|
685
763
|
|
|
686
|
-
async
|
|
687
|
-
|
|
764
|
+
async getStatus(
|
|
765
|
+
subject: ModSubject,
|
|
766
|
+
): Promise<ModerationSubjectStatusRow | null> {
|
|
767
|
+
const result = await this.db.db
|
|
688
768
|
.selectFrom('moderation_subject_status')
|
|
689
769
|
.where('did', '=', subject.did)
|
|
690
|
-
.where('recordPath', '=', subject.recordPath
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
return !!result?.takendown
|
|
770
|
+
.where('recordPath', '=', subject.recordPath ?? '')
|
|
771
|
+
.selectAll()
|
|
772
|
+
.executeTakeFirst()
|
|
773
|
+
return result ?? null
|
|
695
774
|
}
|
|
696
775
|
|
|
697
776
|
async formatAndCreateLabels(
|
|
698
|
-
src: string,
|
|
699
777
|
uri: string,
|
|
700
778
|
cid: string | null,
|
|
701
779
|
labels: { create?: string[]; negate?: string[] },
|
|
702
780
|
): Promise<Label[]> {
|
|
703
781
|
const { create = [], negate = [] } = labels
|
|
704
782
|
const toCreate = create.map((val) => ({
|
|
705
|
-
src,
|
|
783
|
+
src: this.serverDid,
|
|
706
784
|
uri,
|
|
707
785
|
cid: cid ?? undefined,
|
|
708
786
|
val,
|
|
@@ -710,7 +788,7 @@ export class ModerationService {
|
|
|
710
788
|
cts: new Date().toISOString(),
|
|
711
789
|
}))
|
|
712
790
|
const toNegate = negate.map((val) => ({
|
|
713
|
-
src,
|
|
791
|
+
src: this.serverDid,
|
|
714
792
|
uri,
|
|
715
793
|
cid: cid ?? undefined,
|
|
716
794
|
val,
|
|
@@ -12,6 +12,7 @@ import { ModerationEventRow, ModerationSubjectStatusRow } from './types'
|
|
|
12
12
|
import { HOUR } from '@atproto/common'
|
|
13
13
|
import { sql } from 'kysely'
|
|
14
14
|
import { REASONAPPEAL } from '../lexicon/types/com/atproto/moderation/defs'
|
|
15
|
+
import { jsonb } from '../db/types'
|
|
15
16
|
|
|
16
17
|
const getSubjectStatusForModerationEvent = ({
|
|
17
18
|
action,
|
|
@@ -191,9 +192,9 @@ export const adjustModerationSubjectStatus = async (
|
|
|
191
192
|
}
|
|
192
193
|
|
|
193
194
|
if (blobCids?.length) {
|
|
194
|
-
const newBlobCids =
|
|
195
|
+
const newBlobCids = jsonb(
|
|
195
196
|
blobCids,
|
|
196
|
-
)
|
|
197
|
+
) as unknown as ModerationSubjectStatusRow['blobCids']
|
|
197
198
|
newStatus.blobCids = newBlobCids
|
|
198
199
|
subjectStatus.blobCids = newBlobCids
|
|
199
200
|
}
|
|
@@ -37,7 +37,11 @@ export const subjectFromEventRow = (row: ModerationEventRow): ModSubject => {
|
|
|
37
37
|
row.subjectUri &&
|
|
38
38
|
row.subjectCid
|
|
39
39
|
) {
|
|
40
|
-
return new RecordSubject(
|
|
40
|
+
return new RecordSubject(
|
|
41
|
+
row.subjectUri,
|
|
42
|
+
row.subjectCid,
|
|
43
|
+
row.subjectBlobCids ?? [],
|
|
44
|
+
)
|
|
41
45
|
} else {
|
|
42
46
|
return new RepoSubject(row.subjectDid)
|
|
43
47
|
}
|
|
@@ -50,7 +54,7 @@ export const subjectFromStatusRow = (
|
|
|
50
54
|
// Not too intuitive but the recordpath is basically <collection>/<rkey>
|
|
51
55
|
// which is what the last 2 params of .make() arguments are
|
|
52
56
|
const uri = AtUri.make(row.did, ...row.recordPath.split('/')).toString()
|
|
53
|
-
return new RecordSubject(uri.toString(), row.recordCid)
|
|
57
|
+
return new RecordSubject(uri.toString(), row.recordCid, row.blobCids ?? [])
|
|
54
58
|
} else {
|
|
55
59
|
return new RepoSubject(row.did)
|
|
56
60
|
}
|
|
@@ -61,6 +65,7 @@ type SubjectInfo = {
|
|
|
61
65
|
subjectDid: string
|
|
62
66
|
subjectUri: string | null
|
|
63
67
|
subjectCid: string | null
|
|
68
|
+
subjectBlobCids: string[] | null
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
export interface ModSubject {
|
|
@@ -89,6 +94,7 @@ export class RepoSubject implements ModSubject {
|
|
|
89
94
|
subjectDid: this.did,
|
|
90
95
|
subjectUri: null,
|
|
91
96
|
subjectCid: null,
|
|
97
|
+
subjectBlobCids: null,
|
|
92
98
|
}
|
|
93
99
|
}
|
|
94
100
|
lex(): RepoRef {
|
|
@@ -124,6 +130,7 @@ export class RecordSubject implements ModSubject {
|
|
|
124
130
|
subjectDid: this.did,
|
|
125
131
|
subjectUri: this.uri,
|
|
126
132
|
subjectCid: this.cid,
|
|
133
|
+
subjectBlobCids: this.blobCids ?? [],
|
|
127
134
|
}
|
|
128
135
|
}
|
|
129
136
|
lex(): StrongRef {
|
package/src/mod-service/types.ts
CHANGED
|
@@ -30,3 +30,7 @@ export type ModEventType =
|
|
|
30
30
|
| ComAtprotoAdminDefs.ModEventReport
|
|
31
31
|
| ComAtprotoAdminDefs.ModEventMute
|
|
32
32
|
| ComAtprotoAdminDefs.ModEventReverseTakedown
|
|
33
|
+
|
|
34
|
+
export const UNSPECCED_TAKEDOWN_LABEL = '!unspecced-takedown'
|
|
35
|
+
|
|
36
|
+
export const UNSPECCED_TAKEDOWN_BLOBS_LABEL = '!unspecced-takedown-blobs'
|
package/src/mod-service/views.ts
CHANGED
|
@@ -88,7 +88,7 @@ export class ModerationViews {
|
|
|
88
88
|
comment: event.comment ?? undefined,
|
|
89
89
|
},
|
|
90
90
|
subject: subjectFromEventRow(event).lex(),
|
|
91
|
-
subjectBlobCids: [],
|
|
91
|
+
subjectBlobCids: event.subjectBlobCids ?? [],
|
|
92
92
|
createdBy: event.createdBy,
|
|
93
93
|
createdAt: event.createdAt,
|
|
94
94
|
subjectHandle: event.subjectHandle ?? undefined,
|
|
@@ -7,6 +7,14 @@ Object {
|
|
|
7
7
|
"cid": "cids(0)",
|
|
8
8
|
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
9
9
|
"labels": Array [
|
|
10
|
+
Object {
|
|
11
|
+
"cid": "cids(0)",
|
|
12
|
+
"cts": "1970-01-01T00:00:00.000Z",
|
|
13
|
+
"neg": false,
|
|
14
|
+
"src": "user(1)",
|
|
15
|
+
"uri": "record(0)",
|
|
16
|
+
"val": "!unspecced-takedown",
|
|
17
|
+
},
|
|
10
18
|
Object {
|
|
11
19
|
"cid": "cids(0)",
|
|
12
20
|
"cts": "1970-01-01T00:00:00.000Z",
|
|
@@ -93,6 +101,14 @@ Object {
|
|
|
93
101
|
"cid": "cids(0)",
|
|
94
102
|
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
95
103
|
"labels": Array [
|
|
104
|
+
Object {
|
|
105
|
+
"cid": "cids(0)",
|
|
106
|
+
"cts": "1970-01-01T00:00:00.000Z",
|
|
107
|
+
"neg": false,
|
|
108
|
+
"src": "user(1)",
|
|
109
|
+
"uri": "record(0)",
|
|
110
|
+
"val": "!unspecced-takedown",
|
|
111
|
+
},
|
|
96
112
|
Object {
|
|
97
113
|
"cid": "cids(0)",
|
|
98
114
|
"cts": "1970-01-01T00:00:00.000Z",
|
|
@@ -8,7 +8,15 @@ Object {
|
|
|
8
8
|
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
9
9
|
"invites": Array [],
|
|
10
10
|
"invitesDisabled": false,
|
|
11
|
-
"labels": Array [
|
|
11
|
+
"labels": Array [
|
|
12
|
+
Object {
|
|
13
|
+
"cts": "1970-01-01T00:00:00.000Z",
|
|
14
|
+
"neg": false,
|
|
15
|
+
"src": "user(1)",
|
|
16
|
+
"uri": "user(0)",
|
|
17
|
+
"val": "!unspecced-takedown",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
12
20
|
"moderation": Object {
|
|
13
21
|
"subjectStatus": Object {
|
|
14
22
|
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
@@ -39,7 +39,7 @@ describe('moderation-appeals', () => {
|
|
|
39
39
|
|
|
40
40
|
beforeAll(async () => {
|
|
41
41
|
network = await TestNetwork.create({
|
|
42
|
-
dbPostgresSchema: '
|
|
42
|
+
dbPostgresSchema: 'ozone_moderation_appeals',
|
|
43
43
|
})
|
|
44
44
|
agent = network.ozone.getClient()
|
|
45
45
|
pdsAgent = network.pds.getClient()
|