@atproto/ozone 0.0.6 → 0.0.8

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE.txt +1 -1
  3. package/dist/db/index.js +15 -1
  4. package/dist/db/index.js.map +3 -3
  5. package/dist/db/migrations/20240201T051104136Z-mod-event-blobs.d.ts +3 -0
  6. package/dist/db/migrations/index.d.ts +1 -0
  7. package/dist/db/schema/moderation_event.d.ts +1 -0
  8. package/dist/db/types.d.ts +1 -0
  9. package/dist/index.js +440 -294
  10. package/dist/index.js.map +3 -3
  11. package/dist/lexicon/index.d.ts +2 -2
  12. package/dist/lexicon/lexicons.d.ts +67 -47
  13. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +2 -2
  14. package/dist/lexicon/types/com/atproto/admin/queryModerationEvents.d.ts +7 -0
  15. package/dist/lexicon/types/{app/bsky/unspecced/getTimelineSkeleton.d.ts → com/atproto/temp/checkSignupQueue.d.ts} +3 -6
  16. package/dist/mod-service/index.d.ts +13 -4
  17. package/dist/mod-service/subject.d.ts +3 -0
  18. package/dist/mod-service/types.d.ts +2 -0
  19. package/package.json +6 -6
  20. package/src/api/admin/emitModerationEvent.ts +9 -6
  21. package/src/api/admin/queryModerationEvents.ts +14 -0
  22. package/src/api/moderation/util.ts +1 -0
  23. package/src/api/temp/fetchLabels.ts +36 -21
  24. package/src/context.ts +1 -0
  25. package/src/daemon/context.ts +1 -0
  26. package/src/db/migrations/20240201T051104136Z-mod-event-blobs.ts +15 -0
  27. package/src/db/migrations/index.ts +1 -0
  28. package/src/db/schema/moderation_event.ts +1 -0
  29. package/src/db/types.ts +6 -1
  30. package/src/lexicon/index.ts +12 -12
  31. package/src/lexicon/lexicons.ts +72 -50
  32. package/src/lexicon/types/com/atproto/admin/defs.ts +2 -0
  33. package/src/lexicon/types/com/atproto/admin/queryModerationEvents.ts +13 -0
  34. package/src/lexicon/types/{app/bsky/unspecced/getTimelineSkeleton.ts → com/atproto/temp/checkSignupQueue.ts} +4 -8
  35. package/src/mod-service/index.ts +142 -64
  36. package/src/mod-service/status.ts +3 -2
  37. package/src/mod-service/subject.ts +9 -2
  38. package/src/mod-service/types.ts +4 -0
  39. package/src/mod-service/views.ts +1 -1
  40. package/tests/__snapshots__/get-record.test.ts.snap +16 -0
  41. package/tests/__snapshots__/get-repo.test.ts.snap +9 -1
  42. package/tests/moderation-appeals.test.ts +1 -1
  43. package/tests/moderation-events.test.ts +161 -8
  44. package/tests/moderation-statuses.test.ts +55 -0
  45. package/tests/moderation.test.ts +133 -34
@@ -68,6 +68,7 @@ import * as ComAtprotoSyncListRepos from './types/com/atproto/sync/listRepos';
68
68
  import * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOfUpdate';
69
69
  import * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl';
70
70
  import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos';
71
+ import * as ComAtprotoTempCheckSignupQueue from './types/com/atproto/temp/checkSignupQueue';
71
72
  import * as ComAtprotoTempFetchLabels from './types/com/atproto/temp/fetchLabels';
72
73
  import * as ComAtprotoTempImportRepo from './types/com/atproto/temp/importRepo';
73
74
  import * as ComAtprotoTempPushBlob from './types/com/atproto/temp/pushBlob';
@@ -116,7 +117,6 @@ import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/
116
117
  import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen';
117
118
  import * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators';
118
119
  import * as AppBskyUnspeccedGetTaggedSuggestions from './types/app/bsky/unspecced/getTaggedSuggestions';
119
- import * as AppBskyUnspeccedGetTimelineSkeleton from './types/app/bsky/unspecced/getTimelineSkeleton';
120
120
  import * as AppBskyUnspeccedSearchActorsSkeleton from './types/app/bsky/unspecced/searchActorsSkeleton';
