@atproto/ozone 0.0.2 → 0.0.4

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 (73) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/api/admin/listCommunicationTemplates.d.ts +3 -0
  3. package/dist/api/admin/updateCommunicationTemplate.d.ts +3 -0
  4. package/dist/communication-service/template.d.ts +18 -0
  5. package/dist/context.d.ts +3 -0
  6. package/dist/db/index.js +18 -1
  7. package/dist/db/index.js.map +3 -3
  8. package/dist/db/migrations/20240116T085607200Z-communication-template.d.ts +3 -0
  9. package/dist/db/migrations/index.d.ts +1 -0
  10. package/dist/db/schema/communication_template.d.ts +15 -0
  11. package/dist/db/schema/index.d.ts +2 -1
  12. package/dist/index.js +861 -240
  13. package/dist/index.js.map +3 -3
  14. package/dist/lexicon/index.d.ts +8 -0
  15. package/dist/lexicon/lexicons.d.ts +182 -0
  16. package/dist/lexicon/types/{app/bsky/unspecced/getPopular.d.ts → com/atproto/admin/createCommunicationTemplate.d.ts} +11 -9
  17. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +13 -0
  18. package/dist/lexicon/types/com/atproto/admin/deleteCommunicationTemplate.d.ts +25 -0
  19. package/dist/lexicon/types/{app/bsky/moderation/getServices.d.ts → com/atproto/admin/listCommunicationTemplates.d.ts} +2 -3
  20. package/dist/lexicon/types/{app/bsky/moderation/getService.d.ts → com/atproto/admin/updateCommunicationTemplate.d.ts} +15 -5
  21. package/package.json +8 -8
  22. package/src/api/admin/createCommunicationTemplate.ts +37 -0
  23. package/src/api/admin/deleteCommunicationTemplate.ts +23 -0
  24. package/src/api/admin/listCommunicationTemplates.ts +31 -0
  25. package/src/api/admin/updateCommunicationTemplate.ts +40 -0
  26. package/src/api/index.ts +8 -0
  27. package/src/communication-service/template.ts +105 -0
  28. package/src/context.ts +12 -0
  29. package/src/db/migrations/20240116T085607200Z-communication-template.ts +23 -0
  30. package/src/db/migrations/index.ts +1 -0
  31. package/src/db/schema/communication_template.ts +18 -0
  32. package/src/db/schema/index.ts +3 -1
  33. package/src/lexicon/index.ts +48 -0
  34. package/src/lexicon/lexicons.ts +199 -0
  35. package/src/lexicon/types/com/atproto/admin/createCommunicationTemplate.ts +54 -0
  36. package/src/lexicon/types/com/atproto/admin/defs.ts +35 -0
  37. package/src/lexicon/types/com/atproto/admin/deleteCommunicationTemplate.ts +38 -0
  38. package/src/lexicon/types/com/atproto/admin/listCommunicationTemplates.ts +44 -0
  39. package/src/lexicon/types/com/atproto/admin/updateCommunicationTemplate.ts +57 -0
  40. package/tests/communication-templates.test.ts +131 -0
  41. package/dist/api/com/atproto/admin/emitModerationEvent.d.ts +0 -3
  42. package/dist/api/com/atproto/admin/getModerationEvent.d.ts +0 -3
  43. package/dist/api/com/atproto/admin/getRecord.d.ts +0 -3
  44. package/dist/api/com/atproto/admin/getRepo.d.ts +0 -3
  45. package/dist/api/com/atproto/admin/queryModerationEvents.d.ts +0 -3
  46. package/dist/api/com/atproto/admin/queryModerationStatuses.d.ts +0 -3
  47. package/dist/api/com/atproto/admin/searchRepos.d.ts +0 -3
  48. package/dist/api/com/atproto/admin/util.d.ts +0 -5
  49. package/dist/api/com/atproto/moderation/createReport.d.ts +0 -3
  50. package/dist/api/com/atproto/moderation/util.d.ts +0 -4
  51. package/dist/api/com/atproto/temp/fetchLabels.d.ts +0 -3
  52. package/dist/api/util.d.ts +0 -2
  53. package/dist/auth-verifier.d.ts +0 -47
  54. package/dist/config.d.ts +0 -42
  55. package/dist/daemon/config.d.ts +0 -23
  56. package/dist/lexicon/types/app/bsky/moderation/defs.d.ts +0 -49
  57. package/dist/lexicon/types/app/bsky/moderation/service.d.ts +0 -17
  58. package/dist/sequencer/index.d.ts +0 -2
  59. package/dist/sequencer/outbox.d.ts +0 -16
  60. package/dist/sequencer/sequencer.d.ts +0 -35
  61. package/dist/services/index.d.ts +0 -7
  62. package/dist/services/moderation/index.d.ts +0 -144
  63. package/dist/services/moderation/status.d.ts +0 -12
  64. package/dist/services/moderation/subject.d.ts +0 -60
  65. package/dist/services/moderation/types.d.ts +0 -19
  66. package/dist/services/moderation/views.d.ts +0 -42
  67. package/dist/services/types.d.ts +0 -2
  68. package/dist/util/date.d.ts +0 -1
  69. package/dist/util/debug.d.ts +0 -1
  70. package/dist/util/retry.d.ts +0 -3
  71. package/test.log +0 -0
  72. /package/dist/api/{label/queryLabels.d.ts → admin/createCommunicationTemplate.d.ts} +0 -0
  73. /package/dist/api/{label/subscribeLabels.d.ts → admin/deleteCommunicationTemplate.d.ts} +0 -0
