@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.
- package/CHANGELOG.md +14 -0
- package/dist/api/admin/listCommunicationTemplates.d.ts +3 -0
- package/dist/api/admin/updateCommunicationTemplate.d.ts +3 -0
- package/dist/communication-service/template.d.ts +18 -0
- package/dist/context.d.ts +3 -0
- package/dist/db/index.js +18 -1
- package/dist/db/index.js.map +3 -3
- package/dist/db/migrations/20240116T085607200Z-communication-template.d.ts +3 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/db/schema/communication_template.d.ts +15 -0
- package/dist/db/schema/index.d.ts +2 -1
- package/dist/index.js +861 -240
- package/dist/index.js.map +3 -3
- package/dist/lexicon/index.d.ts +8 -0
- package/dist/lexicon/lexicons.d.ts +182 -0
- package/dist/lexicon/types/{app/bsky/unspecced/getPopular.d.ts → com/atproto/admin/createCommunicationTemplate.d.ts} +11 -9
- package/dist/lexicon/types/com/atproto/admin/defs.d.ts +13 -0
- package/dist/lexicon/types/com/atproto/admin/deleteCommunicationTemplate.d.ts +25 -0
- package/dist/lexicon/types/{app/bsky/moderation/getServices.d.ts → com/atproto/admin/listCommunicationTemplates.d.ts} +2 -3
- package/dist/lexicon/types/{app/bsky/moderation/getService.d.ts → com/atproto/admin/updateCommunicationTemplate.d.ts} +15 -5
- package/package.json +8 -8
- package/src/api/admin/createCommunicationTemplate.ts +37 -0
- package/src/api/admin/deleteCommunicationTemplate.ts +23 -0
- package/src/api/admin/listCommunicationTemplates.ts +31 -0
- package/src/api/admin/updateCommunicationTemplate.ts +40 -0
- package/src/api/index.ts +8 -0
- package/src/communication-service/template.ts +105 -0
- package/src/context.ts +12 -0
- package/src/db/migrations/20240116T085607200Z-communication-template.ts +23 -0
- package/src/db/migrations/index.ts +1 -0
- package/src/db/schema/communication_template.ts +18 -0
- package/src/db/schema/index.ts +3 -1
- package/src/lexicon/index.ts +48 -0
- package/src/lexicon/lexicons.ts +199 -0
- package/src/lexicon/types/com/atproto/admin/createCommunicationTemplate.ts +54 -0
- package/src/lexicon/types/com/atproto/admin/defs.ts +35 -0
- package/src/lexicon/types/com/atproto/admin/deleteCommunicationTemplate.ts +38 -0
- package/src/lexicon/types/com/atproto/admin/listCommunicationTemplates.ts +44 -0
- package/src/lexicon/types/com/atproto/admin/updateCommunicationTemplate.ts +57 -0
- package/tests/communication-templates.test.ts +131 -0
- package/dist/api/com/atproto/admin/emitModerationEvent.d.ts +0 -3
- package/dist/api/com/atproto/admin/getModerationEvent.d.ts +0 -3
- package/dist/api/com/atproto/admin/getRecord.d.ts +0 -3
- package/dist/api/com/atproto/admin/getRepo.d.ts +0 -3
- package/dist/api/com/atproto/admin/queryModerationEvents.d.ts +0 -3
- package/dist/api/com/atproto/admin/queryModerationStatuses.d.ts +0 -3
- package/dist/api/com/atproto/admin/searchRepos.d.ts +0 -3
- package/dist/api/com/atproto/admin/util.d.ts +0 -5
- package/dist/api/com/atproto/moderation/createReport.d.ts +0 -3
- package/dist/api/com/atproto/moderation/util.d.ts +0 -4
- package/dist/api/com/atproto/temp/fetchLabels.d.ts +0 -3
- package/dist/api/util.d.ts +0 -2
- package/dist/auth-verifier.d.ts +0 -47
- package/dist/config.d.ts +0 -42
- package/dist/daemon/config.d.ts +0 -23
- package/dist/lexicon/types/app/bsky/moderation/defs.d.ts +0 -49
- package/dist/lexicon/types/app/bsky/moderation/service.d.ts +0 -17
- package/dist/sequencer/index.d.ts +0 -2
- package/dist/sequencer/outbox.d.ts +0 -16
- package/dist/sequencer/sequencer.d.ts +0 -35
- package/dist/services/index.d.ts +0 -7
- package/dist/services/moderation/index.d.ts +0 -144
- package/dist/services/moderation/status.d.ts +0 -12
- package/dist/services/moderation/subject.d.ts +0 -60
- package/dist/services/moderation/types.d.ts +0 -19
- package/dist/services/moderation/views.d.ts +0 -42
- package/dist/services/types.d.ts +0 -2
- package/dist/util/date.d.ts +0 -1
- package/dist/util/debug.d.ts +0 -1
- package/dist/util/retry.d.ts +0 -3
- package/test.log +0 -0
- /package/dist/api/{label/queryLabels.d.ts → admin/createCommunicationTemplate.d.ts} +0 -0
- /package/dist/api/{label/subscribeLabels.d.ts → admin/deleteCommunicationTemplate.d.ts} +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import Database from '../db'
|
|
2
|
+
import { Selectable } from 'kysely'
|
|
3
|
+
import { CommunicationTemplate } from '../db/schema/communication_template'
|
|
4
|
+
import { CommunicationTemplateView } from '../lexicon/types/com/atproto/admin/defs'
|
|
5
|
+
|
|
6
|
+
export type CommunicationTemplateServiceCreator = (
|
|
7
|
+
db: Database,
|
|
8
|
+
) => CommunicationTemplateService
|
|
9
|
+
|
|
10
|
+
export class CommunicationTemplateService {
|
|
11
|
+
constructor(public db: Database) {}
|
|
12
|
+
|
|
13
|
+
static creator() {
|
|
14
|
+
return (db: Database) => new CommunicationTemplateService(db)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async list(): Promise<Selectable<CommunicationTemplate>[]> {
|
|
18
|
+
const list = await this.db.db
|
|
19
|
+
.selectFrom('communication_template')
|
|
20
|
+
.selectAll()
|
|
21
|
+
.execute()
|
|
22
|
+
|
|
23
|
+
return list
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async create({
|
|
27
|
+
name,
|
|
28
|
+
contentMarkdown,
|
|
29
|
+
subject,
|
|
30
|
+
disabled,
|
|
31
|
+
updatedAt,
|
|
32
|
+
createdAt,
|
|
33
|
+
lastUpdatedBy,
|
|
34
|
+
}: Omit<
|
|
35
|
+
Selectable<CommunicationTemplate>,
|
|
36
|
+
'id' | 'createdAt' | 'updatedAt'
|
|
37
|
+
> & {
|
|
38
|
+
createdAt?: Date
|
|
39
|
+
updatedAt?: Date
|
|
40
|
+
}): Promise<Selectable<CommunicationTemplate>> {
|
|
41
|
+
const newTemplate = await this.db.db
|
|
42
|
+
.insertInto('communication_template')
|
|
43
|
+
.values({
|
|
44
|
+
name,
|
|
45
|
+
contentMarkdown,
|
|
46
|
+
subject,
|
|
47
|
+
disabled,
|
|
48
|
+
lastUpdatedBy,
|
|
49
|
+
updatedAt: updatedAt || new Date(),
|
|
50
|
+
createdAt: createdAt || new Date(),
|
|
51
|
+
})
|
|
52
|
+
.returningAll()
|
|
53
|
+
.executeTakeFirstOrThrow()
|
|
54
|
+
|
|
55
|
+
return newTemplate
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async update(
|
|
59
|
+
id: number,
|
|
60
|
+
{
|
|
61
|
+
name,
|
|
62
|
+
contentMarkdown,
|
|
63
|
+
subject,
|
|
64
|
+
disabled,
|
|
65
|
+
updatedAt,
|
|
66
|
+
lastUpdatedBy,
|
|
67
|
+
}: Partial<Omit<Selectable<CommunicationTemplate>, 'id' | 'createdAt'>>,
|
|
68
|
+
): Promise<Selectable<CommunicationTemplate>> {
|
|
69
|
+
const updatedTemplate = await this.db.db
|
|
70
|
+
.updateTable('communication_template')
|
|
71
|
+
.where('id', '=', id)
|
|
72
|
+
.set({
|
|
73
|
+
name,
|
|
74
|
+
contentMarkdown,
|
|
75
|
+
subject,
|
|
76
|
+
disabled,
|
|
77
|
+
lastUpdatedBy,
|
|
78
|
+
updatedAt: updatedAt || new Date(),
|
|
79
|
+
})
|
|
80
|
+
.returningAll()
|
|
81
|
+
.executeTakeFirstOrThrow()
|
|
82
|
+
|
|
83
|
+
return updatedTemplate
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async delete(id: number): Promise<void> {
|
|
87
|
+
await this.db.db
|
|
88
|
+
.deleteFrom('communication_template')
|
|
89
|
+
.where('id', '=', id)
|
|
90
|
+
.execute()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
view(template: Selectable<CommunicationTemplate>): CommunicationTemplateView {
|
|
94
|
+
return {
|
|
95
|
+
id: `${template.id}`,
|
|
96
|
+
name: template.name,
|
|
97
|
+
contentMarkdown: template.contentMarkdown,
|
|
98
|
+
disabled: template.disabled,
|
|
99
|
+
subject: template.subject || undefined,
|
|
100
|
+
createdAt: template.createdAt.toISOString(),
|
|
101
|
+
updatedAt: template.updatedAt.toISOString(),
|
|
102
|
+
lastUpdatedBy: template.lastUpdatedBy,
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
package/src/context.ts
CHANGED
|
@@ -10,11 +10,16 @@ import * as auth from './auth'
|
|
|
10
10
|
import { BackgroundQueue } from './background'
|
|
11
11
|
import assert from 'assert'
|
|
12
12
|
import { EventPusher } from './daemon'
|
|
13
|
+
import {
|
|
14
|
+
CommunicationTemplateService,
|
|
15
|
+
CommunicationTemplateServiceCreator,
|
|
16
|
+
} from './communication-service/template'
|
|
13
17
|
|
|
14
18
|
export type AppContextOptions = {
|
|
15
19
|
db: Database
|
|
16
20
|
cfg: OzoneConfig
|
|
17
21
|
modService: ModerationServiceCreator
|
|
22
|
+
communicationTemplateService: CommunicationTemplateServiceCreator
|
|
18
23
|
appviewAgent: AtpAgent
|
|
19
24
|
pdsAgent: AtpAgent | undefined
|
|
20
25
|
signingKey: Keypair
|
|
@@ -62,6 +67,8 @@ export class AppContext {
|
|
|
62
67
|
appviewAuth,
|
|
63
68
|
)
|
|
64
69
|
|
|
70
|
+
const communicationTemplateService = CommunicationTemplateService.creator()
|
|
71
|
+
|
|
65
72
|
const idResolver = new IdResolver({
|
|
66
73
|
plcUrl: cfg.identity.plcUrl,
|
|
67
74
|
})
|
|
@@ -71,6 +78,7 @@ export class AppContext {
|
|
|
71
78
|
db,
|
|
72
79
|
cfg,
|
|
73
80
|
modService,
|
|
81
|
+
communicationTemplateService,
|
|
74
82
|
appviewAgent,
|
|
75
83
|
pdsAgent,
|
|
76
84
|
signingKey,
|
|
@@ -102,6 +110,10 @@ export class AppContext {
|
|
|
102
110
|
return this.opts.modService
|
|
103
111
|
}
|
|
104
112
|
|
|
113
|
+
get communicationTemplateService(): CommunicationTemplateServiceCreator {
|
|
114
|
+
return this.opts.communicationTemplateService
|
|
115
|
+
}
|
|
116
|
+
|
|
105
117
|
get appviewAgent(): AtpAgent {
|
|
106
118
|
return this.opts.appviewAgent
|
|
107
119
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Kysely } from 'kysely'
|
|
2
|
+
|
|
3
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
4
|
+
await db.schema
|
|
5
|
+
.createTable('communication_template')
|
|
6
|
+
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
7
|
+
.addColumn('name', 'varchar', (col) => col.notNull())
|
|
8
|
+
.addColumn('contentMarkdown', 'varchar', (col) => col.notNull())
|
|
9
|
+
.addColumn('subject', 'varchar')
|
|
10
|
+
.addColumn('disabled', 'boolean', (col) => col.defaultTo(false).notNull())
|
|
11
|
+
.addColumn('createdAt', 'timestamptz')
|
|
12
|
+
.addColumn('updatedAt', 'timestamptz')
|
|
13
|
+
.addColumn('lastUpdatedBy', 'varchar', (col) => col.notNull())
|
|
14
|
+
.addUniqueConstraint('communication_template_unique_name', [
|
|
15
|
+
'name',
|
|
16
|
+
'disabled',
|
|
17
|
+
])
|
|
18
|
+
.execute()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
22
|
+
await db.schema.dropTable('communication_template')
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Generated, GeneratedAlways } from 'kysely'
|
|
2
|
+
|
|
3
|
+
export const communicationTemplateTableName = 'communication_template'
|
|
4
|
+
|
|
5
|
+
export interface CommunicationTemplate {
|
|
6
|
+
id: GeneratedAlways<number>
|
|
7
|
+
name: string
|
|
8
|
+
contentMarkdown: string
|
|
9
|
+
subject: string | null
|
|
10
|
+
disabled: Generated<boolean>
|
|
11
|
+
createdAt: Date
|
|
12
|
+
updatedAt: Date
|
|
13
|
+
lastUpdatedBy: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type PartialDB = {
|
|
17
|
+
[communicationTemplateTableName]: CommunicationTemplate
|
|
18
|
+
}
|
package/src/db/schema/index.ts
CHANGED
|
@@ -5,13 +5,15 @@ import * as repoPushEvent from './repo_push_event'
|
|
|
5
5
|
import * as recordPushEvent from './record_push_event'
|
|
6
6
|
import * as blobPushEvent from './blob_push_event'
|
|
7
7
|
import * as label from './label'
|
|
8
|
+
import * as communicationTemplate from './communication_template'
|
|
8
9
|
|
|
9
10
|
export type DatabaseSchemaType = modEvent.PartialDB &
|
|
10
11
|
modSubjectStatus.PartialDB &
|
|
11
12
|
label.PartialDB &
|
|
12
13
|
repoPushEvent.PartialDB &
|
|
13
14
|
recordPushEvent.PartialDB &
|
|
14
|
-
blobPushEvent.PartialDB
|
|
15
|
+
blobPushEvent.PartialDB &
|
|
16
|
+
communicationTemplate.PartialDB
|
|
15
17
|
|
|
16
18
|
export type DatabaseSchema = Kysely<DatabaseSchemaType>
|
|
17
19
|
|
package/src/lexicon/index.ts
CHANGED
|
@@ -9,7 +9,9 @@ import {
|
|
|
9
9
|
StreamAuthVerifier,
|
|
10
10
|
} from '@atproto/xrpc-server'
|
|
11
11
|
import { schemas } from './lexicons'
|
|
12
|
+
import * as ComAtprotoAdminCreateCommunicationTemplate from './types/com/atproto/admin/createCommunicationTemplate'
|
|
12
13
|
import * as ComAtprotoAdminDeleteAccount from './types/com/atproto/admin/deleteAccount'
|
|
14
|
+
import * as ComAtprotoAdminDeleteCommunicationTemplate from './types/com/atproto/admin/deleteCommunicationTemplate'
|
|
13
15
|
import * as ComAtprotoAdminDisableAccountInvites from './types/com/atproto/admin/disableAccountInvites'
|
|
14
16
|
import * as ComAtprotoAdminDisableInviteCodes from './types/com/atproto/admin/disableInviteCodes'
|
|
15
17
|
import * as ComAtprotoAdminEmitModerationEvent from './types/com/atproto/admin/emitModerationEvent'
|
|
@@ -21,12 +23,14 @@ import * as ComAtprotoAdminGetModerationEvent from './types/com/atproto/admin/ge
|
|
|
21
23
|
import * as ComAtprotoAdminGetRecord from './types/com/atproto/admin/getRecord'
|
|
22
24
|
import * as ComAtprotoAdminGetRepo from './types/com/atproto/admin/getRepo'
|
|
23
25
|
import * as ComAtprotoAdminGetSubjectStatus from './types/com/atproto/admin/getSubjectStatus'
|
|
26
|
+
import * as ComAtprotoAdminListCommunicationTemplates from './types/com/atproto/admin/listCommunicationTemplates'
|
|
24
27
|
import * as ComAtprotoAdminQueryModerationEvents from './types/com/atproto/admin/queryModerationEvents'
|
|
25
28
|
import * as ComAtprotoAdminQueryModerationStatuses from './types/com/atproto/admin/queryModerationStatuses'
|
|
26
29
|
import * as ComAtprotoAdminSearchRepos from './types/com/atproto/admin/searchRepos'
|
|
27
30
|
import * as ComAtprotoAdminSendEmail from './types/com/atproto/admin/sendEmail'
|
|
28
31
|
import * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/updateAccountEmail'
|
|
29
32
|
import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle'
|
|
33
|
+
import * as ComAtprotoAdminUpdateCommunicationTemplate from './types/com/atproto/admin/updateCommunicationTemplate'
|
|
30
34
|
import * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus'
|
|
31
35
|
import * as ComAtprotoIdentityResolveHandle from './types/com/atproto/identity/resolveHandle'
|
|
32
36
|
import * as ComAtprotoIdentityUpdateHandle from './types/com/atproto/identity/updateHandle'
|
|
@@ -200,6 +204,17 @@ export class ComAtprotoAdminNS {
|
|
|
200
204
|
this._server = server
|
|
201
205
|
}
|
|
202
206
|
|
|
207
|
+
createCommunicationTemplate<AV extends AuthVerifier>(
|
|
208
|
+
cfg: ConfigOf<
|
|
209
|
+
AV,
|
|
210
|
+
ComAtprotoAdminCreateCommunicationTemplate.Handler<ExtractAuth<AV>>,
|
|
211
|
+
ComAtprotoAdminCreateCommunicationTemplate.HandlerReqCtx<ExtractAuth<AV>>
|
|
212
|
+
>,
|
|
213
|
+
) {
|
|
214
|
+
const nsid = 'com.atproto.admin.createCommunicationTemplate' // @ts-ignore
|
|
215
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
216
|
+
}
|
|
217
|
+
|
|
203
218
|
deleteAccount<AV extends AuthVerifier>(
|
|
204
219
|
cfg: ConfigOf<
|
|
205
220
|
AV,
|
|
@@ -211,6 +226,17 @@ export class ComAtprotoAdminNS {
|
|
|
211
226
|
return this._server.xrpc.method(nsid, cfg)
|
|
212
227
|
}
|
|
213
228
|
|
|
229
|
+
deleteCommunicationTemplate<AV extends AuthVerifier>(
|
|
230
|
+
cfg: ConfigOf<
|
|
231
|
+
AV,
|
|
232
|
+
ComAtprotoAdminDeleteCommunicationTemplate.Handler<ExtractAuth<AV>>,
|
|
233
|
+
ComAtprotoAdminDeleteCommunicationTemplate.HandlerReqCtx<ExtractAuth<AV>>
|
|
234
|
+
>,
|
|
235
|
+
) {
|
|
236
|
+
const nsid = 'com.atproto.admin.deleteCommunicationTemplate' // @ts-ignore
|
|
237
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
238
|
+
}
|
|
239
|
+
|
|
214
240
|
disableAccountInvites<AV extends AuthVerifier>(
|
|
215
241
|
cfg: ConfigOf<
|
|
216
242
|
AV,
|
|
@@ -332,6 +358,17 @@ export class ComAtprotoAdminNS {
|
|
|
332
358
|
return this._server.xrpc.method(nsid, cfg)
|
|
333
359
|
}
|
|
334
360
|
|
|
361
|
+
listCommunicationTemplates<AV extends AuthVerifier>(
|
|
362
|
+
cfg: ConfigOf<
|
|
363
|
+
AV,
|
|
364
|
+
ComAtprotoAdminListCommunicationTemplates.Handler<ExtractAuth<AV>>,
|
|
365
|
+
ComAtprotoAdminListCommunicationTemplates.HandlerReqCtx<ExtractAuth<AV>>
|
|
366
|
+
>,
|
|
367
|
+
) {
|
|
368
|
+
const nsid = 'com.atproto.admin.listCommunicationTemplates' // @ts-ignore
|
|
369
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
370
|
+
}
|
|
371
|
+
|
|
335
372
|
queryModerationEvents<AV extends AuthVerifier>(
|
|
336
373
|
cfg: ConfigOf<
|
|
337
374
|
AV,
|
|
@@ -398,6 +435,17 @@ export class ComAtprotoAdminNS {
|
|
|
398
435
|
return this._server.xrpc.method(nsid, cfg)
|
|
399
436
|
}
|
|
400
437
|
|
|
438
|
+
updateCommunicationTemplate<AV extends AuthVerifier>(
|
|
439
|
+
cfg: ConfigOf<
|
|
440
|
+
AV,
|
|
441
|
+
ComAtprotoAdminUpdateCommunicationTemplate.Handler<ExtractAuth<AV>>,
|
|
442
|
+
ComAtprotoAdminUpdateCommunicationTemplate.HandlerReqCtx<ExtractAuth<AV>>
|
|
443
|
+
>,
|
|
444
|
+
) {
|
|
445
|
+
const nsid = 'com.atproto.admin.updateCommunicationTemplate' // @ts-ignore
|
|
446
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
447
|
+
}
|
|
448
|
+
|
|
401
449
|
updateSubjectStatus<AV extends AuthVerifier>(
|
|
402
450
|
cfg: ConfigOf<
|
|
403
451
|
AV,
|
package/src/lexicon/lexicons.ts
CHANGED
|
@@ -4,6 +4,51 @@
|
|
|
4
4
|
import { LexiconDoc, Lexicons } from '@atproto/lexicon'
|
|
5
5
|
|
|
6
6
|
export const schemaDict = {
|
|
7
|
+
ComAtprotoAdminCreateCommunicationTemplate: {
|
|
8
|
+
lexicon: 1,
|
|
9
|
+
id: 'com.atproto.admin.createCommunicationTemplate',
|
|
10
|
+
defs: {
|
|
11
|
+
main: {
|
|
12
|
+
type: 'procedure',
|
|
13
|
+
description:
|
|
14
|
+
'Administrative action to create a new, re-usable communication (email for now) template.',
|
|
15
|
+
input: {
|
|
16
|
+
encoding: 'application/json',
|
|
17
|
+
schema: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
required: ['subject', 'contentMarkdown', 'name'],
|
|
20
|
+
properties: {
|
|
21
|
+
name: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
description: 'Name of the template.',
|
|
24
|
+
},
|
|
25
|
+
contentMarkdown: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description:
|
|
28
|
+
'Content of the template, markdown supported, can contain variable placeholders.',
|
|
29
|
+
},
|
|
30
|
+
subject: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'Subject of the message, used in emails.',
|
|
33
|
+
},
|
|
34
|
+
createdBy: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
format: 'did',
|
|
37
|
+
description: 'DID of the user who is creating the template.',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
output: {
|
|
43
|
+
encoding: 'application/json',
|
|
44
|
+
schema: {
|
|
45
|
+
type: 'ref',
|
|
46
|
+
ref: 'lex:com.atproto.admin.defs#communicationTemplateView',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
7
52
|
ComAtprotoAdminDefs: {
|
|
8
53
|
lexicon: 1,
|
|
9
54
|
id: 'com.atproto.admin.defs',
|
|
@@ -850,6 +895,52 @@ export const schemaDict = {
|
|
|
850
895
|
},
|
|
851
896
|
},
|
|
852
897
|
},
|
|
898
|
+
communicationTemplateView: {
|
|
899
|
+
type: 'object',
|
|
900
|
+
required: [
|
|
901
|
+
'id',
|
|
902
|
+
'name',
|
|
903
|
+
'contentMarkdown',
|
|
904
|
+
'disabled',
|
|
905
|
+
'lastUpdatedBy',
|
|
906
|
+
'createdAt',
|
|
907
|
+
'updatedAt',
|
|
908
|
+
],
|
|
909
|
+
properties: {
|
|
910
|
+
id: {
|
|
911
|
+
type: 'string',
|
|
912
|
+
},
|
|
913
|
+
name: {
|
|
914
|
+
type: 'string',
|
|
915
|
+
description: 'Name of the template.',
|
|
916
|
+
},
|
|
917
|
+
subject: {
|
|
918
|
+
type: 'string',
|
|
919
|
+
description:
|
|
920
|
+
'Content of the template, can contain markdown and variable placeholders.',
|
|
921
|
+
},
|
|
922
|
+
contentMarkdown: {
|
|
923
|
+
type: 'string',
|
|
924
|
+
description: 'Subject of the message, used in emails.',
|
|
925
|
+
},
|
|
926
|
+
disabled: {
|
|
927
|
+
type: 'boolean',
|
|
928
|
+
},
|
|
929
|
+
lastUpdatedBy: {
|
|
930
|
+
type: 'string',
|
|
931
|
+
format: 'did',
|
|
932
|
+
description: 'DID of the user who last updated the template.',
|
|
933
|
+
},
|
|
934
|
+
createdAt: {
|
|
935
|
+
type: 'string',
|
|
936
|
+
format: 'datetime',
|
|
937
|
+
},
|
|
938
|
+
updatedAt: {
|
|
939
|
+
type: 'string',
|
|
940
|
+
format: 'datetime',
|
|
941
|
+
},
|
|
942
|
+
},
|
|
943
|
+
},
|
|
853
944
|
},
|
|
854
945
|
},
|
|
855
946
|
ComAtprotoAdminDeleteAccount: {
|
|
@@ -875,6 +966,28 @@ export const schemaDict = {
|
|
|
875
966
|
},
|
|
876
967
|
},
|
|
877
968
|
},
|
|
969
|
+
ComAtprotoAdminDeleteCommunicationTemplate: {
|
|
970
|
+
lexicon: 1,
|
|
971
|
+
id: 'com.atproto.admin.deleteCommunicationTemplate',
|
|
972
|
+
defs: {
|
|
973
|
+
main: {
|
|
974
|
+
type: 'procedure',
|
|
975
|
+
description: 'Delete a communication template.',
|
|
976
|
+
input: {
|
|
977
|
+
encoding: 'application/json',
|
|
978
|
+
schema: {
|
|
979
|
+
type: 'object',
|
|
980
|
+
required: ['id'],
|
|
981
|
+
properties: {
|
|
982
|
+
id: {
|
|
983
|
+
type: 'string',
|
|
984
|
+
},
|
|
985
|
+
},
|
|
986
|
+
},
|
|
987
|
+
},
|
|
988
|
+
},
|
|
989
|
+
},
|
|
990
|
+
},
|
|
878
991
|
ComAtprotoAdminDisableAccountInvites: {
|
|
879
992
|
lexicon: 1,
|
|
880
993
|
id: 'com.atproto.admin.disableAccountInvites',
|
|
@@ -1282,6 +1395,32 @@ export const schemaDict = {
|
|
|
1282
1395
|
},
|
|
1283
1396
|
},
|
|
1284
1397
|
},
|
|
1398
|
+
ComAtprotoAdminListCommunicationTemplates: {
|
|
1399
|
+
lexicon: 1,
|
|
1400
|
+
id: 'com.atproto.admin.listCommunicationTemplates',
|
|
1401
|
+
defs: {
|
|
1402
|
+
main: {
|
|
1403
|
+
type: 'query',
|
|
1404
|
+
description: 'Get list of all communication templates.',
|
|
1405
|
+
output: {
|
|
1406
|
+
encoding: 'application/json',
|
|
1407
|
+
schema: {
|
|
1408
|
+
type: 'object',
|
|
1409
|
+
required: ['communicationTemplates'],
|
|
1410
|
+
properties: {
|
|
1411
|
+
communicationTemplates: {
|
|
1412
|
+
type: 'array',
|
|
1413
|
+
items: {
|
|
1414
|
+
type: 'ref',
|
|
1415
|
+
ref: 'lex:com.atproto.admin.defs#communicationTemplateView',
|
|
1416
|
+
},
|
|
1417
|
+
},
|
|
1418
|
+
},
|
|
1419
|
+
},
|
|
1420
|
+
},
|
|
1421
|
+
},
|
|
1422
|
+
},
|
|
1423
|
+
},
|
|
1285
1424
|
ComAtprotoAdminQueryModerationEvents: {
|
|
1286
1425
|
lexicon: 1,
|
|
1287
1426
|
id: 'com.atproto.admin.queryModerationEvents',
|
|
@@ -1619,6 +1758,58 @@ export const schemaDict = {
|
|
|
1619
1758
|
},
|
|
1620
1759
|
},
|
|
1621
1760
|
},
|
|
1761
|
+
ComAtprotoAdminUpdateCommunicationTemplate: {
|
|
1762
|
+
lexicon: 1,
|
|
1763
|
+
id: 'com.atproto.admin.updateCommunicationTemplate',
|
|
1764
|
+
defs: {
|
|
1765
|
+
main: {
|
|
1766
|
+
type: 'procedure',
|
|
1767
|
+
description:
|
|
1768
|
+
'Administrative action to update an existing communication template. Allows passing partial fields to patch specific fields only.',
|
|
1769
|
+
input: {
|
|
1770
|
+
encoding: 'application/json',
|
|
1771
|
+
schema: {
|
|
1772
|
+
type: 'object',
|
|
1773
|
+
required: ['id'],
|
|
1774
|
+
properties: {
|
|
1775
|
+
id: {
|
|
1776
|
+
type: 'string',
|
|
1777
|
+
description: 'ID of the template to be updated.',
|
|
1778
|
+
},
|
|
1779
|
+
name: {
|
|
1780
|
+
type: 'string',
|
|
1781
|
+
description: 'Name of the template.',
|
|
1782
|
+
},
|
|
1783
|
+
contentMarkdown: {
|
|
1784
|
+
type: 'string',
|
|
1785
|
+
description:
|
|
1786
|
+
'Content of the template, markdown supported, can contain variable placeholders.',
|
|
1787
|
+
},
|
|
1788
|
+
subject: {
|
|
1789
|
+
type: 'string',
|
|
1790
|
+
description: 'Subject of the message, used in emails.',
|
|
1791
|
+
},
|
|
1792
|
+
updatedBy: {
|
|
1793
|
+
type: 'string',
|
|
1794
|
+
format: 'did',
|
|
1795
|
+
description: 'DID of the user who is updating the template.',
|
|
1796
|
+
},
|
|
1797
|
+
disabled: {
|
|
1798
|
+
type: 'boolean',
|
|
1799
|
+
},
|
|
1800
|
+
},
|
|
1801
|
+
},
|
|
1802
|
+
},
|
|
1803
|
+
output: {
|
|
1804
|
+
encoding: 'application/json',
|
|
1805
|
+
schema: {
|
|
1806
|
+
type: 'ref',
|
|
1807
|
+
ref: 'lex:com.atproto.admin.defs#communicationTemplateView',
|
|
1808
|
+
},
|
|
1809
|
+
},
|
|
1810
|
+
},
|
|
1811
|
+
},
|
|
1812
|
+
},
|
|
1622
1813
|
ComAtprotoAdminUpdateSubjectStatus: {
|
|
1623
1814
|
lexicon: 1,
|
|
1624
1815
|
id: 'com.atproto.admin.updateSubjectStatus',
|
|
@@ -7896,8 +8087,12 @@ export const schemaDict = {
|
|
|
7896
8087
|
export const schemas: LexiconDoc[] = Object.values(schemaDict) as LexiconDoc[]
|
|
7897
8088
|
export const lexicons: Lexicons = new Lexicons(schemas)
|
|
7898
8089
|
export const ids = {
|
|
8090
|
+
ComAtprotoAdminCreateCommunicationTemplate:
|
|
8091
|
+
'com.atproto.admin.createCommunicationTemplate',
|
|
7899
8092
|
ComAtprotoAdminDefs: 'com.atproto.admin.defs',
|
|
7900
8093
|
ComAtprotoAdminDeleteAccount: 'com.atproto.admin.deleteAccount',
|
|
8094
|
+
ComAtprotoAdminDeleteCommunicationTemplate:
|
|
8095
|
+
'com.atproto.admin.deleteCommunicationTemplate',
|
|
7901
8096
|
ComAtprotoAdminDisableAccountInvites:
|
|
7902
8097
|
'com.atproto.admin.disableAccountInvites',
|
|
7903
8098
|
ComAtprotoAdminDisableInviteCodes: 'com.atproto.admin.disableInviteCodes',
|
|
@@ -7910,6 +8105,8 @@ export const ids = {
|
|
|
7910
8105
|
ComAtprotoAdminGetRecord: 'com.atproto.admin.getRecord',
|
|
7911
8106
|
ComAtprotoAdminGetRepo: 'com.atproto.admin.getRepo',
|
|
7912
8107
|
ComAtprotoAdminGetSubjectStatus: 'com.atproto.admin.getSubjectStatus',
|
|
8108
|
+
ComAtprotoAdminListCommunicationTemplates:
|
|
8109
|
+
'com.atproto.admin.listCommunicationTemplates',
|
|
7913
8110
|
ComAtprotoAdminQueryModerationEvents:
|
|
7914
8111
|
'com.atproto.admin.queryModerationEvents',
|
|
7915
8112
|
ComAtprotoAdminQueryModerationStatuses:
|
|
@@ -7918,6 +8115,8 @@ export const ids = {
|
|
|
7918
8115
|
ComAtprotoAdminSendEmail: 'com.atproto.admin.sendEmail',
|
|
7919
8116
|
ComAtprotoAdminUpdateAccountEmail: 'com.atproto.admin.updateAccountEmail',
|
|
7920
8117
|
ComAtprotoAdminUpdateAccountHandle: 'com.atproto.admin.updateAccountHandle',
|
|
8118
|
+
ComAtprotoAdminUpdateCommunicationTemplate:
|
|
8119
|
+
'com.atproto.admin.updateCommunicationTemplate',
|
|
7921
8120
|
ComAtprotoAdminUpdateSubjectStatus: 'com.atproto.admin.updateSubjectStatus',
|
|
7922
8121
|
ComAtprotoIdentityResolveHandle: 'com.atproto.identity.resolveHandle',
|
|
7923
8122
|
ComAtprotoIdentityUpdateHandle: 'com.atproto.identity.updateHandle',
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import express from 'express'
|
|
5
|
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { lexicons } from '../../../../lexicons'
|
|
7
|
+
import { isObj, hasProp } from '../../../../util'
|
|
8
|
+
import { CID } from 'multiformats/cid'
|
|
9
|
+
import { HandlerAuth } from '@atproto/xrpc-server'
|
|
10
|
+
import * as ComAtprotoAdminDefs from './defs'
|
|
11
|
+
|
|
12
|
+
export interface QueryParams {}
|
|
13
|
+
|
|
14
|
+
export interface InputSchema {
|
|
15
|
+
/** Name of the template. */
|
|
16
|
+
name: string
|
|
17
|
+
/** Content of the template, markdown supported, can contain variable placeholders. */
|
|
18
|
+
contentMarkdown: string
|
|
19
|
+
/** Subject of the message, used in emails. */
|
|
20
|
+
subject: string
|
|
21
|
+
/** DID of the user who is creating the template. */
|
|
22
|
+
createdBy?: string
|
|
23
|
+
[k: string]: unknown
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type OutputSchema = ComAtprotoAdminDefs.CommunicationTemplateView
|
|
27
|
+
|
|
28
|
+
export interface HandlerInput {
|
|
29
|
+
encoding: 'application/json'
|
|
30
|
+
body: InputSchema
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface HandlerSuccess {
|
|
34
|
+
encoding: 'application/json'
|
|
35
|
+
body: OutputSchema
|
|
36
|
+
headers?: { [key: string]: string }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface HandlerError {
|
|
40
|
+
status: number
|
|
41
|
+
message?: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type HandlerOutput = HandlerError | HandlerSuccess
|
|
45
|
+
export type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
|
46
|
+
auth: HA
|
|
47
|
+
params: QueryParams
|
|
48
|
+
input: HandlerInput
|
|
49
|
+
req: express.Request
|
|
50
|
+
res: express.Response
|
|
51
|
+
}
|
|
52
|
+
export type Handler<HA extends HandlerAuth = never> = (
|
|
53
|
+
ctx: HandlerReqCtx<HA>,
|
|
54
|
+
) => Promise<HandlerOutput> | HandlerOutput
|
|
@@ -717,3 +717,38 @@ export function isModEventEmail(v: unknown): v is ModEventEmail {
|
|
|
717
717
|
export function validateModEventEmail(v: unknown): ValidationResult {
|
|
718
718
|
return lexicons.validate('com.atproto.admin.defs#modEventEmail', v)
|
|
719
719
|
}
|
|
720
|
+
|
|
721
|
+
export interface CommunicationTemplateView {
|
|
722
|
+
id: string
|
|
723
|
+
/** Name of the template. */
|
|
724
|
+
name: string
|
|
725
|
+
/** Content of the template, can contain markdown and variable placeholders. */
|
|
726
|
+
subject?: string
|
|
727
|
+
/** Subject of the message, used in emails. */
|
|
728
|
+
contentMarkdown: string
|
|
729
|
+
disabled: boolean
|
|
730
|
+
/** DID of the user who last updated the template. */
|
|
731
|
+
lastUpdatedBy: string
|
|
732
|
+
createdAt: string
|
|
733
|
+
updatedAt: string
|
|
734
|
+
[k: string]: unknown
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
export function isCommunicationTemplateView(
|
|
738
|
+
v: unknown,
|
|
739
|
+
): v is CommunicationTemplateView {
|
|
740
|
+
return (
|
|
741
|
+
isObj(v) &&
|
|
742
|
+
hasProp(v, '$type') &&
|
|
743
|
+
v.$type === 'com.atproto.admin.defs#communicationTemplateView'
|
|
744
|
+
)
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
export function validateCommunicationTemplateView(
|
|
748
|
+
v: unknown,
|
|
749
|
+
): ValidationResult {
|
|
750
|
+
return lexicons.validate(
|
|
751
|
+
'com.atproto.admin.defs#communicationTemplateView',
|
|
752
|
+
v,
|
|
753
|
+
)
|
|
754
|
+
}
|