121
121
  import * as AppBskyUnspeccedSearchPostsSkeleton from './types/app/bsky/unspecced/searchPostsSkeleton';
122
122
  export declare const COM_ATPROTO_ADMIN: {
@@ -261,6 +261,7 @@ export declare class ComAtprotoSyncNS {
261
261
  export declare class ComAtprotoTempNS {
262
262
  _server: Server;
263
263
  constructor(server: Server);
264
+ checkSignupQueue<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoTempCheckSignupQueue.Handler<ExtractAuth<AV>>, ComAtprotoTempCheckSignupQueue.HandlerReqCtx<ExtractAuth<AV>>>): void;
264
265
  fetchLabels<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoTempFetchLabels.Handler<ExtractAuth<AV>>, ComAtprotoTempFetchLabels.HandlerReqCtx<ExtractAuth<AV>>>): void;
265
266
  importRepo<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoTempImportRepo.Handler<ExtractAuth<AV>>, ComAtprotoTempImportRepo.HandlerReqCtx<ExtractAuth<AV>>>): void;
266
267
  pushBlob<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoTempPushBlob.Handler<ExtractAuth<AV>>, ComAtprotoTempPushBlob.HandlerReqCtx<ExtractAuth<AV>>>): void;
@@ -353,7 +354,6 @@ export declare class AppBskyUnspeccedNS {
353
354
  constructor(server: Server);
354
355
  getPopularFeedGenerators<AV extends AuthVerifier>(cfg: ConfigOf<AV, AppBskyUnspeccedGetPopularFeedGenerators.Handler<ExtractAuth<AV>>, AppBskyUnspeccedGetPopularFeedGenerators.HandlerReqCtx<ExtractAuth<AV>>>): void;
355
356
  getTaggedSuggestions<AV extends AuthVerifier>(cfg: ConfigOf<AV, AppBskyUnspeccedGetTaggedSuggestions.Handler<ExtractAuth<AV>>, AppBskyUnspeccedGetTaggedSuggestions.HandlerReqCtx<ExtractAuth<AV>>>): void;
356
- getTimelineSkeleton<AV extends AuthVerifier>(cfg: ConfigOf<AV, AppBskyUnspeccedGetTimelineSkeleton.Handler<ExtractAuth<AV>>, AppBskyUnspeccedGetTimelineSkeleton.HandlerReqCtx<ExtractAuth<AV>>>): void;
357
357
  searchActorsSkeleton<AV extends AuthVerifier>(cfg: ConfigOf<AV, AppBskyUnspeccedSearchActorsSkeleton.Handler<ExtractAuth<AV>>, AppBskyUnspeccedSearchActorsSkeleton.HandlerReqCtx<ExtractAuth<AV>>>): void;
358
358
  searchPostsSkeleton<AV extends AuthVerifier>(cfg: ConfigOf<AV, AppBskyUnspeccedSearchPostsSkeleton.Handler<ExtractAuth<AV>>, AppBskyUnspeccedSearchPostsSkeleton.HandlerReqCtx<ExtractAuth<AV>>>): void;
359
359
  }
@@ -1296,6 +1296,16 @@ export declare const schemaDict: {
1296
1296
  enum: string[];
1297
1297
  description: string;
1298
1298
  };
1299
+ createdAfter: {
1300
+ type: string;
1301
+ format: string;
1302
+ description: string;
1303
+ };
1304
+ createdBefore: {
1305
+ type: string;
1306
+ format: string;
1307
+ description: string;
1308
+ };
1299
1309
  subject: {
1300
1310
  type: string;
1301
1311
  format: string;
@@ -1311,6 +1321,34 @@ export declare const schemaDict: {
1311
1321
  maximum: number;
1312
1322
  default: number;
1313
1323
  };
1324
+ hasComment: {
1325
+ type: string;
1326
+ description: string;
1327
+ };
1328
+ comment: {
1329
+ type: string;
1330
+ description: string;
1331
+ };
1332
+ addedLabels: {
1333
+ type: string;
1334
+ items: {
1335
+ type: string;
1336
+ };
1337
+ description: string;
1338
+ };
1339
+ removedLabels: {
1340
+ type: string;
1341
+ items: {
1342
+ type: string;
1343
+ };
1344
+ description: string;
1345
+ };
1346
+ reportTypes: {
1347
+ type: string;
1348
+ items: {
1349
+ type: string;
1350
+ };
1351
+ };
1314
1352
  cursor: {
1315
1353
  type: string;
1316
1354
  };
@@ -3906,6 +3944,34 @@ export declare const schemaDict: {
3906
3944
  };
3907
3945
  };