@@ -1,5 +1,7 @@
1
1
  import { Server as XrpcServer, Options as XrpcOptions, AuthVerifier, StreamAuthVerifier } from '@atproto/xrpc-server';
2
+ import * as ComAtprotoAdminCreateCommunicationTemplate from './types/com/atproto/admin/createCommunicationTemplate';
2
3
  import * as ComAtprotoAdminDeleteAccount from './types/com/atproto/admin/deleteAccount';
4
+ import * as ComAtprotoAdminDeleteCommunicationTemplate from './types/com/atproto/admin/deleteCommunicationTemplate';
3
5
  import * as ComAtprotoAdminDisableAccountInvites from './types/com/atproto/admin/disableAccountInvites';
4
6
  import * as ComAtprotoAdminDisableInviteCodes from './types/com/atproto/admin/disableInviteCodes';
5
7
  import * as ComAtprotoAdminEmitModerationEvent from './types/com/atproto/admin/emitModerationEvent';
@@ -11,12 +13,14 @@ import * as ComAtprotoAdminGetModerationEvent from './types/com/atproto/admin/ge
11
13
  import * as ComAtprotoAdminGetRecord from './types/com/atproto/admin/getRecord';
12
14
  import * as ComAtprotoAdminGetRepo from './types/com/atproto/admin/getRepo';
13
15
  import * as ComAtprotoAdminGetSubjectStatus from './types/com/atproto/admin/getSubjectStatus';
16
+ import * as ComAtprotoAdminListCommunicationTemplates from './types/com/atproto/admin/listCommunicationTemplates';
14
17
  import * as ComAtprotoAdminQueryModerationEvents from './types/com/atproto/admin/queryModerationEvents';
15
18
  import * as ComAtprotoAdminQueryModerationStatuses from './types/com/atproto/admin/queryModerationStatuses';
16
19
  import * as ComAtprotoAdminSearchRepos from './types/com/atproto/admin/searchRepos';
17
20
  import * as ComAtprotoAdminSendEmail from './types/com/atproto/admin/sendEmail';
18
21
  import * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/updateAccountEmail';
19
22
  import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle';
23
+ import * as ComAtprotoAdminUpdateCommunicationTemplate from './types/com/atproto/admin/updateCommunicationTemplate';
20
24
  import * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus';
21
25
  import * as ComAtprotoIdentityResolveHandle from './types/com/atproto/identity/resolveHandle';
