@atproto/ozone 0.0.16 → 0.0.17-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/moderation/util.d.ts +1 -1
- package/dist/auth-verifier.d.ts +7 -11
- package/dist/config/config.d.ts +1 -0
- package/dist/config/env.d.ts +1 -2
- package/dist/config/secrets.d.ts +0 -2
- package/dist/daemon/event-pusher.d.ts +2 -0
- package/dist/db/index.js.map +1 -1
- package/dist/db/schema/moderation_subject_status.d.ts +2 -2
- package/dist/index.js +821 -1055
- package/dist/index.js.map +3 -3
- package/dist/lexicon/index.d.ts +8 -0
- package/dist/lexicon/lexicons.d.ts +298 -0
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts +23 -1
- package/dist/lexicon/types/app/bsky/embed/record.d.ts +2 -1
- package/dist/lexicon/types/app/bsky/labeler/defs.d.ts +41 -0
- package/dist/lexicon/types/app/bsky/labeler/getServices.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/labeler/service.d.ts +14 -0
- package/dist/lexicon/types/com/atproto/admin/defs.d.ts +2 -1
- package/dist/lexicon/types/com/atproto/label/defs.d.ts +18 -0
- package/dist/mod-service/index.d.ts +2 -2
- package/package.json +5 -4
- package/src/api/admin/createCommunicationTemplate.ts +1 -1
- package/src/api/admin/deleteCommunicationTemplate.ts +1 -1
- package/src/api/admin/emitModerationEvent.ts +6 -2
- package/src/api/admin/getModerationEvent.ts +1 -1
- package/src/api/admin/getRecord.ts +1 -1
- package/src/api/admin/getRepo.ts +1 -1
- package/src/api/admin/listCommunicationTemplates.ts +1 -1
- package/src/api/admin/queryModerationEvents.ts +1 -1
- package/src/api/admin/queryModerationStatuses.ts +1 -1
- package/src/api/admin/searchRepos.ts +1 -1
- package/src/api/admin/updateCommunicationTemplate.ts +1 -1
- package/src/api/admin/util.ts +1 -1
- package/src/api/moderation/createReport.ts +1 -2
- package/src/api/proxied.ts +8 -8
- package/src/api/temp/fetchLabels.ts +1 -1
- package/src/auth-verifier.ts +19 -29
- package/src/config/config.ts +10 -7
- package/src/config/env.ts +2 -4
- package/src/config/secrets.ts +0 -6
- package/src/context.ts +1 -3
- package/src/daemon/context.ts +2 -2
- package/src/daemon/event-pusher.ts +9 -1
- package/src/db/schema/moderation_subject_status.ts +6 -1
- package/src/lexicon/index.ts +23 -0
- package/src/lexicon/lexicons.ts +327 -1
- package/src/lexicon/types/app/bsky/actor/defs.ts +57 -1
- package/src/lexicon/types/app/bsky/embed/record.ts +2 -0
- package/src/lexicon/types/app/bsky/labeler/defs.ts +93 -0
- package/src/lexicon/types/app/bsky/labeler/getServices.ts +51 -0
- package/src/lexicon/types/app/bsky/labeler/service.ts +31 -0
- package/src/lexicon/types/com/atproto/admin/defs.ts +3 -0
- package/src/lexicon/types/com/atproto/label/defs.ts +68 -0
- package/src/mod-service/index.ts +4 -3
- package/src/mod-service/status.ts +42 -26
- package/tests/__snapshots__/get-record.test.ts.snap +4 -4
- package/tests/__snapshots__/get-repo.test.ts.snap +2 -2
- package/tests/communication-templates.test.ts +7 -7
- package/tests/get-record.test.ts +17 -7
- package/tests/get-repo.test.ts +24 -12
- package/tests/moderation-appeals.test.ts +24 -52
- package/tests/moderation-events.test.ts +87 -130
- package/tests/moderation-status-tags.test.ts +16 -31
- package/tests/moderation-statuses.test.ts +125 -58
- package/tests/moderation.test.ts +140 -287
- package/tests/repo-search.test.ts +11 -4
|
@@ -3,7 +3,7 @@ import AppContext from '../../context'
|
|
|
3
3
|
|
|
4
4
|
export default function (server: Server, ctx: AppContext) {
|
|
5
5
|
server.com.atproto.admin.getModerationEvent({
|
|
6
|
-
auth: ctx.authVerifier.
|
|
6
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
7
7
|
handler: async ({ params }) => {
|
|
8
8
|
const { id } = params
|
|
9
9
|
const db = ctx.db
|
|
@@ -6,7 +6,7 @@ import { AtUri } from '@atproto/syntax'
|
|
|
6
6
|
|
|
7
7
|
export default function (server: Server, ctx: AppContext) {
|
|
8
8
|
server.com.atproto.admin.getRecord({
|
|
9
|
-
auth: ctx.authVerifier.
|
|
9
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
10
10
|
handler: async ({ params, auth }) => {
|
|
11
11
|
const db = ctx.db
|
|
12
12
|
|
package/src/api/admin/getRepo.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { addAccountInfoToRepoViewDetail, getPdsAccountInfo } from './util'
|
|
|
5
5
|
|
|
6
6
|
export default function (server: Server, ctx: AppContext) {
|
|
7
7
|
server.com.atproto.admin.getRepo({
|
|
8
|
-
auth: ctx.authVerifier.
|
|
8
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
9
9
|
handler: async ({ params, auth }) => {
|
|
10
10
|
const { did } = params
|
|
11
11
|
const db = ctx.db
|
|
@@ -4,7 +4,7 @@ import AppContext from '../../context'
|
|
|
4
4
|
|
|
5
5
|
export default function (server: Server, ctx: AppContext) {
|
|
6
6
|
server.com.atproto.admin.listCommunicationTemplates({
|
|
7
|
-
auth: ctx.authVerifier.
|
|
7
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
8
8
|
handler: async ({ auth }) => {
|
|
9
9
|
const access = auth.credentials
|
|
10
10
|
const db = ctx.db
|
|
@@ -4,7 +4,7 @@ import { getEventType } from '../moderation/util'
|
|
|
4
4
|
|
|
5
5
|
export default function (server: Server, ctx: AppContext) {
|
|
6
6
|
server.com.atproto.admin.queryModerationEvents({
|
|
7
|
-
auth: ctx.authVerifier.
|
|
7
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
8
8
|
handler: async ({ params }) => {
|
|
9
9
|
const {
|
|
10
10
|
subject,
|
|
@@ -4,7 +4,7 @@ import { getReviewState } from '../moderation/util'
|
|
|
4
4
|
|
|
5
5
|
export default function (server: Server, ctx: AppContext) {
|
|
6
6
|
server.com.atproto.admin.queryModerationStatuses({
|
|
7
|
-
auth: ctx.authVerifier.
|
|
7
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
8
8
|
handler: async ({ params }) => {
|
|
9
9
|
const {
|
|
10
10
|
subject,
|
|
@@ -4,7 +4,7 @@ import { mapDefined } from '@atproto/common'
|
|
|
4
4
|
|
|
5
5
|
export default function (server: Server, ctx: AppContext) {
|
|
6
6
|
server.com.atproto.admin.searchRepos({
|
|
7
|
-
auth: ctx.authVerifier.
|
|
7
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
8
8
|
handler: async ({ params }) => {
|
|
9
9
|
const modService = ctx.modService(ctx.db)
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ import AppContext from '../../context'
|
|
|
4
4
|
|
|
5
5
|
export default function (server: Server, ctx: AppContext) {
|
|
6
6
|
server.com.atproto.admin.updateCommunicationTemplate({
|
|
7
|
-
auth: ctx.authVerifier.
|
|
7
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
8
8
|
handler: async ({ input, auth }) => {
|
|
9
9
|
const access = auth.credentials
|
|
10
10
|
const db = ctx.db
|
package/src/api/admin/util.ts
CHANGED
|
@@ -8,8 +8,7 @@ import { ModerationLangService } from '../../mod-service/lang'
|
|
|
8
8
|
|
|
9
9
|
export default function (server: Server, ctx: AppContext) {
|
|
10
10
|
server.com.atproto.moderation.createReport({
|
|
11
|
-
|
|
12
|
-
auth: ctx.authVerifier.standardOptionalOrRole,
|
|
11
|
+
auth: ctx.authVerifier.standard,
|
|
13
12
|
handler: async ({ input, auth }) => {
|
|
14
13
|
const requester =
|
|
15
14
|
'iss' in auth.credentials ? auth.credentials.iss : ctx.cfg.service.did
|
package/src/api/proxied.ts
CHANGED
|
@@ -3,7 +3,7 @@ import AppContext from '../context'
|
|
|
3
3
|
|
|
4
4
|
export default function (server: Server, ctx: AppContext) {
|
|
5
5
|
server.app.bsky.actor.getProfile({
|
|
6
|
-
auth: ctx.authVerifier.
|
|
6
|
+
auth: ctx.authVerifier.moderator,
|
|
7
7
|
handler: async (request) => {
|
|
8
8
|
const res = await ctx.appviewAgent.api.app.bsky.actor.getProfile(
|
|
9
9
|
request.params,
|
|
@@ -17,7 +17,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
17
17
|
})
|
|
18
18
|
|
|
19
19
|
server.app.bsky.actor.getProfiles({
|
|
20
|
-
auth: ctx.authVerifier.
|
|
20
|
+
auth: ctx.authVerifier.moderator,
|
|
21
21
|
handler: async (request) => {
|
|
22
22
|
const res = await ctx.appviewAgent.api.app.bsky.actor.getProfiles(
|
|
23
23
|
request.params,
|
|
@@ -31,7 +31,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
server.app.bsky.feed.getAuthorFeed({
|
|
34
|
-
auth: ctx.authVerifier.
|
|
34
|
+
auth: ctx.authVerifier.moderator,
|
|
35
35
|
handler: async (request) => {
|
|
36
36
|
const res = await ctx.appviewAgent.api.app.bsky.feed.getAuthorFeed(
|
|
37
37
|
request.params,
|
|
@@ -45,7 +45,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
server.app.bsky.feed.getPostThread({
|
|
48
|
-
auth: ctx.authVerifier.
|
|
48
|
+
auth: ctx.authVerifier.moderator,
|
|
49
49
|
handler: async (request) => {
|
|
50
50
|
const res = await ctx.appviewAgent.api.app.bsky.feed.getPostThread(
|
|
51
51
|
request.params,
|
|
@@ -59,7 +59,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
server.app.bsky.feed.getFeedGenerator({
|
|
62
|
-
auth: ctx.authVerifier.
|
|
62
|
+
auth: ctx.authVerifier.moderator,
|
|
63
63
|
handler: async (request) => {
|
|
64
64
|
const res = await ctx.appviewAgent.api.app.bsky.feed.getFeedGenerator(
|
|
65
65
|
request.params,
|
|
@@ -73,7 +73,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
server.app.bsky.graph.getFollows({
|
|
76
|
-
auth: ctx.authVerifier.
|
|
76
|
+
auth: ctx.authVerifier.moderator,
|
|
77
77
|
handler: async (request) => {
|
|
78
78
|
const res = await ctx.appviewAgent.api.app.bsky.graph.getFollows(
|
|
79
79
|
request.params,
|
|
@@ -87,7 +87,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
87
87
|
})
|
|
88
88
|
|
|
89
89
|
server.app.bsky.graph.getFollowers({
|
|
90
|
-
auth: ctx.authVerifier.
|
|
90
|
+
auth: ctx.authVerifier.moderator,
|
|
91
91
|
handler: async (request) => {
|
|
92
92
|
const res = await ctx.appviewAgent.api.app.bsky.graph.getFollowers(
|
|
93
93
|
request.params,
|
|
@@ -101,7 +101,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
101
101
|
})
|
|
102
102
|
|
|
103
103
|
server.app.bsky.graph.getList({
|
|
104
|
-
auth: ctx.authVerifier.
|
|
104
|
+
auth: ctx.authVerifier.moderator,
|
|
105
105
|
handler: async (request) => {
|
|
106
106
|
const res = await ctx.appviewAgent.api.app.bsky.graph.getList(
|
|
107
107
|
request.params,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
export default function (server: Server, ctx: AppContext) {
|
|
10
10
|
server.com.atproto.temp.fetchLabels({
|
|
11
|
-
auth: ctx.authVerifier.
|
|
11
|
+
auth: ctx.authVerifier.standardOptionalOrAdminToken,
|
|
12
12
|
handler: async ({ auth, params }) => {
|
|
13
13
|
const { limit } = params
|
|
14
14
|
const since =
|
package/src/auth-verifier.ts
CHANGED
|
@@ -7,11 +7,11 @@ type ReqCtx = {
|
|
|
7
7
|
req: express.Request
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
type
|
|
10
|
+
type AdminTokenOutput = {
|
|
11
11
|
credentials: {
|
|
12
|
-
type: '
|
|
13
|
-
isAdmin:
|
|
14
|
-
isModerator:
|
|
12
|
+
type: 'admin_token'
|
|
13
|
+
isAdmin: true
|
|
14
|
+
isModerator: true
|
|
15
15
|
isTriage: true
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -51,8 +51,6 @@ export type AuthVerifierOpts = {
|
|
|
51
51
|
moderators: string[]
|
|
52
52
|
triage: string[]
|
|
53
53
|
adminPassword: string
|
|
54
|
-
moderatorPassword: string
|
|
55
|
-
triagePassword: string
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
export class AuthVerifier {
|
|
@@ -61,8 +59,6 @@ export class AuthVerifier {
|
|
|
61
59
|
moderators: string[]
|
|
62
60
|
triage: string[]
|
|
63
61
|
private adminPassword: string
|
|
64
|
-
private moderatorPassword: string
|
|
65
|
-
private triagePassword: string
|
|
66
62
|
|
|
67
63
|
constructor(public idResolver: IdResolver, opts: AuthVerifierOpts) {
|
|
68
64
|
this.serviceDid = opts.serviceDid
|
|
@@ -70,15 +66,15 @@ export class AuthVerifier {
|
|
|
70
66
|
this.moderators = opts.moderators
|
|
71
67
|
this.triage = opts.triage
|
|
72
68
|
this.adminPassword = opts.adminPassword
|
|
73
|
-
this.moderatorPassword = opts.moderatorPassword
|
|
74
|
-
this.triagePassword = opts.triagePassword
|
|
75
69
|
}
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
modOrAdminToken = async (
|
|
72
|
+
reqCtx: ReqCtx,
|
|
73
|
+
): Promise<ModeratorOutput | AdminTokenOutput> => {
|
|
74
|
+
if (isBasicToken(reqCtx.req)) {
|
|
75
|
+
return this.adminToken(reqCtx)
|
|
80
76
|
} else {
|
|
81
|
-
return this.
|
|
77
|
+
return this.moderator(reqCtx)
|
|
82
78
|
}
|
|
83
79
|
}
|
|
84
80
|
|
|
@@ -138,36 +134,30 @@ export class AuthVerifier {
|
|
|
138
134
|
return this.nullCreds()
|
|
139
135
|
}
|
|
140
136
|
|
|
141
|
-
|
|
137
|
+
standardOptionalOrAdminToken = async (
|
|
142
138
|
reqCtx: ReqCtx,
|
|
143
|
-
): Promise<StandardOutput |
|
|
139
|
+
): Promise<StandardOutput | AdminTokenOutput | NullOutput> => {
|
|
144
140
|
if (isBearerToken(reqCtx.req)) {
|
|
145
141
|
return this.standard(reqCtx)
|
|
146
142
|
} else if (isBasicToken(reqCtx.req)) {
|
|
147
|
-
return this.
|
|
143
|
+
return this.adminToken(reqCtx)
|
|
148
144
|
} else {
|
|
149
145
|
return this.nullCreds()
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
148
|
|
|
153
|
-
|
|
149
|
+
adminToken = async (reqCtx: ReqCtx): Promise<AdminTokenOutput> => {
|
|
154
150
|
const parsed = parseBasicAuth(reqCtx.req.headers.authorization ?? '')
|
|
155
151
|
const { username, password } = parsed ?? {}
|
|
156
|
-
if (username !== 'admin') {
|
|
157
|
-
throw new AuthRequiredError()
|
|
158
|
-
}
|
|
159
|
-
const isAdmin = password === this.adminPassword
|
|
160
|
-
const isModerator = isAdmin || password === this.moderatorPassword
|
|
161
|
-
const isTriage = isModerator || password === this.triagePassword
|
|
162
|
-
if (!isTriage) {
|
|
152
|
+
if (username !== 'admin' || password !== this.adminPassword) {
|
|
163
153
|
throw new AuthRequiredError()
|
|
164
154
|
}
|
|
165
155
|
return {
|
|
166
156
|
credentials: {
|
|
167
|
-
type: '
|
|
168
|
-
isAdmin,
|
|
169
|
-
isModerator,
|
|
170
|
-
isTriage,
|
|
157
|
+
type: 'admin_token',
|
|
158
|
+
isAdmin: true,
|
|
159
|
+
isModerator: true,
|
|
160
|
+
isTriage: true,
|
|
171
161
|
},
|
|
172
162
|
}
|
|
173
163
|
}
|
package/src/config/config.ts
CHANGED
|
@@ -25,18 +25,20 @@ export const envToCfg = (env: OzoneEnvironment): OzoneConfig => {
|
|
|
25
25
|
poolIdleTimeoutMs: env.dbPoolIdleTimeoutMs,
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
assert(env.appviewUrl)
|
|
29
|
-
assert(env.appviewDid)
|
|
28
|
+
assert(env.appviewUrl && env.appviewDid)
|
|
30
29
|
const appviewCfg: OzoneConfig['appview'] = {
|
|
31
30
|
url: env.appviewUrl,
|
|
32
31
|
did: env.appviewDid,
|
|
32
|
+
pushEvents: !!env.appviewPushEvents,
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
let pdsCfg: OzoneConfig['pds'] = null
|
|
36
|
+
if (env.pdsUrl || env.pdsDid) {
|
|
37
|
+
assert(env.pdsUrl && env.pdsDid)
|
|
38
|
+
pdsCfg = {
|
|
39
|
+
url: env.pdsUrl,
|
|
40
|
+
did: env.pdsDid,
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
const cdnCfg: OzoneConfig['cdn'] = {
|
|
@@ -94,6 +96,7 @@ export type DatabaseConfig = {
|
|
|
94
96
|
export type AppviewConfig = {
|
|
95
97
|
url: string
|
|
96
98
|
did: string
|
|
99
|
+
pushEvents: boolean
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
export type PdsConfig = {
|
package/src/config/env.ts
CHANGED
|
@@ -10,6 +10,7 @@ export const readEnv = (): OzoneEnvironment => {
|
|
|
10
10
|
serverDid: envStr('OZONE_SERVER_DID'),
|
|
11
11
|
appviewUrl: envStr('OZONE_APPVIEW_URL'),
|
|
12
12
|
appviewDid: envStr('OZONE_APPVIEW_DID'),
|
|
13
|
+
appviewPushEvents: envBool('OZONE_APPVIEW_PUSH_EVENTS'),
|
|
13
14
|
pdsUrl: envStr('OZONE_PDS_URL'),
|
|
14
15
|
pdsDid: envStr('OZONE_PDS_DID'),
|
|
15
16
|
dbPostgresUrl: envStr('OZONE_DB_POSTGRES_URL'),
|
|
@@ -23,8 +24,6 @@ export const readEnv = (): OzoneEnvironment => {
|
|
|
23
24
|
moderatorDids: envList('OZONE_MODERATOR_DIDS'),
|
|
24
25
|
triageDids: envList('OZONE_TRIAGE_DIDS'),
|
|
25
26
|
adminPassword: envStr('OZONE_ADMIN_PASSWORD'),
|
|
26
|
-
moderatorPassword: envStr('OZONE_MODERATOR_PASSWORD'),
|
|
27
|
-
triagePassword: envStr('OZONE_TRIAGE_PASSWORD'),
|
|
28
27
|
signingKeyHex: envStr('OZONE_SIGNING_KEY_HEX'),
|
|
29
28
|
}
|
|
30
29
|
}
|
|
@@ -38,6 +37,7 @@ export type OzoneEnvironment = {
|
|
|
38
37
|
serverDid?: string
|
|
39
38
|
appviewUrl?: string
|
|
40
39
|
appviewDid?: string
|
|
40
|
+
appviewPushEvents?: boolean
|
|
41
41
|
pdsUrl?: string
|
|
42
42
|
pdsDid?: string
|
|
43
43
|
dbPostgresUrl?: string
|
|
@@ -51,7 +51,5 @@ export type OzoneEnvironment = {
|
|
|
51
51
|
moderatorDids: string[]
|
|
52
52
|
triageDids: string[]
|
|
53
53
|
adminPassword?: string
|
|
54
|
-
moderatorPassword?: string
|
|
55
|
-
triagePassword?: string
|
|
56
54
|
signingKeyHex?: string
|
|
57
55
|
}
|
package/src/config/secrets.ts
CHANGED
|
@@ -3,21 +3,15 @@ import { OzoneEnvironment } from './env'
|
|
|
3
3
|
|
|
4
4
|
export const envToSecrets = (env: OzoneEnvironment): OzoneSecrets => {
|
|
5
5
|
assert(env.adminPassword)
|
|
6
|
-
assert(env.moderatorPassword)
|
|
7
|
-
assert(env.triagePassword)
|
|
8
6
|
assert(env.signingKeyHex)
|
|
9
7
|
|
|
10
8
|
return {
|
|
11
9
|
adminPassword: env.adminPassword,
|
|
12
|
-
moderatorPassword: env.moderatorPassword,
|
|
13
|
-
triagePassword: env.triagePassword,
|
|
14
10
|
signingKeyHex: env.signingKeyHex,
|
|
15
11
|
}
|
|
16
12
|
}
|
|
17
13
|
|
|
18
14
|
export type OzoneSecrets = {
|
|
19
15
|
adminPassword: string
|
|
20
|
-
moderatorPassword: string
|
|
21
|
-
triagePassword: string
|
|
22
16
|
signingKeyHex: string
|
|
23
17
|
}
|
package/src/context.ts
CHANGED
|
@@ -62,7 +62,7 @@ export class AppContext {
|
|
|
62
62
|
|
|
63
63
|
const backgroundQueue = new BackgroundQueue(db)
|
|
64
64
|
const eventPusher = new EventPusher(db, createAuthHeaders, {
|
|
65
|
-
appview: cfg.appview,
|
|
65
|
+
appview: cfg.appview.pushEvents ? cfg.appview : undefined,
|
|
66
66
|
pds: cfg.pds ?? undefined,
|
|
67
67
|
})
|
|
68
68
|
|
|
@@ -92,8 +92,6 @@ export class AppContext {
|
|
|
92
92
|
moderators: cfg.access.moderators,
|
|
93
93
|
triage: cfg.access.triage,
|
|
94
94
|
adminPassword: secrets.adminPassword,
|
|
95
|
-
moderatorPassword: secrets.moderatorPassword,
|
|
96
|
-
triagePassword: secrets.triagePassword,
|
|
97
95
|
})
|
|
98
96
|
|
|
99
97
|
return new AppContext(
|
package/src/daemon/context.ts
CHANGED
|
@@ -35,13 +35,13 @@ export class DaemonContext {
|
|
|
35
35
|
const appviewAgent = new AtpAgent({ service: cfg.appview.url })
|
|
36
36
|
const createAuthHeaders = (aud: string) =>
|
|
37
37
|
createServiceAuthHeaders({
|
|
38
|
-
iss: cfg.service.did
|
|
38
|
+
iss: `${cfg.service.did}#atproto_labeler`,
|
|
39
39
|
aud,
|
|
40
40
|
keypair: signingKey,
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
const eventPusher = new EventPusher(db, createAuthHeaders, {
|
|
44
|
-
appview: cfg.appview,
|
|
44
|
+
appview: cfg.appview.pushEvents ? cfg.appview : undefined,
|
|
45
45
|
pds: cfg.pds ?? undefined,
|
|
46
46
|
})
|
|
47
47
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import assert from 'node:assert'
|
|
1
2
|
import AtpAgent from '@atproto/api'
|
|
2
3
|
import { SECOND } from '@atproto/common'
|
|
3
4
|
import Database from '../db'
|
|
5
|
+
import { RepoPushEventType } from '../db/schema/repo_push_event'
|
|
4
6
|
import { retryHttp } from '../util'
|
|
5
7
|
import { dbLogger } from '../logger'
|
|
6
8
|
import { InputSchema } from '../lexicon/types/com/atproto/admin/updateSubjectStatus'
|
|
7
|
-
import assert from 'assert'
|
|
8
9
|
|
|
9
10
|
type EventSubject = InputSchema['subject']
|
|
10
11
|
|
|
@@ -74,6 +75,13 @@ export class EventPusher {
|
|
|
74
75
|
this.poll(this.blobPollState, () => this.pushBlobEvents())
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
get takedowns(): RepoPushEventType[] {
|
|
79
|
+
const takedowns: RepoPushEventType[] = []
|
|
80
|
+
if (this.pds) takedowns.push('pds_takedown')
|
|
81
|
+
if (this.appview) takedowns.push('appview_takedown')
|
|
82
|
+
return takedowns
|
|
83
|
+
}
|
|
84
|
+
|
|
77
85
|
poll(state: PollState, fn: () => Promise<void>) {
|
|
78
86
|
if (this.destroyed) return
|
|
79
87
|
state.promise = fn()
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
REVIEWCLOSED,
|
|
4
4
|
REVIEWOPEN,
|
|
5
5
|
REVIEWESCALATED,
|
|
6
|
+
REVIEWNONE,
|
|
6
7
|
} from '../../lexicon/types/com/atproto/admin/defs'
|
|
7
8
|
|
|
8
9
|
export const subjectStatusTableName = 'moderation_subject_status'
|
|
@@ -13,7 +14,11 @@ export interface ModerationSubjectStatus {
|
|
|
13
14
|
recordPath: string
|
|
14
15
|
recordCid: string | null
|
|
15
16
|
blobCids: string[] | null
|
|
16
|
-
reviewState:
|
|
17
|
+
reviewState:
|
|
18
|
+
| typeof REVIEWCLOSED
|
|
19
|
+
| typeof REVIEWOPEN
|
|
20
|
+
| typeof REVIEWESCALATED
|
|
21
|
+
| typeof REVIEWNONE
|
|
17
22
|
createdAt: string
|
|
18
23
|
updatedAt: string
|
|
19
24
|
lastReviewedBy: string | null
|
package/src/lexicon/index.ts
CHANGED
|
@@ -129,6 +129,7 @@ import * as AppBskyGraphMuteActor from './types/app/bsky/graph/muteActor'
|
|
|
129
129
|
import * as AppBskyGraphMuteActorList from './types/app/bsky/graph/muteActorList'
|
|
130
130
|
import * as AppBskyGraphUnmuteActor from './types/app/bsky/graph/unmuteActor'
|
|
131
131
|
import * as AppBskyGraphUnmuteActorList from './types/app/bsky/graph/unmuteActorList'
|
|
132
|
+
import * as AppBskyLabelerGetServices from './types/app/bsky/labeler/getServices'
|
|
132
133
|
import * as AppBskyNotificationGetUnreadCount from './types/app/bsky/notification/getUnreadCount'
|
|
133
134
|
import * as AppBskyNotificationListNotifications from './types/app/bsky/notification/listNotifications'
|
|
134
135
|
import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/registerPush'
|
|
@@ -142,6 +143,7 @@ export const COM_ATPROTO_ADMIN = {
|
|
|
142
143
|
DefsReviewOpen: 'com.atproto.admin.defs#reviewOpen',
|
|
143
144
|
DefsReviewEscalated: 'com.atproto.admin.defs#reviewEscalated',
|
|
144
145
|
DefsReviewClosed: 'com.atproto.admin.defs#reviewClosed',
|
|
146
|
+
DefsReviewNone: 'com.atproto.admin.defs#reviewNone',
|
|
145
147
|
}
|
|
146
148
|
export const COM_ATPROTO_MODERATION = {
|
|
147
149
|
DefsReasonSpam: 'com.atproto.moderation.defs#reasonSpam',
|
|
@@ -1204,6 +1206,7 @@ export class AppBskyNS {
|
|
|
1204
1206
|
embed: AppBskyEmbedNS
|
|
1205
1207
|
feed: AppBskyFeedNS
|
|
1206
1208
|
graph: AppBskyGraphNS
|
|
1209
|
+
labeler: AppBskyLabelerNS
|
|
1207
1210
|
notification: AppBskyNotificationNS
|
|
1208
1211
|
richtext: AppBskyRichtextNS
|
|
1209
1212
|
unspecced: AppBskyUnspeccedNS
|
|
@@ -1214,6 +1217,7 @@ export class AppBskyNS {
|
|
|
1214
1217
|
this.embed = new AppBskyEmbedNS(server)
|
|
1215
1218
|
this.feed = new AppBskyFeedNS(server)
|
|
1216
1219
|
this.graph = new AppBskyGraphNS(server)
|
|
1220
|
+
this.labeler = new AppBskyLabelerNS(server)
|
|
1217
1221
|
this.notification = new AppBskyNotificationNS(server)
|
|
1218
1222
|
this.richtext = new AppBskyRichtextNS(server)
|
|
1219
1223
|
this.unspecced = new AppBskyUnspeccedNS(server)
|
|
@@ -1659,6 +1663,25 @@ export class AppBskyGraphNS {
|
|
|
1659
1663
|
}
|
|
1660
1664
|
}
|
|
1661
1665
|
|
|
1666
|
+
export class AppBskyLabelerNS {
|
|
1667
|
+
_server: Server
|
|
1668
|
+
|
|
1669
|
+
constructor(server: Server) {
|
|
1670
|
+
this._server = server
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
getServices<AV extends AuthVerifier>(
|
|
1674
|
+
cfg: ConfigOf<
|
|
1675
|
+
AV,
|
|
1676
|
+
AppBskyLabelerGetServices.Handler<ExtractAuth<AV>>,
|
|
1677
|
+
AppBskyLabelerGetServices.HandlerReqCtx<ExtractAuth<AV>>
|
|
1678
|
+
>,
|
|
1679
|
+
) {
|
|
1680
|
+
const nsid = 'app.bsky.labeler.getServices' // @ts-ignore
|
|
1681
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1662
1685
|
export class AppBskyNotificationNS {
|
|
1663
1686
|
_server: Server
|
|
1664
1687
|
|