3908
3946
  };
3947
+ ComAtprotoTempCheckSignupQueue: {
3948
+ lexicon: number;
3949
+ id: string;
3950
+ defs: {
3951
+ main: {
3952
+ type: string;
3953
+ description: string;
3954
+ output: {
3955
+ encoding: string;
3956
+ schema: {
3957
+ type: string;
3958
+ required: string[];
3959
+ properties: {
3960
+ activated: {
3961
+ type: string;
3962
+ };
3963
+ placeInQueue: {
3964
+ type: string;
3965
+ };
3966
+ estimatedTimeMs: {
3967
+ type: string;
3968
+ };
3969
+ };
3970
+ };
3971
+ };
3972
+ };
3973
+ };
3974
+ };
3909
3975
  ComAtprotoTempFetchLabels: {
3910
3976
  lexicon: number;
3911
3977
  id: string;
@@ -7574,52 +7640,6 @@ export declare const schemaDict: {
7574
7640
  };
7575
7641
  };
7576
7642
  };
7577
- AppBskyUnspeccedGetTimelineSkeleton: {
7578
- lexicon: number;
7579
- id: string;
7580
- defs: {
7581
- main: {
7582
- type: string;
7583
- description: string;
7584
- parameters: {
7585
- type: string;
7586
- properties: {
7587
- limit: {
7588
- type: string;
7589
- minimum: number;
7590
- maximum: number;
7591
- default: number;
7592
- };
7593
- cursor: {
7594
- type: string;
7595
- };
7596
- };
7597
- };
7598
- output: {
7599
- encoding: string;
7600
- schema: {
7601
- type: string;
7602
- required: string[];
7603
- properties: {
7604
- cursor: {
7605
- type: string;
7606
- };
7607
- feed: {
7608
- type: string;
7609
- items: {
7610
- type: string;
7611
- ref: string;
7612
- };
7613
- };
7614
- };
7615
- };
7616
- };
7617
- errors: {
7618
- name: string;
7619
- }[];
7620
- };
7621
- };
7622
- };
7623
7643
  AppBskyUnspeccedSearchActorsSkeleton: {
7624
7644
  lexicon: number;
7625
7645
  id: string;
@@ -7814,6 +7834,7 @@ export declare const ids: {
7814
7834
  ComAtprotoSyncNotifyOfUpdate: string;
7815
7835
  ComAtprotoSyncRequestCrawl: string;
7816
7836
  ComAtprotoSyncSubscribeRepos: string;
7837
+ ComAtprotoTempCheckSignupQueue: string;
7817
7838
  ComAtprotoTempFetchLabels: string;
7818
7839
  ComAtprotoTempImportRepo: string;
7819
7840
  ComAtprotoTempPushBlob: string;
@@ -7882,7 +7903,6 @@ export declare const ids: {
7882
7903
  AppBskyUnspeccedDefs: string;
7883
7904
  AppBskyUnspeccedGetPopularFeedGenerators: string;
7884
7905
  AppBskyUnspeccedGetTaggedSuggestions: string;
7885
- AppBskyUnspeccedGetTimelineSkeleton: string;
7886
7906
  AppBskyUnspeccedSearchActorsSkeleton: string;
7887
7907
  AppBskyUnspeccedSearchPostsSkeleton: string;
7888
7908
  };
@@ -12,7 +12,7 @@ export declare function isStatusAttr(v: unknown): v is StatusAttr;
12
12
  export declare function validateStatusAttr(v: unknown): ValidationResult;
13
13
  export interface ModEventView {
14
14
  id: number;
15
- event: ModEventTakedown | ModEventReverseTakedown | ModEventComment | ModEventReport | ModEventLabel | ModEventAcknowledge | ModEventEscalate | ModEventMute | ModEventEmail | {
15
+ event: ModEventTakedown | ModEventReverseTakedown | ModEventComment | ModEventReport | ModEventLabel | ModEventAcknowledge | ModEventEscalate | ModEventMute | ModEventEmail | ModEventResolveAppeal | {
16
16
  $type: string;
17
17
  [k: string]: unknown;
18
18
  };
@@ -31,7 +31,7 @@ export declare function isModEventView(v: unknown): v is ModEventView;
31
31
  export declare function validateModEventView(v: unknown): ValidationResult;
32
32
  export interface ModEventViewDetail {
33
33
  id: number;
34
- event: ModEventTakedown | ModEventReverseTakedown | ModEventComment | ModEventReport | ModEventLabel | ModEventAcknowledge | ModEventEscalate | ModEventMute | ModEventResolveAppeal | {
34
+ event: ModEventTakedown | ModEventReverseTakedown | ModEventComment | ModEventReport | ModEventLabel | ModEventAcknowledge | ModEventEscalate | ModEventMute | ModEventEmail | ModEventResolveAppeal | {
35
35
  $type: string;
36
36
  [k: string]: unknown;
37
37
  };
@@ -5,9 +5,16 @@ export interface QueryParams {
5
5
  types?: string[];
6
6
  createdBy?: string;
7
7
  sortDirection: 'asc' | 'desc';
8
+ createdAfter?: string;
9
+ createdBefore?: string;
8
10
  subject?: string;
9
11
  includeAllUserRecords: boolean;
10
12
  limit: number;
13
+ hasComment?: boolean;
14
+ comment?: string;
15
+ addedLabels?: string[];
16
+ removedLabels?: string[];
17
+ reportTypes?: string[];
11
18
  cursor?: string;
12
19
  }
13
20
  export type InputSchema = undefined;
@@ -1,14 +1,12 @@
1
1
  import express from 'express';
2
2
  import { HandlerAuth } from '@atproto/xrpc-server';
3
- import * as AppBskyFeedDefs from '../feed/defs';
4
3
  export interface QueryParams {
5
- limit: number;
6
- cursor?: string;
7
4
  }
8
5
  export type InputSchema = undefined;
9
6
  export interface OutputSchema {
10
- cursor?: string;
11
- feed: AppBskyFeedDefs.SkeletonFeedPost[];
7
+ activated: boolean;
8
+ placeInQueue?: number;
9
+ estimatedTimeMs?: number;
12
10
  [k: string]: unknown;
13
11
  }
14
12
  export type HandlerInput = undefined;
@@ -22,7 +20,6 @@ export interface HandlerSuccess {
22
20
  export interface HandlerError {
23
21
  status: number;
24
22
  message?: string;
25
- error?: 'UnknownFeed';
26
23
  }
27
24
  export type HandlerOutput = HandlerError | HandlerSuccess;
28
25
  export type HandlerReqCtx<HA extends HandlerAuth = never> = {
@@ -18,8 +18,9 @@ export declare class ModerationService {
18
18
  eventPusher: EventPusher;
19
19
  appviewAgent: AtpAgent;
20
20
  private appviewAuth;
21
- constructor(db: Database, backgroundQueue: BackgroundQueue, eventPusher: EventPusher, appviewAgent: AtpAgent, appviewAuth: AppviewAuth);
22
- static creator(backgroundQueue: BackgroundQueue, eventPusher: EventPusher, appviewAgent: AtpAgent, appviewAuth: AppviewAuth): (db: Database) => ModerationService;
21
+ serverDid: string;
22
+ constructor(db: Database, backgroundQueue: BackgroundQueue, eventPusher: EventPusher, appviewAgent: AtpAgent, appviewAuth: AppviewAuth, serverDid: string);
23
+ static creator(backgroundQueue: BackgroundQueue, eventPusher: EventPusher, appviewAgent: AtpAgent, appviewAuth: AppviewAuth, serverDid: string): (db: Database) => ModerationService;
23
24
  views: ModerationViews;
24
25
  getEvent(id: number): Promise<ModerationEventRow | undefined>;
25
26
  getEventOrThrow(id: number): Promise<ModerationEventRow>;
@@ -31,6 +32,13 @@ export declare class ModerationService {
31
32
  includeAllUserRecords: boolean;
32
33
  types: ModerationEvent['action'][];
33
34
  sortDirection?: 'asc' | 'desc';
35
+ hasComment?: boolean;
36
+ comment?: string;
37
+ createdAfter?: string;
38
+ createdBefore?: string;
39
+ addedLabels: string[];
40
+ removedLabels: string[];
41
+ reportTypes?: string[];
34
42
  }): Promise<{
35
43
  cursor?: string;
36
44
  events: ModerationEventRow[];
@@ -69,6 +77,7 @@ export declare class ModerationService {
69
77
  }): Promise<ModerationEventRow>;
70
78
  getLastReversibleEventForSubject(subject: ReversalSubject): Promise<{
71
79
  id: number;
80
+ subjectBlobCids: string[] | null;
72
81
  createdBy: string;
73
82
  createdAt: string;
74
83
  comment: string | null;
@@ -137,8 +146,8 @@ export declare class ModerationService {
137
146
  }[];
138
147
  cursor: string | undefined;
139
148
  }>;
140
- isSubjectTakendown(subject: ModSubject): Promise<boolean>;
141
- formatAndCreateLabels(src: string, uri: string, cid: string | null, labels: {
149
+ getStatus(subject: ModSubject): Promise<ModerationSubjectStatusRow | null>;
150
+ formatAndCreateLabels(uri: string, cid: string | null, labels: {
142
151
  create?: string[];
143
152
  negate?: string[];
144
153
  }): Promise<Label[]>;
@@ -13,6 +13,7 @@ type SubjectInfo = {
13
13
  subjectDid: string;
14
14
  subjectUri: string | null;
15
15
  subjectCid: string | null;
16
+ subjectBlobCids: string[] | null;
16
17
  };
17
18
  export interface ModSubject {
18
19
  did: string;
@@ -35,6 +36,7 @@ export declare class RepoSubject implements ModSubject {
35
36
  subjectDid: string;
36
37
  subjectUri: null;
37
38
  subjectCid: null;
39
+ subjectBlobCids: null;
38
40
  };
39
41
  lex(): RepoRef;
40
42
  }
@@ -53,6 +55,7 @@ export declare class RecordSubject implements ModSubject {
53
55
  subjectDid: string;
54
56
  subjectUri: string;
55
57
  subjectCid: string;
58
+ subjectBlobCids: string[];
56
59
  };
57
60
  lex(): StrongRef;
58
61
  }
@@ -17,3 +17,5 @@ export type ModerationSubjectStatusRowWithHandle = ModerationSubjectStatusRow &
17
17
  handle: string | null;
18
18
  };
19
19
  export type ModEventType = ComAtprotoAdminDefs.ModEventTakedown | ComAtprotoAdminDefs.ModEventAcknowledge | ComAtprotoAdminDefs.ModEventEscalate | ComAtprotoAdminDefs.ModEventComment | ComAtprotoAdminDefs.ModEventLabel | ComAtprotoAdminDefs.ModEventReport | ComAtprotoAdminDefs.ModEventMute | ComAtprotoAdminDefs.ModEventReverseTakedown;
20
+ export declare const UNSPECCED_TAKEDOWN_LABEL = "!unspecced-takedown";
21
+ export declare const UNSPECCED_TAKEDOWN_BLOBS_LABEL = "!unspecced-takedown-blobs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/ozone",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "license": "MIT",
5
5
  "description": "Backend service for moderating the Bluesky network.",
6
6
  "keywords": [
@@ -30,9 +30,9 @@
30
30
  "pino-http": "^8.2.1",
31
31
  "typed-emitter": "^2.1.0",
32
32
  "uint8arrays": "3.0.0",
33
- "@atproto/api": "^0.9.4",
34
- "@atproto/crypto": "^0.3.0",
33
+ "@atproto/api": "^0.9.6",
35
34
  "@atproto/common": "^0.3.3",
35
+ "@atproto/crypto": "^0.3.0",
36
36
  "@atproto/syntax": "^0.1.5",
37
37
  "@atproto/identity": "^0.3.2",
38
38
  "@atproto/lexicon": "^0.3.1",
@@ -46,10 +46,10 @@
46
46
  "@types/pg": "^8.6.6",
47
47
  "@types/qs": "^6.9.7",
48
48
  "axios": "^0.27.2",
49
- "@atproto/api": "^0.9.4",
50
- "@atproto/dev-env": "^0.2.27",
49
+ "@atproto/api": "^0.9.6",
50
+ "@atproto/dev-env": "^0.2.29",
51
51
  "@atproto/lex-cli": "^0.3.0",
52
- "@atproto/pds": "^0.3.15",
52
+ "@atproto/pds": "^0.3.17",
53
53
  "@atproto/xrpc": "^0.4.1"
54
54
  },
55
55
  "scripts": {
@@ -51,17 +51,21 @@ export default function (server: Server, ctx: AppContext) {
51
51
  }
52
52
 
53
53
  if (isTakedownEvent || isReverseTakedownEvent) {
54
- const isSubjectTakendown = await moderationService.isSubjectTakendown(
55
- subject,
56
- )
54
+ const status = await moderationService.getStatus(subject)
57
55
 
58
- if (isSubjectTakendown && isTakedownEvent) {
56
+ if (status?.takendown && isTakedownEvent) {
59
57
  throw new InvalidRequestError(`Subject is already taken down`)
60
58
  }
61
59
 
62
- if (!isSubjectTakendown && isReverseTakedownEvent) {
60
+ if (!status?.takendown && isReverseTakedownEvent) {
63
61
  throw new InvalidRequestError(`Subject is not taken down`)
64
62
  }
63
+
64
+ if (status?.takendown && isReverseTakedownEvent && subject.isRecord()) {
65
+ // due to the way blob status is modeled, we should reverse takedown on all
66
+ // blobs for the record being restored, which aren't taken down on another record.
67
+ subject.blobCids = status.blobCids ?? []
68
+ }
65
69
  }
66
70
 
67
71
  const moderationEvent = await db.transaction(async (dbTxn) => {
@@ -92,7 +96,6 @@ export default function (server: Server, ctx: AppContext) {
92
96
 
93
97
  if (isLabelEvent) {
94
98
  await moderationTxn.formatAndCreateLabels(
95
- ctx.cfg.service.did,
96
99
  result.subjectUri ?? result.subjectDid,
97
100
  result.subjectCid,
98
101
  {
@@ -13,7 +13,14 @@ export default function (server: Server, ctx: AppContext) {
13
13
  sortDirection = 'desc',
14
14
  types,
15
15
  includeAllUserRecords = false,
16
+ hasComment,
17
+ comment,
16
18
  createdBy,
19
+ createdAfter,
20
+ createdBefore,
21
+ addedLabels = [],
22
+ removedLabels = [],
23
+ reportTypes,
17
24
  } = params
18
25
  const db = ctx.db
19
26
  const modService = ctx.modService(db)
@@ -25,6 +32,13 @@ export default function (server: Server, ctx: AppContext) {
25
32
  cursor,
26
33
  sortDirection,
27
34
  includeAllUserRecords,
35
+ hasComment,
36
+ comment,
37
+ createdAfter,
38
+ createdBefore,
39
+ addedLabels,
40
+ removedLabels,
41
+ reportTypes,
28
42
  })
29
43
  return {
30
44
  encoding: 'application/json',
@@ -62,4 +62,5 @@ const eventTypes = new Set([
62
62
  'com.atproto.admin.defs#modEventUnmute',
63
63
  'com.atproto.admin.defs#modEventReverseTakedown',
64
64
  'com.atproto.admin.defs#modEventEmail',
65
+ 'com.atproto.admin.defs#modEventResolveAppeal',
65
66
  ])
@@ -1,29 +1,44 @@
1
1
  import { Server } from '../../lexicon'
2
2
  import AppContext from '../../context'
3
+ import {
4
+ UNSPECCED_TAKEDOWN_BLOBS_LABEL,
5
+ UNSPECCED_TAKEDOWN_LABEL,
6
+ } from '../../mod-service/types'
3
7
 
4
8
  export default function (server: Server, ctx: AppContext) {
5
- server.com.atproto.temp.fetchLabels(async ({ params }) => {
6
- const { limit } = params
7
- const since =
8
- params.since !== undefined ? new Date(params.since).toISOString() : ''
9
- const labelRes = await ctx.db.db
10
- .selectFrom('label')
11
- .selectAll()
12
- .orderBy('label.cts', 'asc')
13
- .where('cts', '>', since)
14
- .limit(limit)
15
- .execute()
9
+ server.com.atproto.temp.fetchLabels({
10
+ auth: ctx.authOptionalAccessOrRoleVerifier,
11
+ handler: async ({ auth, params }) => {
12
+ const { limit } = params
13
+ const since =
14
+ params.since !== undefined ? new Date(params.since).toISOString() : ''
15
+ const includeUnspeccedTakedowns =
16
+ auth.credentials.type === 'role' && auth.credentials.admin
17
+ const labelRes = await ctx.db.db
18
+ .selectFrom('label')
19
+ .selectAll()
20
+ .orderBy('label.cts', 'asc')
21
+ .where('cts', '>', since)
22
+ .if(!includeUnspeccedTakedowns, (q) =>
23
+ q.where('label.val', 'not in', [
24
+ UNSPECCED_TAKEDOWN_LABEL,
25
+ UNSPECCED_TAKEDOWN_BLOBS_LABEL,
26
+ ]),
27
+ )
28
+ .limit(limit)
29
+ .execute()
16
30
 
17
- const labels = labelRes.map((l) => ({
18
- ...l,
19
- cid: l.cid === '' ? undefined : l.cid,
20
- }))
31
+ const labels = labelRes.map((l) => ({
32
+ ...l,
33
+ cid: l.cid === '' ? undefined : l.cid,
34
+ }))
21
35
 
22
- return {
23
- encoding: 'application/json',
24
- body: {
25
- labels,
26
- },
27
- }
36
+ return {
37
+ encoding: 'application/json',
38
+ body: {
39
+ labels,
40
+ },
41
+ }
42
+ },
28
43
  })
29
44
  }
package/src/context.ts CHANGED
@@ -65,6 +65,7 @@ export class AppContext {
65
65
  eventPusher,
66
66
  appviewAgent,
67
67
  appviewAuth,
68
+ cfg.service.did,
68
69
  )
69
70
 
70
71
  const communicationTemplateService = CommunicationTemplateService.creator()
@@ -52,6 +52,7 @@ export class DaemonContext {
52
52
  eventPusher,
53
53
  appviewAgent,
54
54
  appviewAuth,
55
+ cfg.service.did,
55
56
  )
56
57
  const eventReverser = new EventReverser(db, modService)
57
58
 
@@ -0,0 +1,15 @@
1
+ import { Kysely } from 'kysely'
2
+
3
+ export async function up(db: Kysely<unknown>): Promise<void> {
4
+ await db.schema
5
+ .alterTable('moderation_event')
6
+ .addColumn('subjectBlobCids', 'jsonb')
7
+ .execute()
8
+ }
9
+
10
+ export async function down(db: Kysely<unknown>): Promise<void> {
11
+ await db.schema
12
+ .alterTable('moderation_event')
13
+ .dropColumn('subjectBlobCids')
14
+ .execute()
15
+ }
@@ -4,3 +4,4 @@
4
4
 
5
5
  export * as _20231219T205730722Z from './20231219T205730722Z-init'
6
6
  export * as _20240116T085607200Z from './20240116T085607200Z-communication-template'
7
+ export * as _20240201T051104136Z from './20240201T051104136Z-mod-event-blobs'
@@ -19,6 +19,7 @@ export interface ModerationEvent {
19
19
  subjectDid: string
20
20
  subjectUri: string | null
21
21
  subjectCid: string | null
22
+ subjectBlobCids: string[] | null
22
23
  createLabelVals: string | null
23
24
  negateLabelVals: string | null
24
25
  comment: string | null
package/src/db/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Pool as PgPool } from 'pg'
2
- import { DynamicModule, RawBuilder, SelectQueryBuilder } from 'kysely'
2
+ import { DynamicModule, RawBuilder, SelectQueryBuilder, sql } from 'kysely'
3
3
 
4
4
  export type DbRef = RawBuilder | ReturnType<DynamicModule['ref']>
5
5
 
@@ -13,3 +13,8 @@ export type PgOptions = {
13
13
  poolMaxUses?: number
14
14
  poolIdleTimeoutMs?: number
15
15
  }
16
+
17
+ export const jsonb = <T>(val: T) => {
18
+ if (val === null) return sql<T>`null`
19
+ return sql<T>`${JSON.stringify(val)}::jsonb`
20
+ }
@@ -78,6 +78,7 @@ import * as ComAtprotoSyncListRepos from './types/com/atproto/sync/listRepos'
78
78
  import * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOfUpdate'
79
79
  import * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl'
80
80
  import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos'
81
+ import * as ComAtprotoTempCheckSignupQueue from './types/com/atproto/temp/checkSignupQueue'
81
82
  import * as ComAtprotoTempFetchLabels from './types/com/atproto/temp/fetchLabels'
82
83
  import * as ComAtprotoTempImportRepo from './types/com/atproto/temp/importRepo'
83
84
  import * as ComAtprotoTempPushBlob from './types/com/atproto/temp/pushBlob'
@@ -126,7 +127,6 @@ import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/
126
127
  import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
127
128
  import * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
128
129
  import * as AppBskyUnspeccedGetTaggedSuggestions from './types/app/bsky/unspecced/getTaggedSuggestions'
129
- import * as AppBskyUnspeccedGetTimelineSkeleton from './types/app/bsky/unspecced/getTimelineSkeleton'
130
130
  import * as AppBskyUnspeccedSearchActorsSkeleton from './types/app/bsky/unspecced/searchActorsSkeleton'
131
131
  import * as AppBskyUnspeccedSearchPostsSkeleton from './types/app/bsky/unspecced/searchPostsSkeleton'
132
132
 
@@ -1021,6 +1021,17 @@ export class ComAtprotoTempNS {
1021
1021
  this._server = server
1022
1022
  }
1023
1023
 
1024
+ checkSignupQueue<AV extends AuthVerifier>(
1025
+ cfg: ConfigOf<
1026
+ AV,
1027
+ ComAtprotoTempCheckSignupQueue.Handler<ExtractAuth<AV>>,
1028
+ ComAtprotoTempCheckSignupQueue.HandlerReqCtx<ExtractAuth<AV>>
1029
+ >,
1030
+ ) {
1031
+ const nsid = 'com.atproto.temp.checkSignupQueue' // @ts-ignore
1032
+ return this._server.xrpc.method(nsid, cfg)
1033
+ }
1034
+
1024
1035
  fetchLabels<AV extends AuthVerifier>(
1025
1036
  cfg: ConfigOf<
1026
1037
  AV,
@@ -1637,17 +1648,6 @@ export class AppBskyUnspeccedNS {
1637
1648
  return this._server.xrpc.method(nsid, cfg)
1638
1649
  }
1639
1650
 
1640
- getTimelineSkeleton<AV extends AuthVerifier>(
1641
- cfg: ConfigOf<
1642
- AV,
1643
- AppBskyUnspeccedGetTimelineSkeleton.Handler<ExtractAuth<AV>>,
1644
- AppBskyUnspeccedGetTimelineSkeleton.HandlerReqCtx<ExtractAuth<AV>>
1645
- >,
1646
- ) {
1647
- const nsid = 'app.bsky.unspecced.getTimelineSkeleton' // @ts-ignore
1648
- return this._server.xrpc.method(nsid, cfg)
1649
- }
1650
-
1651
1651
  searchActorsSkeleton<AV extends AuthVerifier>(
1652
1652
  cfg: ConfigOf<
1653
1653
  AV,