22
26
  import * as ComAtprotoIdentityUpdateHandle from './types/com/atproto/identity/updateHandle';
@@ -158,7 +162,9 @@ export declare class ComAtprotoNS {
158
162
  export declare class ComAtprotoAdminNS {
159
163
  _server: Server;
160
164
  constructor(server: Server);
165
+ createCommunicationTemplate<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminCreateCommunicationTemplate.Handler<ExtractAuth<AV>>, ComAtprotoAdminCreateCommunicationTemplate.HandlerReqCtx<ExtractAuth<AV>>>): void;
161
166
  deleteAccount<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminDeleteAccount.Handler<ExtractAuth<AV>>, ComAtprotoAdminDeleteAccount.HandlerReqCtx<ExtractAuth<AV>>>): void;
167
+ deleteCommunicationTemplate<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminDeleteCommunicationTemplate.Handler<ExtractAuth<AV>>, ComAtprotoAdminDeleteCommunicationTemplate.HandlerReqCtx<ExtractAuth<AV>>>): void;
162
168
  disableAccountInvites<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminDisableAccountInvites.Handler<ExtractAuth<AV>>, ComAtprotoAdminDisableAccountInvites.HandlerReqCtx<ExtractAuth<AV>>>): void;
163
169
  disableInviteCodes<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminDisableInviteCodes.Handler<ExtractAuth<AV>>, ComAtprotoAdminDisableInviteCodes.HandlerReqCtx<ExtractAuth<AV>>>): void;
164
170
  emitModerationEvent<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminEmitModerationEvent.Handler<ExtractAuth<AV>>, ComAtprotoAdminEmitModerationEvent.HandlerReqCtx<ExtractAuth<AV>>>): void;
@@ -170,12 +176,14 @@ export declare class ComAtprotoAdminNS {
170
176
  getRecord<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminGetRecord.Handler<ExtractAuth<AV>>, ComAtprotoAdminGetRecord.HandlerReqCtx<ExtractAuth<AV>>>): void;
171
177
  getRepo<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminGetRepo.Handler<ExtractAuth<AV>>, ComAtprotoAdminGetRepo.HandlerReqCtx<ExtractAuth<AV>>>): void;
172
178
  getSubjectStatus<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminGetSubjectStatus.Handler<ExtractAuth<AV>>, ComAtprotoAdminGetSubjectStatus.HandlerReqCtx<ExtractAuth<AV>>>): void;
179
+ listCommunicationTemplates<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminListCommunicationTemplates.Handler<ExtractAuth<AV>>, ComAtprotoAdminListCommunicationTemplates.HandlerReqCtx<ExtractAuth<AV>>>): void;
173
180
  queryModerationEvents<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminQueryModerationEvents.Handler<ExtractAuth<AV>>, ComAtprotoAdminQueryModerationEvents.HandlerReqCtx<ExtractAuth<AV>>>): void;
174
181
  queryModerationStatuses<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminQueryModerationStatuses.Handler<ExtractAuth<AV>>, ComAtprotoAdminQueryModerationStatuses.HandlerReqCtx<ExtractAuth<AV>>>): void;
175
182
  searchRepos<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminSearchRepos.Handler<ExtractAuth<AV>>, ComAtprotoAdminSearchRepos.HandlerReqCtx<ExtractAuth<AV>>>): void;
176
183
  sendEmail<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminSendEmail.Handler<ExtractAuth<AV>>, ComAtprotoAdminSendEmail.HandlerReqCtx<ExtractAuth<AV>>>): void;
177
184
  updateAccountEmail<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminUpdateAccountEmail.Handler<ExtractAuth<AV>>, ComAtprotoAdminUpdateAccountEmail.HandlerReqCtx<ExtractAuth<AV>>>): void;
178
185
  updateAccountHandle<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminUpdateAccountHandle.Handler<ExtractAuth<AV>>, ComAtprotoAdminUpdateAccountHandle.HandlerReqCtx<ExtractAuth<AV>>>): void;
