@atproto/ozone 0.0.2 → 0.0.5
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 +21 -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 +971 -240
- package/dist/index.js.map +3 -3
- package/dist/lexicon/index.d.ts +10 -0
- package/dist/lexicon/lexicons.d.ts +230 -0
- package/dist/lexicon/types/app/bsky/unspecced/{getPopular.d.ts → getTaggedSuggestions.d.ts} +10 -6
- package/dist/lexicon/types/{app/bsky/moderation/getService.d.ts → com/atproto/admin/createCommunicationTemplate.d.ts} +13 -5
- 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/com/atproto/admin/updateCommunicationTemplate.d.ts +39 -0
- 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 +60 -0
- package/src/lexicon/lexicons.ts +249 -0
- package/src/lexicon/types/app/bsky/unspecced/getTaggedSuggestions.ts +65 -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,131 @@
|
|
|
1
|
+
import { TestNetwork, SeedClient, basicSeed } from '@atproto/dev-env'
|
|
2
|
+
import AtpAgent from '@atproto/api'
|
|
3
|
+
|
|
4
|
+
describe('communication-templates', () => {
|
|
5
|
+
let network: TestNetwork
|
|
6
|
+
let agent: AtpAgent
|
|
7
|
+
let sc: SeedClient
|
|
8
|
+
|
|
9
|
+
beforeAll(async () => {
|
|
10
|
+
network = await TestNetwork.create({
|
|
11
|
+
dbPostgresSchema: 'ozone_communication_templates',
|
|
12
|
+
})
|
|
13
|
+
agent = network.ozone.getClient()
|
|
14
|
+
sc = network.getSeedClient()
|
|
15
|
+
await basicSeed(sc)
|
|
16
|
+
await network.processAll()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
afterAll(async () => {
|
|
20
|
+
await network.close()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const templateOne = {
|
|
24
|
+
name: 'Test name 1',
|
|
25
|
+
subject: 'Test subject 1',
|
|
26
|
+
contentMarkdown: 'Test content 1',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const listTemplates = async () => {
|
|
30
|
+
const { data } =
|
|
31
|
+
await agent.api.com.atproto.admin.listCommunicationTemplates(
|
|
32
|
+
{},
|
|
33
|
+
{
|
|
34
|
+
headers: network.ozone.adminAuthHeaders('moderator'),
|
|
35
|
+
},
|
|
36
|
+
)
|
|
37
|
+
return data.communicationTemplates
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe('create templates', () => {
|
|
41
|
+
it('only allows admins to create new templates', async () => {
|
|
42
|
+
const moderatorReq =
|
|
43
|
+
agent.api.com.atproto.admin.createCommunicationTemplate(
|
|
44
|
+
{ ...templateOne, createdBy: sc.dids.bob },
|
|
45
|
+
{
|
|
46
|
+
encoding: 'application/json',
|
|
47
|
+
headers: network.ozone.adminAuthHeaders('moderator'),
|
|
48
|
+
},
|
|
49
|
+
)
|
|
50
|
+
await expect(moderatorReq).rejects.toThrow(
|
|
51
|
+
'Must be an admin to create a communication template',
|
|
52
|
+
)
|
|
53
|
+
const modReq =
|
|
54
|
+
await agent.api.com.atproto.admin.createCommunicationTemplate(
|
|
55
|
+
{ ...templateOne, createdBy: sc.dids.bob },
|
|
56
|
+
{
|
|
57
|
+
encoding: 'application/json',
|
|
58
|
+
headers: network.ozone.adminAuthHeaders('admin'),
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
expect(modReq.data).toMatchObject({
|
|
63
|
+
...templateOne,
|
|
64
|
+
lastUpdatedBy: sc.dids.bob,
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
describe('list templates', () => {
|
|
69
|
+
it('returns all saved templates', async () => {
|
|
70
|
+
const listBefore = await listTemplates()
|
|
71
|
+
expect(listBefore.length).toEqual(1)
|
|
72
|
+
expect(listBefore[0]).toMatchObject(templateOne)
|
|
73
|
+
|
|
74
|
+
const templateTwo = {
|
|
75
|
+
...templateOne,
|
|
76
|
+
name: 'Test template 2',
|
|
77
|
+
}
|
|
78
|
+
await agent.api.com.atproto.admin.createCommunicationTemplate(
|
|
79
|
+
{ ...templateTwo, createdBy: sc.dids.bob },
|
|
80
|
+
{
|
|
81
|
+
encoding: 'application/json',
|
|
82
|
+
headers: network.ozone.adminAuthHeaders('admin'),
|
|
83
|
+
},
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
const listAfter = await listTemplates()
|
|
87
|
+
expect(listAfter.length).toEqual(2)
|
|
88
|
+
expect(listAfter[1]).toMatchObject(templateTwo)
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
describe('update template', () => {
|
|
92
|
+
it('allows moderators to update a template by id', async () => {
|
|
93
|
+
const { data } =
|
|
94
|
+
await agent.api.com.atproto.admin.updateCommunicationTemplate(
|
|
95
|
+
{ id: '1', updatedBy: sc.dids.bob, name: '1 Test template' },
|
|
96
|
+
{
|
|
97
|
+
encoding: 'application/json',
|
|
98
|
+
headers: network.ozone.adminAuthHeaders('admin'),
|
|
99
|
+
},
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
expect(data.name).not.toEqual(templateOne.name)
|
|
103
|
+
expect(data.name).toEqual('1 Test template')
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
describe('delete template', () => {
|
|
107
|
+
it('allows admins to remove a template by id', async () => {
|
|
108
|
+
const modReq = agent.api.com.atproto.admin.deleteCommunicationTemplate(
|
|
109
|
+
{ id: '1' },
|
|
110
|
+
{
|
|
111
|
+
encoding: 'application/json',
|
|
112
|
+
headers: network.ozone.adminAuthHeaders('moderator'),
|
|
113
|
+
},
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
await expect(modReq).rejects.toThrow(
|
|
117
|
+
'Must be an admin to delete a communication template',
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
await agent.api.com.atproto.admin.deleteCommunicationTemplate(
|
|
121
|
+
{ id: '1' },
|
|
122
|
+
{
|
|
123
|
+
encoding: 'application/json',
|
|
124
|
+
headers: network.ozone.adminAuthHeaders('admin'),
|
|
125
|
+
},
|
|
126
|
+
)
|
|
127
|
+
const list = await listTemplates()
|
|
128
|
+
expect(list.length).toEqual(1)
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
})
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import AppContext from '../../../../context';
|
|
2
|
-
import { RepoView, RepoViewDetail, AccountView } from '../../../../lexicon/types/com/atproto/admin/defs';
|
|
3
|
-
export declare const getPdsAccountInfo: (ctx: AppContext, did: string) => Promise<AccountView | null>;
|
|
4
|
-
export declare const addAccountInfoToRepoViewDetail: (repoView: RepoViewDetail, accountInfo: AccountView | null, includeEmail?: boolean) => RepoViewDetail;
|
|
5
|
-
export declare const addAccountInfoToRepoView: (repoView: RepoView, accountInfo: AccountView | null, includeEmail?: boolean) => RepoView;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { InputSchema as ReportInput } from '../../../../lexicon/types/com/atproto/moderation/createReport';
|
|
2
|
-
export declare const getReasonType: (reasonType: ReportInput['reasonType']) => string | boolean;
|
|
3
|
-
export declare const getEventType: (type: string) => "com.atproto.admin.defs#modEventTakedown" | "com.atproto.admin.defs#modEventAcknowledge" | "com.atproto.admin.defs#modEventEscalate" | "com.atproto.admin.defs#modEventComment" | "com.atproto.admin.defs#modEventLabel" | "com.atproto.admin.defs#modEventReport" | "com.atproto.admin.defs#modEventMute" | "com.atproto.admin.defs#modEventReverseTakedown" | "com.atproto.admin.defs#modEventEmail";
|
|
4
|
-
export declare const getReviewState: (reviewState?: string) => "com.atproto.admin.defs#reviewOpen" | "com.atproto.admin.defs#reviewEscalated" | "com.atproto.admin.defs#reviewClosed" | undefined;
|
package/dist/api/util.d.ts
DELETED
package/dist/auth-verifier.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { IdResolver } from '@atproto/identity';
|
|
2
|
-
import express from 'express';
|
|
3
|
-
type ReqCtx = {
|
|
4
|
-
req: express.Request;
|
|
5
|
-
};
|
|
6
|
-
type AdminOutput = {
|
|
7
|
-
credentials: {
|
|
8
|
-
type: 'admin';
|
|
9
|
-
aud: string;
|
|
10
|
-
iss: string;
|
|
11
|
-
isModerator: boolean;
|
|
12
|
-
isTriage: true;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
type StandardOutput = {
|
|
16
|
-
credentials: {
|
|
17
|
-
type: 'standard';
|
|
18
|
-
aud: string;
|
|
19
|
-
iss: string;
|
|
20
|
-
isModerator: boolean;
|
|
21
|
-
isTriage: boolean;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
type NullOutput = {
|
|
25
|
-
credentials: {
|
|
26
|
-
type: 'null';
|
|
27
|
-
iss: null;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export type AuthVerifierOpts = {
|
|
31
|
-
serviceDid: string;
|
|
32
|
-
moderators: string[];
|
|
33
|
-
triage: string[];
|
|
34
|
-
};
|
|
35
|
-
export declare class AuthVerifier {
|
|
36
|
-
idResolver: IdResolver;
|
|
37
|
-
serviceDid: string;
|
|
38
|
-
moderators: string[];
|
|
39
|
-
triage: string[];
|
|
40
|
-
constructor(idResolver: IdResolver, opts: AuthVerifierOpts);
|
|
41
|
-
admin: (reqCtx: ReqCtx) => Promise<AdminOutput>;
|
|
42
|
-
standard: (reqCtx: ReqCtx) => Promise<StandardOutput>;
|
|
43
|
-
standardOptional: (reqCtx: ReqCtx) => Promise<StandardOutput | NullOutput>;
|
|
44
|
-
nullCreds(): NullOutput;
|
|
45
|
-
}
|
|
46
|
-
export declare const getJwtStrFromReq: (req: express.Request) => string | null;
|
|
47
|
-
export {};
|
package/dist/config.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export interface ServerConfigValues {
|
|
2
|
-
version: string;
|
|
3
|
-
debugMode?: boolean;
|
|
4
|
-
port?: number;
|
|
5
|
-
publicUrl?: string;
|
|
6
|
-
serverDid: string;
|
|
7
|
-
appviewUrl: string;
|
|
8
|
-
appviewDid?: string;
|
|
9
|
-
pdsUrl?: string;
|
|
10
|
-
pdsDid?: string;
|
|
11
|
-
dbPostgresUrl: string;
|
|
12
|
-
dbPostgresSchema?: string;
|
|
13
|
-
didPlcUrl: string;
|
|
14
|
-
labelerDid: string;
|
|
15
|
-
adminPassword: string;
|
|
16
|
-
moderatorPassword?: string;
|
|
17
|
-
triagePassword?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare class ServerConfig {
|
|
20
|
-
private cfg;
|
|
21
|
-
private assignedPort?;
|
|
22
|
-
constructor(cfg: ServerConfigValues);
|
|
23
|
-
static readEnv(overrides?: Partial<ServerConfigValues>): ServerConfig;
|
|
24
|
-
assignPort(port: number): void;
|
|
25
|
-
get version(): string;
|
|
26
|
-
get debugMode(): boolean;
|
|
27
|
-
get port(): number | undefined;
|
|
28
|
-
get localUrl(): string;
|
|
29
|
-
get publicUrl(): string | undefined;
|
|
30
|
-
get serverDid(): string;
|
|
31
|
-
get appviewUrl(): string;
|
|
32
|
-
get appviewDid(): string | undefined;
|
|
33
|
-
get pdsUrl(): string | undefined;
|
|
34
|
-
get pdsDid(): string | undefined;
|
|
35
|
-
get dbPostgresUrl(): string;
|
|
36
|
-
get dbPostgresSchema(): string | undefined;
|
|
37
|
-
get didPlcUrl(): string;
|
|
38
|
-
get labelerDid(): string;
|
|
39
|
-
get adminPassword(): string;
|
|
40
|
-
get moderatorPassword(): string | undefined;
|
|
41
|
-
get triagePassword(): string | undefined;
|
|
42
|
-
}
|
package/dist/daemon/config.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export interface DaemonConfigValues {
|
|
2
|
-
version: string;
|
|
3
|
-
dbPostgresUrl: string;
|
|
4
|
-
dbPostgresSchema?: string;
|
|
5
|
-
serverDid: string;
|
|
6
|
-
appviewUrl: string;
|
|
7
|
-
appviewDid?: string;
|
|
8
|
-
pdsUrl?: string;
|
|
9
|
-
pdsDid?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare class DaemonConfig {
|
|
12
|
-
private cfg;
|
|
13
|
-
constructor(cfg: DaemonConfigValues);
|
|
14
|
-
static readEnv(overrides?: Partial<DaemonConfigValues>): DaemonConfig;
|
|
15
|
-
get version(): string;
|
|
16
|
-
get dbPostgresUrl(): string;
|
|
17
|
-
get dbPostgresSchema(): string | undefined;
|
|
18
|
-
get serverDid(): string;
|
|
19
|
-
get appviewUrl(): string;
|
|
20
|
-
get appviewDid(): string | undefined;
|
|
21
|
-
get pdsUrl(): string | undefined;
|
|
22
|
-
get pdsDid(): string | undefined;
|
|
23
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ValidationResult } from '@atproto/lexicon';
|
|
2
|
-
import * as AppBskyActorDefs from '../actor/defs';
|
|
3
|
-
import * as AppBskyRichtextFacet from '../richtext/facet';
|
|
4
|
-
import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs';
|
|
5
|
-
import * as ComAtprotoModerationDefs from '../../../com/atproto/moderation/defs';
|
|
6
|
-
export interface ModServiceView {
|
|
7
|
-
uri: string;
|
|
8
|
-
cid: string;
|
|
9
|
-
creator: AppBskyActorDefs.ProfileView;
|
|
10
|
-
description?: string;
|
|
11
|
-
descriptionFacets?: AppBskyRichtextFacet.Main[];
|
|
12
|
-
likeCount?: number;
|
|
13
|
-
viewer?: ModServiceViewerState;
|
|
14
|
-
indexedAt: string;
|
|
15
|
-
labels?: ComAtprotoLabelDefs.Label[];
|
|
16
|
-
[k: string]: unknown;
|
|
17
|
-
}
|
|
18
|
-
export declare function isModServiceView(v: unknown): v is ModServiceView;
|
|
19
|
-
export declare function validateModServiceView(v: unknown): ValidationResult;
|
|
20
|
-
export interface ModServiceViewDetailed {
|
|
21
|
-
uri: string;
|
|
22
|
-
cid: string;
|
|
23
|
-
creator: AppBskyActorDefs.ProfileView;
|
|
24
|
-
description?: string;
|
|
25
|
-
descriptionFacets?: AppBskyRichtextFacet.Main[];
|
|
26
|
-
policies: ModServicePolicies;
|
|
27
|
-
likeCount?: number;
|
|
28
|
-
viewer?: ModServiceViewerState;
|
|
29
|
-
indexedAt: string;
|
|
30
|
-
labels?: ComAtprotoLabelDefs.Label[];
|
|
31
|
-
[k: string]: unknown;
|
|
32
|
-
}
|
|
33
|
-
export declare function isModServiceViewDetailed(v: unknown): v is ModServiceViewDetailed;
|
|
34
|
-
export declare function validateModServiceViewDetailed(v: unknown): ValidationResult;
|
|
35
|
-
export interface ModServiceViewerState {
|
|
36
|
-
like?: string;
|
|
37
|
-
[k: string]: unknown;
|
|
38
|
-
}
|
|
39
|
-
export declare function isModServiceViewerState(v: unknown): v is ModServiceViewerState;
|
|
40
|
-
export declare function validateModServiceViewerState(v: unknown): ValidationResult;
|
|
41
|
-
export interface ModServicePolicies {
|
|
42
|
-
description?: string;
|
|
43
|
-
descriptionFacets?: AppBskyRichtextFacet.Main[];
|
|
44
|
-
reportReasons: ComAtprotoModerationDefs.ReasonType[];
|
|
45
|
-
labelValues: ComAtprotoLabelDefs.LabelValue[];
|
|
46
|
-
[k: string]: unknown;
|
|
47
|
-
}
|
|
48
|
-
export declare function isModServicePolicies(v: unknown): v is ModServicePolicies;
|
|
49
|
-
export declare function validateModServicePolicies(v: unknown): ValidationResult;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ValidationResult } from '@atproto/lexicon';
|
|
2
|
-
import * as AppBskyRichtextFacet from '../richtext/facet';
|
|
3
|
-
import * as AppBskyModerationDefs from './defs';
|
|
4
|
-
import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs';
|
|
5
|
-
export interface Record {
|
|
6
|
-
description?: string;
|
|
7
|
-
descriptionFacets?: AppBskyRichtextFacet.Main[];
|
|
8
|
-
policies: AppBskyModerationDefs.ModServicePolicies;
|
|
9
|
-
labels?: ComAtprotoLabelDefs.SelfLabels | {
|
|
10
|
-
$type: string;
|
|
11
|
-
[k: string]: unknown;
|
|
12
|
-
};
|
|
13
|
-
createdAt: string;
|
|
14
|
-
[k: string]: unknown;
|
|
15
|
-
}
|
|
16
|
-
export declare function isRecord(v: unknown): v is Record;
|
|
17
|
-
export declare function validateRecord(v: unknown): ValidationResult;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AsyncBuffer } from '@atproto/common';
|
|
2
|
-
import { Sequencer, LabelsEvt } from './sequencer';
|
|
3
|
-
export type OutboxOpts = {
|
|
4
|
-
maxBufferSize: number;
|
|
5
|
-
};
|
|
6
|
-
export declare class Outbox {
|
|
7
|
-
sequencer: Sequencer;
|
|
8
|
-
private caughtUp;
|
|
9
|
-
lastSeen: number;
|
|
10
|
-
cutoverBuffer: LabelsEvt[];
|
|
11
|
-
outBuffer: AsyncBuffer<LabelsEvt>;
|
|
12
|
-
constructor(sequencer: Sequencer, opts?: Partial<OutboxOpts>);
|
|
13
|
-
events(backfillCursor?: number, signal?: AbortSignal): AsyncGenerator<LabelsEvt>;
|
|
14
|
-
getBackfill(backfillCursor: number): AsyncGenerator<LabelsEvt, void, unknown>;
|
|
15
|
-
}
|
|
16
|
-
export default Outbox;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import TypedEmitter from 'typed-emitter';
|
|
3
|
-
import Database from '../db';
|
|
4
|
-
import { Labels as LabelsEvt } from '../lexicon/types/com/atproto/label/subscribeLabels';
|
|
5
|
-
import { Label as LabelTable } from '../db/schema/label';
|
|
6
|
-
import { Selectable } from 'kysely';
|
|
7
|
-
import { ModerationService } from '../mod-service';
|
|
8
|
-
export type { Labels as LabelsEvt } from '../lexicon/types/com/atproto/label/subscribeLabels';
|
|
9
|
-
type LabelRow = Selectable<LabelTable>;
|
|
10
|
-
declare const Sequencer_base: new () => SequencerEmitter;
|
|
11
|
-
export declare class Sequencer extends Sequencer_base {
|
|
12
|
-
modService: ModerationService;
|
|
13
|
-
lastSeen: number;
|
|
14
|
-
destroyed: boolean;
|
|
15
|
-
pollPromise: Promise<void>;
|
|
16
|
-
pollTimer: NodeJS.Timer | undefined;
|
|
17
|
-
triesWithNoResults: number;
|
|
18
|
-
db: Database;
|
|
19
|
-
constructor(modService: ModerationService, lastSeen?: number);
|
|
20
|
-
start(): Promise<void>;
|
|
21
|
-
destroy(): Promise<void>;
|
|
22
|
-
curr(): Promise<number | null>;
|
|
23
|
-
next(cursor: number): Promise<LabelRow | null>;
|
|
24
|
-
requestLabelRange(opts: {
|
|
25
|
-
earliestId?: number;
|
|
26
|
-
limit?: number;
|
|
27
|
-
}): Promise<LabelsEvt[]>;
|
|
28
|
-
private poll;
|
|
29
|
-
}
|
|
30
|
-
type SequencerEvents = {
|
|
31
|
-
events: (evts: LabelsEvt[]) => void;
|
|
32
|
-
close: () => void;
|
|
33
|
-
};
|
|
34
|
-
export type SequencerEmitter = TypedEmitter<SequencerEvents>;
|
|
35
|
-
export default Sequencer;
|
package/dist/services/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import AtpAgent from '@atproto/api';
|
|
2
|
-
import { ModerationService } from './moderation';
|
|
3
|
-
import { FromDb } from './types';
|
|
4
|
-
export declare function createServices(appviewAgent: AtpAgent): Services;
|
|
5
|
-
export declare type Services = {
|
|
6
|
-
moderation: FromDb<ModerationService>;
|
|
7
|
-
};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { CID } from 'multiformats/cid';
|
|
2
|
-
import { AtUri } from '@atproto/syntax';
|
|
3
|
-
import { Database } from '../../db';
|
|
4
|
-
import { ModerationViews } from './views';
|
|
5
|
-
import { Main as StrongRef } from '../../lexicon/types/com/atproto/repo/strongRef';
|
|
6
|
-
import { RepoRef, RepoBlobRef } from '../../lexicon/types/com/atproto/admin/defs';
|
|
7
|
-
import { ModEventType, ModerationEventRow, ModerationSubjectStatusRow, ReversibleModerationEvent } from './types';
|
|
8
|
-
import { ModerationEvent } from '../../db/schema/moderation_event';
|
|
9
|
-
import AtpAgent from '@atproto/api';
|
|
10
|
-
import { Label } from '../../lexicon/types/com/atproto/label/defs';
|
|
11
|
-
import { ModSubject, RecordSubject, RepoSubject } from './subject';
|
|
12
|
-
export declare class ModerationService {
|
|
13
|
-
db: Database;
|
|
14
|
-
appviewAgent: AtpAgent;
|
|
15
|
-
constructor(db: Database, appviewAgent: AtpAgent);
|
|
16
|
-
static creator(appviewAgent: AtpAgent): (db: Database) => ModerationService;
|
|
17
|
-
views: ModerationViews;
|
|
18
|
-
getEvent(id: number): Promise<ModerationEventRow | undefined>;
|
|
19
|
-
getEventOrThrow(id: number): Promise<ModerationEventRow>;
|
|
20
|
-
getEvents(opts: {
|
|
21
|
-
subject?: string;
|
|
22
|
-
createdBy?: string;
|
|
23
|
-
limit: number;
|
|
24
|
-
cursor?: string;
|
|
25
|
-
includeAllUserRecords: boolean;
|
|
26
|
-
types: ModerationEvent['action'][];
|
|
27
|
-
sortDirection?: 'asc' | 'desc';
|
|
28
|
-
}): Promise<{
|
|
29
|
-
cursor?: string;
|
|
30
|
-
events: ModerationEventRow[];
|
|
31
|
-
}>;
|
|
32
|
-
getReport(id: number): Promise<ModerationEventRow | undefined>;
|
|
33
|
-
getCurrentStatus(subject: {
|
|
34
|
-
did: string;
|
|
35
|
-
} | {
|
|
36
|
-
uri: AtUri;
|
|
37
|
-
} | {
|
|
38
|
-
cids: CID[];
|
|
39
|
-
}): Promise<{
|
|
40
|
-
did: string;
|
|
41
|
-
id: number;
|
|
42
|
-
createdAt: string;
|
|
43
|
-
updatedAt: string;
|
|
44
|
-
reviewState: "com.atproto.admin.defs#reviewOpen" | "com.atproto.admin.defs#reviewEscalated" | "com.atproto.admin.defs#reviewClosed";
|
|
45
|
-
blobCids: string[] | null;
|
|
46
|
-
comment: string | null;
|
|
47
|
-
lastReportedAt: string | null;
|
|
48
|
-
lastReviewedAt: string | null;
|
|
49
|
-
muteUntil: string | null;
|
|
50
|
-
lastReviewedBy: string | null;
|
|
51
|
-
takendown: boolean;
|
|
52
|
-
suspendUntil: string | null;
|
|
53
|
-
recordPath: string;
|
|
54
|
-
recordCid: string | null;
|
|
55
|
-
}[]>;
|
|
56
|
-
logEvent(info: {
|
|
57
|
-
event: ModEventType;
|
|
58
|
-
subject: ModSubject;
|
|
59
|
-
createdBy: string;
|
|
60
|
-
createdAt?: Date;
|
|
61
|
-
}): Promise<ModerationEventRow>;
|
|
62
|
-
getLastReversibleEventForSubject(subject: ReversalSubject): Promise<{
|
|
63
|
-
id: number;
|
|
64
|
-
createdBy: string;
|
|
65
|
-
createdAt: string;
|
|
66
|
-
comment: string | null;
|
|
67
|
-
createLabelVals: string | null;
|
|
68
|
-
negateLabelVals: string | null;
|
|
69
|
-
durationInHours: number | null;
|
|
70
|
-
action: "com.atproto.admin.defs#modEventTakedown" | "com.atproto.admin.defs#modEventAcknowledge" | "com.atproto.admin.defs#modEventEscalate" | "com.atproto.admin.defs#modEventComment" | "com.atproto.admin.defs#modEventLabel" | "com.atproto.admin.defs#modEventReport" | "com.atproto.admin.defs#modEventMute" | "com.atproto.admin.defs#modEventReverseTakedown" | "com.atproto.admin.defs#modEventEmail";
|
|
71
|
-
subjectType: "com.atproto.admin.defs#repoRef" | "com.atproto.repo.strongRef";
|
|
72
|
-
subjectDid: string;
|
|
73
|
-
subjectUri: string | null;
|
|
74
|
-
subjectCid: string | null;
|
|
75
|
-
meta: Record<string, string | boolean> | null;
|
|
76
|
-
expiresAt: string | null;
|
|
77
|
-
legacyRefId: number | null;
|
|
78
|
-
} | null | undefined>;
|
|
79
|
-
getSubjectsDueForReversal(): Promise<ReversalSubject[]>;
|
|
80
|
-
isSubjectSuspended(did: string): Promise<boolean>;
|
|
81
|
-
revertState({ createdBy, createdAt, comment, action, subject, }: ReversibleModerationEvent): Promise<ModerationEventRow>;
|
|
82
|
-
takedownRepo(subject: RepoSubject, takedownId: number): Promise<void>;
|
|
83
|
-
reverseTakedownRepo(subject: RepoSubject): Promise<void>;
|
|
84
|
-
takedownRecord(subject: RecordSubject, takedownId: number): Promise<void>;
|
|
85
|
-
reverseTakedownRecord(subject: RecordSubject): Promise<void>;
|
|
86
|
-
report(info: {
|
|
87
|
-
reasonType: NonNullable<ModerationEventRow['meta']>['reportType'];
|
|
88
|
-
reason?: string;
|
|
89
|
-
subject: ModSubject;
|
|
90
|
-
reportedBy: string;
|
|
91
|
-
createdAt?: Date;
|
|
92
|
-
}): Promise<ModerationEventRow>;
|
|
93
|
-
getSubjectStatuses({ cursor, limit, takendown, reviewState, reviewedAfter, reviewedBefore, reportedAfter, reportedBefore, includeMuted, ignoreSubjects, sortDirection, lastReviewedBy, sortField, subject, }: {
|
|
94
|
-
cursor?: string;
|
|
95
|
-
limit?: number;
|
|
96
|
-
takendown?: boolean;
|
|
97
|
-
reviewedBefore?: string;
|
|
98
|
-
reviewState?: ModerationSubjectStatusRow['reviewState'];
|
|
99
|
-
reviewedAfter?: string;
|
|
100
|
-
reportedAfter?: string;
|
|
101
|
-
reportedBefore?: string;
|
|
102
|
-
includeMuted?: boolean;
|
|
103
|
-
subject?: string;
|
|
104
|
-
ignoreSubjects?: string[];
|
|
105
|
-
sortDirection: 'asc' | 'desc';
|
|
106
|
-
lastReviewedBy?: string;
|
|
107
|
-
sortField: 'lastReviewedAt' | 'lastReportedAt';
|
|
108
|
-
}): Promise<{
|
|
109
|
-
statuses: {
|
|
110
|
-
handle: string;
|
|
111
|
-
did: string;
|
|
112
|
-
id: number;
|
|
113
|
-
createdAt: string;
|
|
114
|
-
updatedAt: string;
|
|
115
|
-
reviewState: "com.atproto.admin.defs#reviewOpen" | "com.atproto.admin.defs#reviewEscalated" | "com.atproto.admin.defs#reviewClosed";
|
|
116
|
-
blobCids: string[] | null;
|
|
117
|
-
comment: string | null;
|
|
118
|
-
lastReportedAt: string | null;
|
|
119
|
-
lastReviewedAt: string | null;
|
|
120
|
-
muteUntil: string | null;
|
|
121
|
-
lastReviewedBy: string | null;
|
|
122
|
-
takendown: boolean;
|
|
123
|
-
suspendUntil: string | null;
|
|
124
|
-
recordPath: string;
|
|
125
|
-
recordCid: string | null;
|
|
126
|
-
}[];
|
|
127
|
-
cursor: string | undefined;
|
|
128
|
-
}>;
|
|
129
|
-
isSubjectTakendown(subject: ModSubject): Promise<boolean>;
|
|
130
|
-
formatAndCreateLabels(src: string, uri: string, cid: string | null, labels: {
|
|
131
|
-
create?: string[];
|
|
132
|
-
negate?: string[];
|
|
133
|
-
}): Promise<Label[]>;
|
|
134
|
-
createLabels(labels: Label[]): Promise<void>;
|
|
135
|
-
}
|
|
136
|
-
export declare type TakedownSubjects = {
|
|
137
|
-
did: string;
|
|
138
|
-
subjects: (RepoRef | RepoBlobRef | StrongRef)[];
|
|
139
|
-
};
|
|
140
|
-
export declare type ReversalSubject = {
|
|
141
|
-
subject: ModSubject;
|
|
142
|
-
reverseSuspend: boolean;
|
|
143
|
-
reverseMute: boolean;
|
|
144
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AtUri } from '@atproto/syntax';
|
|
2
|
-
import { Database } from '../../db';
|
|
3
|
-
import { ModerationSubjectStatus } from '../../db/schema/moderation_subject_status';
|
|
4
|
-
import { ModerationEventRow } from './types';
|
|
5
|
-
export declare const adjustModerationSubjectStatus: (db: Database, moderationEvent: ModerationEventRow, blobCids?: string[]) => Promise<import("kysely").InsertResult | null>;
|
|
6
|
-
declare type ModerationSubjectStatusFilter = Pick<ModerationSubjectStatus, 'did'> | Pick<ModerationSubjectStatus, 'did' | 'recordPath'> | Pick<ModerationSubjectStatus, 'did' | 'recordPath' | 'recordCid'>;
|
|
7
|
-
export declare const getModerationSubjectStatus: (db: Database, filters: ModerationSubjectStatusFilter) => Promise<{} | undefined>;
|
|
8
|
-
export declare const getStatusIdentifierFromSubject: (subject: string | AtUri) => {
|
|
9
|
-
did: string;
|
|
10
|
-
recordPath: string;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { AtUri } from '@atproto/syntax';
|
|
2
|
-
import { InputSchema as ReportInput } from '../../lexicon/types/com/atproto/moderation/createReport';
|
|
3
|
-
import { InputSchema as ActionInput } from '../../lexicon/types/com/atproto/admin/emitModerationEvent';
|
|
4
|
-
import { ModerationEventRow, ModerationSubjectStatusRow } from './types';
|
|
5
|
-
import { RepoRef } from '../../lexicon/types/com/atproto/admin/defs';
|
|
6
|
-
import { Main as StrongRef } from '../../lexicon/types/com/atproto/repo/strongRef';
|
|
7
|
-
declare type SubjectInput = ReportInput['subject'] | ActionInput['subject'];
|
|
8
|
-
export declare const subjectFromInput: (subject: SubjectInput, blobs?: string[]) => ModSubject;
|
|
9
|
-
export declare const subjectFromEventRow: (row: ModerationEventRow) => ModSubject;
|
|
10
|
-
export declare const subjectFromStatusRow: (row: ModerationSubjectStatusRow) => ModSubject;
|
|
11
|
-
declare type SubjectInfo = {
|
|
12
|
-
subjectType: 'com.atproto.admin.defs#repoRef' | 'com.atproto.repo.strongRef';
|
|
13
|
-
subjectDid: string;
|
|
14
|
-
subjectUri: string | null;
|
|
15
|
-
subjectCid: string | null;
|
|
16
|
-
};
|
|
17
|
-
export interface ModSubject {
|
|
18
|
-
did: string;
|
|
19
|
-
recordPath: string | undefined;
|
|
20
|
-
blobCids?: string[];
|
|
21
|
-
isRepo(): this is RepoSubject;
|
|
22
|
-
isRecord(): this is RecordSubject;
|
|
23
|
-
info(): SubjectInfo;
|
|
24
|
-
lex(): RepoRef | StrongRef;
|
|
25
|
-
}
|
|
26
|
-
export declare class RepoSubject implements ModSubject {
|
|
27
|
-
did: string;
|
|
28
|
-
blobCids: undefined;
|
|
29
|
-
recordPath: undefined;
|
|
30
|
-
constructor(did: string);
|
|
31
|
-
isRepo(): boolean;
|
|
32
|
-
isRecord(): boolean;
|
|
33
|
-
isWeakRecord(): boolean;
|
|
34
|
-
info(): {
|
|
35
|
-
subjectType: "com.atproto.admin.defs#repoRef";
|
|
36
|
-
subjectDid: string;
|
|
37
|
-
subjectUri: null;
|
|
38
|
-
subjectCid: null;
|
|
39
|
-
};
|
|
40
|
-
lex(): RepoRef;
|
|
41
|
-
}
|
|
42
|
-
export declare class RecordSubject implements ModSubject {
|
|
43
|
-
uri: string;
|
|
44
|
-
cid: string;
|
|
45
|
-
blobCids?: string[] | undefined;
|
|
46
|
-
parsedUri: AtUri;
|
|
47
|
-
did: string;
|
|
48
|
-
recordPath: string;
|
|
49
|
-
constructor(uri: string, cid: string, blobCids?: string[] | undefined);
|
|
50
|
-
isRepo(): boolean;
|
|
51
|
-
isRecord(): boolean;
|
|
52
|
-
info(): {
|
|
53
|
-
subjectType: "com.atproto.repo.strongRef";
|
|
54
|
-
subjectDid: string;
|
|
55
|
-
subjectUri: string;
|
|
56
|
-
subjectCid: string;
|
|
57
|
-
};
|
|
58
|
-
lex(): StrongRef;
|
|
59
|
-
}
|
|
60
|
-
export {};
|