186
+ updateCommunicationTemplate<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminUpdateCommunicationTemplate.Handler<ExtractAuth<AV>>, ComAtprotoAdminUpdateCommunicationTemplate.HandlerReqCtx<ExtractAuth<AV>>>): void;
179
187
  updateSubjectStatus<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminUpdateSubjectStatus.Handler<ExtractAuth<AV>>, ComAtprotoAdminUpdateSubjectStatus.HandlerReqCtx<ExtractAuth<AV>>>): void;
180
188
  }
181
189
  export declare class ComAtprotoIdentityNS {
@@ -1,5 +1,48 @@
1
1
  import { LexiconDoc, Lexicons } from '@atproto/lexicon';
2
2
  export declare const schemaDict: {
3
+ ComAtprotoAdminCreateCommunicationTemplate: {
4
+ lexicon: number;
5
+ id: string;
6
+ defs: {
7
+ main: {
8
+ type: string;
9
+ description: string;
10
+ input: {
11
+ encoding: string;
12
+ schema: {
13
+ type: string;
14
+ required: string[];
15
+ properties: {
16
+ name: {
17
+ type: string;
18
+ description: string;
19
+ };
20
+ contentMarkdown: {
21
+ type: string;
22
+ description: string;
23
+ };
24
+ subject: {
25
+ type: string;
26
+ description: string;
27
+ };
28
+ createdBy: {
29
+ type: string;
30
+ format: string;
31
+ description: string;
32
+ };
33
+ };
34
+ };
35
+ };
36
+ output: {
37
+ encoding: string;
38
+ schema: {
39
+ type: string;
40
+ ref: string;
41
+ };
42
+ };
43
+ };
44
+ };
45
+ };
3
46
  ComAtprotoAdminDefs: {
4
47
  lexicon: number;
5
48
  id: string;
@@ -736,6 +779,43 @@ export declare const schemaDict: {
736
779
  };
737
780
  };
738
781
  };
782
+ communicationTemplateView: {
783
+ type: string;
784
+ required: string[];
785
+ properties: {
786
+ id: {
787
+ type: string;
788
+ };
789
+ name: {
790
+ type: string;
791
+ description: string;
792
+ };
793
+ subject: {
794
+ type: string;
795
+ description: string;
796
+ };
797
+ contentMarkdown: {
798
+ type: string;
799
+ description: string;
800
+ };
801
+ disabled: {
802
+ type: string;
803
+ };
804
+ lastUpdatedBy: {
805
+ type: string;
806
+ format: string;
807
+ description: string;
808
+ };
809
+ createdAt: {
810
+ type: string;
811
+ format: string;
812
+ };
813
+ updatedAt: {
814
+ type: string;
815
+ format: string;
816
+ };
817
+ };
818
+ };
739
819
  };
740
820
  };
741
821
  ComAtprotoAdminDeleteAccount: {
@@ -761,6 +841,28 @@ export declare const schemaDict: {
761
841
  };
762
842
  };
763
843
  };
844
+ ComAtprotoAdminDeleteCommunicationTemplate: {
845
+ lexicon: number;
846
+ id: string;
847
+ defs: {
848
+ main: {
849
+ type: string;
850
+ description: string;
851
+ input: {
852
+ encoding: string;
853
+ schema: {
854
+ type: string;
855
+ required: string[];
856
+ properties: {
857
+ id: {
858
+ type: string;
859
+ };
860
+ };
861
+ };
862
+ };
863
+ };
864
+ };
865
+ };
764
866
  ComAtprotoAdminDisableAccountInvites: {
765
867
  lexicon: number;
766
868
  id: string;
@@ -1141,6 +1243,32 @@ export declare const schemaDict: {
1141
1243
  };
1142
1244
  };
1143
1245
  };
1246
+ ComAtprotoAdminListCommunicationTemplates: {
1247
+ lexicon: number;
1248
+ id: string;
1249
+ defs: {
1250
+ main: {
1251
+ type: string;
1252
+ description: string;
1253
+ output: {
1254
+ encoding: string;
1255
+ schema: {
1256
+ type: string;
1257
+ required: string[];
1258
+ properties: {
1259
+ communicationTemplates: {
1260
+ type: string;
1261
+ items: {
1262
+ type: string;
1263
+ ref: string;
1264
+ };
1265
+ };
1266
+ };
1267
+ };
1268
+ };
1269
+ };
1270
+ };
1271
+ };
1144
1272
  ComAtprotoAdminQueryModerationEvents: {
1145
1273
  lexicon: number;
1146
1274
  id: string;
@@ -1472,6 +1600,56 @@ export declare const schemaDict: {
1472
1600
  };
1473
1601
  };
1474
1602
  };
1603
+ ComAtprotoAdminUpdateCommunicationTemplate: {
1604
+ lexicon: number;
1605
+ id: string;
1606
+ defs: {
1607
+ main: {
1608
+ type: string;
1609
+ description: string;
1610
+ input: {
1611
+ encoding: string;
1612
+ schema: {
1613
+ type: string;
1614
+ required: string[];
1615
+ properties: {
1616
+ id: {
1617
+ type: string;
1618
+ description: string;
1619
+ };
1620
+ name: {
1621
+ type: string;
1622
+ description: string;
1623
+ };
1624
+ contentMarkdown: {
1625
+ type: string;
1626
+ description: string;
1627
+ };
1628
+ subject: {
1629
+ type: string;
1630
+ description: string;
1631
+ };
1632
+ updatedBy: {
1633
+ type: string;
1634
+ format: string;
1635
+ description: string;
1636
+ };
1637
+ disabled: {
1638
+ type: string;
1639
+ };
1640
+ };
1641
+ };
1642
+ };
1643
+ output: {
1644
+ encoding: string;
1645
+ schema: {
1646
+ type: string;
1647
+ ref: string;
1648
+ };
1649
+ };
1650
+ };
1651
+ };
1652
+ };
1475
1653
  ComAtprotoAdminUpdateSubjectStatus: {
1476
1654
  lexicon: number;
1477
1655
  id: string;
@@ -7411,8 +7589,10 @@ export declare const schemaDict: {
7411
7589
  export declare const schemas: LexiconDoc[];
7412
7590
  export declare const lexicons: Lexicons;
7413
7591
  export declare const ids: {
7592
+ ComAtprotoAdminCreateCommunicationTemplate: string;
7414
7593
  ComAtprotoAdminDefs: string;
7415
7594
  ComAtprotoAdminDeleteAccount: string;
7595
+ ComAtprotoAdminDeleteCommunicationTemplate: string;
7416
7596
  ComAtprotoAdminDisableAccountInvites: string;
7417
7597
  ComAtprotoAdminDisableInviteCodes: string;
7418
7598
  ComAtprotoAdminEmitModerationEvent: string;
@@ -7424,12 +7604,14 @@ export declare const ids: {
7424
7604
  ComAtprotoAdminGetRecord: string;
7425
7605
  ComAtprotoAdminGetRepo: string;
7426
7606
  ComAtprotoAdminGetSubjectStatus: string;
7607
+ ComAtprotoAdminListCommunicationTemplates: string;
7427
7608
  ComAtprotoAdminQueryModerationEvents: string;
7428
7609
  ComAtprotoAdminQueryModerationStatuses: string;
7429
7610
  ComAtprotoAdminSearchRepos: string;
7430
7611
  ComAtprotoAdminSendEmail: string;
7431
7612
  ComAtprotoAdminUpdateAccountEmail: string;
7432
7613
  ComAtprotoAdminUpdateAccountHandle: string;
7614
+ ComAtprotoAdminUpdateCommunicationTemplate: string;
7433
7615
  ComAtprotoAdminUpdateSubjectStatus: string;
7434
7616
  ComAtprotoIdentityResolveHandle: string;
7435
7617
  ComAtprotoIdentityUpdateHandle: string;
@@ -1,18 +1,20 @@
1
1
  import express from 'express';
2
2
  import { HandlerAuth } from '@atproto/xrpc-server';
3
- import * as AppBskyFeedDefs from '../feed/defs';
3
+ import * as ComAtprotoAdminDefs from './defs';
4
4
  export interface QueryParams {
5
- includeNsfw: boolean;
6
- limit: number;
7
- cursor?: string;
8
5
  }
9
- export type InputSchema = undefined;
10
- export interface OutputSchema {
11
- cursor?: string;
12
- feed: AppBskyFeedDefs.FeedViewPost[];
6
+ export interface InputSchema {
7
+ name: string;
8
+ contentMarkdown: string;
9
+ subject: string;
10
+ createdBy?: string;
13
11
  [k: string]: unknown;
14
12
  }
15
- export type HandlerInput = undefined;
13
+ export type OutputSchema = ComAtprotoAdminDefs.CommunicationTemplateView;
14
+ export interface HandlerInput {
15
+ encoding: 'application/json';
16
+ body: InputSchema;
17
+ }
16
18
  export interface HandlerSuccess {
17
19
  encoding: 'application/json';
18
20
  body: OutputSchema;
@@ -317,3 +317,16 @@ export interface ModEventEmail {
317
317
  }
318
318
  export declare function isModEventEmail(v: unknown): v is ModEventEmail;
319
319
  export declare function validateModEventEmail(v: unknown): ValidationResult;
320
+ export interface CommunicationTemplateView {
321
+ id: string;
322
+ name: string;
323
+ subject?: string;
324
+ contentMarkdown: string;
325
+ disabled: boolean;
326
+ lastUpdatedBy: string;
327
+ createdAt: string;
328
+ updatedAt: string;
329
+ [k: string]: unknown;
330
+ }
331
+ export declare function isCommunicationTemplateView(v: unknown): v is CommunicationTemplateView;
332
+ export declare function validateCommunicationTemplateView(v: unknown): ValidationResult;
@@ -0,0 +1,25 @@
1
+ import express from 'express';
2
+ import { HandlerAuth } from '@atproto/xrpc-server';
3
+ export interface QueryParams {
4
+ }
5
+ export interface InputSchema {
6
+ id: string;
7
+ [k: string]: unknown;
8
+ }
9
+ export interface HandlerInput {
10
+ encoding: 'application/json';
11
+ body: InputSchema;
12
+ }
13
+ export interface HandlerError {
14
+ status: number;
15
+ message?: string;
16
+ }
17
+ export type HandlerOutput = HandlerError | void;
18
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
19
+ auth: HA;
20
+ params: QueryParams;
21
+ input: HandlerInput;
22
+ req: express.Request;
23
+ res: express.Response;
24
+ };
25
+ export type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -1,12 +1,11 @@
1
1
  import express from 'express';
2
2
  import { HandlerAuth } from '@atproto/xrpc-server';
3
- import * as AppBskyModerationDefs from './defs';
3
+ import * as ComAtprotoAdminDefs from './defs';
4
4
  export interface QueryParams {
5
- dids: string[];
6
5
  }
7
6
  export type InputSchema = undefined;
8
7
  export interface OutputSchema {
9
- views: AppBskyModerationDefs.ModServiceView[];
8
+ communicationTemplates: ComAtprotoAdminDefs.CommunicationTemplateView[];
10
9
  [k: string]: unknown;
11
10
  }
12
11
  export type HandlerInput = undefined;
@@ -1,12 +1,22 @@
1
1
  import express from 'express';
2
2
  import { HandlerAuth } from '@atproto/xrpc-server';
3
- import * as AppBskyModerationDefs from './defs';
3
+ import * as ComAtprotoAdminDefs from './defs';
4
4
  export interface QueryParams {
5
- did: string;
6
5
  }
7
- export type InputSchema = undefined;
8
- export type OutputSchema = AppBskyModerationDefs.ModServiceViewDetailed;
9
- export type HandlerInput = undefined;
6
+ export interface InputSchema {
7
+ id: string;
8
+ name?: string;
9
+ contentMarkdown?: string;
10
+ subject?: string;
11
+ updatedBy?: string;
12
+ disabled?: boolean;
13
+ [k: string]: unknown;
14
+ }
15
+ export type OutputSchema = ComAtprotoAdminDefs.CommunicationTemplateView;
16
+ export interface HandlerInput {
17
+ encoding: 'application/json';
18
+ body: InputSchema;
19
+ }
10
20
  export interface HandlerSuccess {
11
21
  encoding: 'application/json';
12
22
  body: OutputSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/ozone",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "license": "MIT",
5
5
  "description": "Backend service for moderating the Bluesky network.",
6
6
  "keywords": [
@@ -30,13 +30,13 @@
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.2",
33
34
  "@atproto/common": "^0.3.3",
35
+ "@atproto/crypto": "^0.3.0",
34
36
  "@atproto/syntax": "^0.1.5",
35
37
  "@atproto/identity": "^0.3.2",
36
38
  "@atproto/lexicon": "^0.3.1",
37
- "@atproto/xrpc-server": "^0.4.2",
38
- "@atproto/crypto": "^0.3.0",
39
- "@atproto/api": "^0.9.0"
39
+ "@atproto/xrpc-server": "^0.4.2"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@did-plc/server": "^0.0.1",
@@ -46,11 +46,11 @@
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.2",
50
+ "@atproto/dev-env": "^0.2.25",
49
51
  "@atproto/lex-cli": "^0.3.0",
50
- "@atproto/api": "^0.9.0",
51
- "@atproto/xrpc": "^0.4.1",
52
- "@atproto/dev-env": "^0.2.23",
53
- "@atproto/pds": "^0.3.11"
52
+ "@atproto/pds": "^0.3.13",
53
+ "@atproto/xrpc": "^0.4.1"
54
54
  },
55
55
  "scripts": {
56
56
  "codegen": "lex gen-server ./src/lexicon ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
@@ -0,0 +1,37 @@
1
+ import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
2
+ import { Server } from '../../lexicon'
3
+ import AppContext from '../../context'
4
+
5
+ export default function (server: Server, ctx: AppContext) {
6
+ server.com.atproto.admin.createCommunicationTemplate({
7
+ auth: ctx.roleVerifier,
8
+ handler: async ({ input, auth }) => {
9
+ const access = auth.credentials
10
+ const db = ctx.db
11
+ const { createdBy, ...template } = input.body
12
+
13
+ if (!access.admin) {
14
+ throw new AuthRequiredError(
15
+ 'Must be an admin to create a communication template',
16
+ )
17
+ }
18
+
19
+ // Once auth starts providing us with the caller's DID, we can get rid of this check
20
+ if (!createdBy) {
21
+ throw new InvalidRequestError('createdBy field is required')
22
+ }
23
+
24
+ const communicationTemplate = ctx.communicationTemplateService(db)
25
+ const newTemplate = await communicationTemplate.create({
26
+ ...template,
27
+ disabled: false,
28
+ lastUpdatedBy: createdBy,
29
+ })
30
+
31
+ return {
32
+ encoding: 'application/json',
33
+ body: communicationTemplate.view(newTemplate),
34
+ }
35
+ },
36
+ })
37
+ }
@@ -0,0 +1,23 @@
1
+ import { AuthRequiredError } from '@atproto/xrpc-server'
2
+ import { Server } from '../../lexicon'
3
+ import AppContext from '../../context'
4
+
5
+ export default function (server: Server, ctx: AppContext) {
6
+ server.com.atproto.admin.deleteCommunicationTemplate({
7
+ auth: ctx.roleVerifier,
8
+ handler: async ({ input, auth }) => {
9
+ const access = auth.credentials
10
+ const db = ctx.db
11
+ const { id } = input.body
12
+
13
+ if (!access.admin) {
14
+ throw new AuthRequiredError(
15
+ 'Must be an admin to delete a communication template',
16
+ )
17
+ }
18
+
19
+ const communicationTemplate = ctx.communicationTemplateService(db)
20
+ await communicationTemplate.delete(Number(id))
21
+ },
22
+ })
23
+ }
@@ -0,0 +1,31 @@
1
+ import { AuthRequiredError } from '@atproto/xrpc-server'
2
+ import { Server } from '../../lexicon'
3
+ import AppContext from '../../context'
4
+
5
+ export default function (server: Server, ctx: AppContext) {
6
+ server.com.atproto.admin.listCommunicationTemplates({
7
+ auth: ctx.roleVerifier,
8
+ handler: async ({ auth }) => {
9
+ const access = auth.credentials
10
+ const db = ctx.db
11
+
12
+ if (!access.moderator) {
13
+ throw new AuthRequiredError(
14
+ 'Must be a full moderator to view list of communication template',
15
+ )
16
+ }
17
+
18
+ const communicationTemplate = ctx.communicationTemplateService(db)
19
+ const list = await communicationTemplate.list()
20
+
21
+ return {
22
+ encoding: 'application/json',
23
+ body: {
24
+ communicationTemplates: list.map((item) =>
25
+ communicationTemplate.view(item),
26
+ ),
27
+ },
28
+ }
29
+ },
30
+ })
31
+ }
@@ -0,0 +1,40 @@
1
+ import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
2
+ import { Server } from '../../lexicon'
3
+ import AppContext from '../../context'
4
+
5
+ export default function (server: Server, ctx: AppContext) {
6
+ server.com.atproto.admin.updateCommunicationTemplate({
7
+ auth: ctx.roleVerifier,
8
+ handler: async ({ input, auth }) => {
9
+ const access = auth.credentials
10
+ const db = ctx.db
11
+ const { id, updatedBy, ...template } = input.body
12
+
13
+ if (!access.admin) {
14
+ throw new AuthRequiredError(
15
+ 'Must be an admin to update a communication template',
16
+ )
17
+ }
18
+
19
+ // Once auth starts providing us with the caller's DID, we can get rid of this check
20
+ if (!updatedBy) {
21
+ throw new InvalidRequestError('updatedBy field is required')
22
+ }
23
+
24
+ if (!Object.keys(template).length) {
25
+ throw new InvalidRequestError('Missing update data in request body')
26
+ }
27
+
28
+ const communicationTemplate = ctx.communicationTemplateService(db)
29
+ const updatedTemplate = await communicationTemplate.update(Number(id), {
30
+ ...template,
31
+ lastUpdatedBy: updatedBy,
32
+ })
33
+
34
+ return {
35
+ encoding: 'application/json',
36
+ body: communicationTemplate.view(updatedTemplate),
37
+ }
38
+ },
39
+ })
40
+ }
package/src/api/index.ts CHANGED
@@ -9,6 +9,10 @@ import queryModerationStatuses from './admin/queryModerationStatuses'
9
9
  import queryModerationEvents from './admin/queryModerationEvents'
10
10
  import getModerationEvent from './admin/getModerationEvent'
11
11
  import fetchLabels from './temp/fetchLabels'
12
+ import createCommunicationTemplate from './admin/createCommunicationTemplate'
13
+ import updateCommunicationTemplate from './admin/updateCommunicationTemplate'
14
+ import deleteCommunicationTemplate from './admin/deleteCommunicationTemplate'
15
+ import listCommunicationTemplates from './admin/listCommunicationTemplates'
12
16
 
13
17
  export * as health from './health'
14
18
 
@@ -24,5 +28,9 @@ export default function (server: Server, ctx: AppContext) {
24
28
  queryModerationEvents(server, ctx)
25
29
  queryModerationStatuses(server, ctx)
26
30
  fetchLabels(server, ctx)
31
+ listCommunicationTemplates(server, ctx)
32
+ createCommunicationTemplate(server, ctx)
33
+ updateCommunicationTemplate(server, ctx)
34
+ deleteCommunicationTemplate(server, ctx)
27
35
  return server
28
36
  }