@atproto/bsky 0.0.10 → 0.0.12
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 +26 -0
- package/dist/api/com/atproto/admin/util.d.ts +5 -0
- package/dist/config.d.ts +2 -0
- package/dist/context.d.ts +8 -0
- package/dist/db/index.js +51 -2
- package/dist/db/index.js.map +3 -3
- package/dist/db/migrations/20230929T192920807Z-record-cursor-indexes.d.ts +3 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/did-cache.d.ts +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1818 -580
- package/dist/index.js.map +3 -3
- package/dist/lexicon/index.d.ts +16 -0
- package/dist/lexicon/lexicons.d.ts +330 -3
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/admin/defs.d.ts +28 -0
- package/dist/lexicon/types/com/atproto/admin/getAccountInfo.d.ts +29 -0
- package/dist/lexicon/types/com/atproto/admin/getSubjectStatus.d.ts +39 -0
- package/dist/lexicon/types/com/atproto/admin/searchRepos.d.ts +0 -1
- package/dist/lexicon/types/com/atproto/admin/updateSubjectStatus.d.ts +46 -0
- package/dist/lexicon/types/com/atproto/server/confirmEmail.d.ts +27 -0
- package/dist/lexicon/types/com/atproto/server/createAccount.d.ts +2 -0
- package/dist/lexicon/types/com/atproto/server/createSession.d.ts +2 -0
- package/dist/lexicon/types/com/atproto/server/getSession.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/server/requestEmailConfirmation.d.ts +19 -0
- package/dist/lexicon/types/com/atproto/server/requestEmailUpdate.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/server/reserveSigningKey.d.ts +30 -0
- package/dist/lexicon/types/com/atproto/server/updateEmail.d.ts +27 -0
- package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +1 -0
- package/dist/services/actor/index.d.ts +2 -2
- package/dist/services/actor/types.d.ts +1 -0
- package/dist/services/graph/index.d.ts +2 -0
- package/dist/services/moderation/index.d.ts +13 -3
- package/dist/services/util/search.d.ts +3 -3
- package/package.json +13 -14
- package/src/api/app/bsky/actor/searchActors.ts +36 -22
- package/src/api/app/bsky/actor/searchActorsTypeahead.ts +24 -17
- package/src/api/app/bsky/feed/getAuthorFeed.ts +2 -2
- package/src/api/app/bsky/feed/getPostThread.ts +2 -2
- package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +1 -0
- package/src/api/app/bsky/notification/listNotifications.ts +33 -22
- package/src/api/com/atproto/admin/getModerationAction.ts +28 -2
- package/src/api/com/atproto/admin/getModerationReport.ts +27 -2
- package/src/api/com/atproto/admin/getRecord.ts +14 -2
- package/src/api/com/atproto/admin/getRepo.ts +13 -2
- package/src/api/com/atproto/admin/reverseModerationAction.ts +31 -5
- package/src/api/com/atproto/admin/searchRepos.ts +6 -12
- package/src/api/com/atproto/admin/takeModerationAction.ts +41 -7
- package/src/api/com/atproto/admin/util.ts +50 -0
- package/src/api/well-known.ts +8 -0
- package/src/auth.ts +12 -5
- package/src/auto-moderator/index.ts +1 -0
- package/src/config.ts +7 -0
- package/src/context.ts +30 -0
- package/src/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +40 -0
- package/src/db/migrations/index.ts +1 -0
- package/src/did-cache.ts +29 -14
- package/src/feed-gen/with-friends.ts +2 -2
- package/src/index.ts +9 -1
- package/src/indexer/subscription.ts +1 -21
- package/src/lexicon/index.ts +96 -0
- package/src/lexicon/lexicons.ts +368 -4
- package/src/lexicon/types/app/bsky/actor/defs.ts +1 -0
- package/src/lexicon/types/com/atproto/admin/defs.ts +61 -0
- package/src/lexicon/types/com/atproto/admin/getAccountInfo.ts +41 -0
- package/src/lexicon/types/com/atproto/admin/getSubjectStatus.ts +54 -0
- package/src/lexicon/types/com/atproto/admin/searchRepos.ts +0 -1
- package/src/lexicon/types/com/atproto/admin/updateSubjectStatus.ts +61 -0
- package/src/lexicon/types/com/atproto/server/confirmEmail.ts +40 -0
- package/src/lexicon/types/com/atproto/server/createAccount.ts +2 -0
- package/src/lexicon/types/com/atproto/server/createSession.ts +2 -0
- package/src/lexicon/types/com/atproto/server/getSession.ts +1 -0
- package/src/lexicon/types/com/atproto/server/refreshSession.ts +1 -0
- package/src/lexicon/types/com/atproto/server/requestEmailConfirmation.ts +31 -0
- package/src/lexicon/types/com/atproto/server/requestEmailUpdate.ts +43 -0
- package/src/lexicon/types/com/atproto/server/reserveSigningKey.ts +44 -0
- package/src/lexicon/types/com/atproto/server/updateEmail.ts +41 -0
- package/src/lexicon/types/com/atproto/sync/listRepos.ts +1 -0
- package/src/logger.ts +8 -0
- package/src/services/actor/index.ts +16 -10
- package/src/services/actor/types.ts +1 -0
- package/src/services/actor/views.ts +26 -8
- package/src/services/graph/index.ts +26 -7
- package/src/services/indexing/index.ts +15 -17
- package/src/services/moderation/index.ts +94 -14
- package/src/services/moderation/views.ts +1 -0
- package/src/services/util/search.ts +24 -23
- package/tests/__snapshots__/feed-generation.test.ts.snap +12 -12
- package/tests/__snapshots__/indexing.test.ts.snap +4 -4
- package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +172 -0
- package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +178 -0
- package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +177 -0
- package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +307 -0
- package/tests/admin/__snapshots__/get-record.test.ts.snap +275 -0
- package/tests/admin/__snapshots__/get-repo.test.ts.snap +103 -0
- package/tests/admin/get-moderation-action.test.ts +100 -0
- package/tests/admin/get-moderation-actions.test.ts +164 -0
- package/tests/admin/get-moderation-report.test.ts +100 -0
- package/tests/admin/get-moderation-reports.test.ts +332 -0
- package/tests/admin/get-record.test.ts +115 -0
- package/tests/admin/get-repo.test.ts +101 -0
- package/tests/{moderation.test.ts → admin/moderation.test.ts} +107 -9
- package/tests/admin/repo-search.test.ts +124 -0
- package/tests/algos/hot-classic.test.ts +3 -5
- package/tests/algos/whats-hot.test.ts +3 -5
- package/tests/algos/with-friends.test.ts +2 -4
- package/tests/auth.test.ts +64 -0
- package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -3
- package/tests/auto-moderator/labeler.test.ts +5 -7
- package/tests/auto-moderator/takedowns.test.ts +11 -12
- package/tests/blob-resolver.test.ts +1 -3
- package/tests/did-cache.test.ts +2 -5
- package/tests/feed-generation.test.ts +8 -6
- package/tests/handle-invalidation.test.ts +2 -3
- package/tests/image/server.test.ts +1 -4
- package/tests/image/sharp.test.ts +1 -1
- package/tests/indexing.test.ts +4 -4
- package/tests/notification-server.test.ts +2 -3
- package/tests/pipeline/backpressure.test.ts +2 -3
- package/tests/pipeline/reingest.test.ts +7 -4
- package/tests/pipeline/repartition.test.ts +2 -3
- package/tests/reprocessing.test.ts +2 -6
- package/tests/seeds/basic.ts +4 -4
- package/tests/seeds/follows.ts +1 -1
- package/tests/seeds/likes.ts +1 -1
- package/tests/seeds/reposts.ts +1 -1
- package/tests/seeds/users-bulk.ts +1 -1
- package/tests/seeds/users.ts +1 -1
- package/tests/server.test.ts +1 -3
- package/tests/subscription/repo.test.ts +2 -4
- package/tests/views/__snapshots__/author-feed.test.ts.snap +24 -24
- package/tests/views/__snapshots__/block-lists.test.ts.snap +42 -7
- package/tests/views/__snapshots__/blocks.test.ts.snap +2 -2
- package/tests/views/__snapshots__/list-feed.test.ts.snap +6 -6
- package/tests/views/__snapshots__/mute-lists.test.ts.snap +15 -4
- package/tests/views/__snapshots__/mutes.test.ts.snap +2 -2
- package/tests/views/__snapshots__/notifications.test.ts.snap +2 -2
- package/tests/views/__snapshots__/posts.test.ts.snap +8 -8
- package/tests/views/__snapshots__/thread.test.ts.snap +10 -10
- package/tests/views/__snapshots__/timeline.test.ts.snap +58 -58
- package/tests/views/actor-likes.test.ts +2 -3
- package/tests/views/actor-search.test.ts +5 -5
- package/tests/views/admin/repo-search.test.ts +2 -4
- package/tests/views/author-feed.test.ts +2 -4
- package/tests/views/block-lists.test.ts +34 -7
- package/tests/views/blocks.test.ts +6 -3
- package/tests/views/follows.test.ts +2 -4
- package/tests/views/likes.test.ts +2 -5
- package/tests/views/list-feed.test.ts +2 -4
- package/tests/views/mute-lists.test.ts +23 -5
- package/tests/views/mutes.test.ts +2 -5
- package/tests/views/notifications.test.ts +2 -4
- package/tests/views/posts.test.ts +2 -5
- package/tests/views/profile.test.ts +4 -5
- package/tests/views/reposts.test.ts +2 -4
- package/tests/views/suggested-follows.test.ts +2 -3
- package/tests/views/suggestions.test.ts +2 -4
- package/tests/views/thread.test.ts +2 -4
- package/tests/views/threadgating.test.ts +2 -3
- package/tests/views/timeline.test.ts +2 -4
- package/dist/env.d.ts +0 -1
- package/example.dev.env +0 -5
- package/src/env.ts +0 -9
- package/tests/seeds/client.ts +0 -466
- /package/tests/{__snapshots__ → admin/__snapshots__}/moderation.test.ts.snap +0 -0
- /package/tests/{image/fixtures → sample-img}/at.png +0 -0
- /package/tests/{image/fixtures → sample-img}/hd-key.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-alt.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-landscape-large.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-landscape-small.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-portrait-large.jpg +0 -0
- /package/tests/{image/fixtures → sample-img}/key-portrait-small.jpg +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { HandlerAuth } from '@atproto/xrpc-server';
|
|
3
|
+
import * as ComAtprotoAdminDefs from './defs';
|
|
4
|
+
import * as ComAtprotoRepoStrongRef from '../repo/strongRef';
|
|
5
|
+
export interface QueryParams {
|
|
6
|
+
did?: string;
|
|
7
|
+
uri?: string;
|
|
8
|
+
blob?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare type InputSchema = undefined;
|
|
11
|
+
export interface OutputSchema {
|
|
12
|
+
subject: ComAtprotoAdminDefs.RepoRef | ComAtprotoRepoStrongRef.Main | ComAtprotoAdminDefs.RepoBlobRef | {
|
|
13
|
+
$type: string;
|
|
14
|
+
[k: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
takedown?: ComAtprotoAdminDefs.StatusAttr;
|
|
17
|
+
[k: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
export declare type HandlerInput = undefined;
|
|
20
|
+
export interface HandlerSuccess {
|
|
21
|
+
encoding: 'application/json';
|
|
22
|
+
body: OutputSchema;
|
|
23
|
+
headers?: {
|
|
24
|
+
[key: string]: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface HandlerError {
|
|
28
|
+
status: number;
|
|
29
|
+
message?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare type HandlerOutput = HandlerError | HandlerSuccess;
|
|
32
|
+
export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
|
33
|
+
auth: HA;
|
|
34
|
+
params: QueryParams;
|
|
35
|
+
input: HandlerInput;
|
|
36
|
+
req: express.Request;
|
|
37
|
+
res: express.Response;
|
|
38
|
+
};
|
|
39
|
+
export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { HandlerAuth } from '@atproto/xrpc-server';
|
|
3
|
+
import * as ComAtprotoAdminDefs from './defs';
|
|
4
|
+
import * as ComAtprotoRepoStrongRef from '../repo/strongRef';
|
|
5
|
+
export interface QueryParams {
|
|
6
|
+
}
|
|
7
|
+
export interface InputSchema {
|
|
8
|
+
subject: ComAtprotoAdminDefs.RepoRef | ComAtprotoRepoStrongRef.Main | ComAtprotoAdminDefs.RepoBlobRef | {
|
|
9
|
+
$type: string;
|
|
10
|
+
[k: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
takedown?: ComAtprotoAdminDefs.StatusAttr;
|
|
13
|
+
[k: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface OutputSchema {
|
|
16
|
+
subject: ComAtprotoAdminDefs.RepoRef | ComAtprotoRepoStrongRef.Main | ComAtprotoAdminDefs.RepoBlobRef | {
|
|
17
|
+
$type: string;
|
|
18
|
+
[k: string]: unknown;
|
|
19
|
+
};
|
|
20
|
+
takedown?: ComAtprotoAdminDefs.StatusAttr;
|
|
21
|
+
[k: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface HandlerInput {
|
|
24
|
+
encoding: 'application/json';
|
|
25
|
+
body: InputSchema;
|
|
26
|
+
}
|
|
27
|
+
export interface HandlerSuccess {
|
|
28
|
+
encoding: 'application/json';
|
|
29
|
+
body: OutputSchema;
|
|
30
|
+
headers?: {
|
|
31
|
+
[key: string]: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface HandlerError {
|
|
35
|
+
status: number;
|
|
36
|
+
message?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare type HandlerOutput = HandlerError | HandlerSuccess;
|
|
39
|
+
export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
|
40
|
+
auth: HA;
|
|
41
|
+
params: QueryParams;
|
|
42
|
+
input: HandlerInput;
|
|
43
|
+
req: express.Request;
|
|
44
|
+
res: express.Response;
|
|
45
|
+
};
|
|
46
|
+
export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { HandlerAuth } from '@atproto/xrpc-server';
|
|
3
|
+
export interface QueryParams {
|
|
4
|
+
}
|
|
5
|
+
export interface InputSchema {
|
|
6
|
+
email: string;
|
|
7
|
+
token: string;
|
|
8
|
+
[k: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface HandlerInput {
|
|
11
|
+
encoding: 'application/json';
|
|
12
|
+
body: InputSchema;
|
|
13
|
+
}
|
|
14
|
+
export interface HandlerError {
|
|
15
|
+
status: number;
|
|
16
|
+
message?: string;
|
|
17
|
+
error?: 'AccountNotFound' | 'ExpiredToken' | 'InvalidToken' | 'InvalidEmail';
|
|
18
|
+
}
|
|
19
|
+
export declare type HandlerOutput = HandlerError | void;
|
|
20
|
+
export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
|
21
|
+
auth: HA;
|
|
22
|
+
params: QueryParams;
|
|
23
|
+
input: HandlerInput;
|
|
24
|
+
req: express.Request;
|
|
25
|
+
res: express.Response;
|
|
26
|
+
};
|
|
27
|
+
export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
|
|
@@ -9,6 +9,7 @@ export interface InputSchema {
|
|
|
9
9
|
inviteCode?: string;
|
|
10
10
|
password: string;
|
|
11
11
|
recoveryKey?: string;
|
|
12
|
+
plcOp?: Uint8Array;
|
|
12
13
|
[k: string]: unknown;
|
|
13
14
|
}
|
|
14
15
|
export interface OutputSchema {
|
|
@@ -16,6 +17,7 @@ export interface OutputSchema {
|
|
|
16
17
|
refreshJwt: string;
|
|
17
18
|
handle: string;
|
|
18
19
|
did: string;
|
|
20
|
+
didDoc?: {};
|
|
19
21
|
[k: string]: unknown;
|
|
20
22
|
}
|
|
21
23
|
export interface HandlerInput {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { HandlerAuth } from '@atproto/xrpc-server';
|
|
3
|
+
export interface QueryParams {
|
|
4
|
+
}
|
|
5
|
+
export declare type InputSchema = undefined;
|
|
6
|
+
export declare type HandlerInput = undefined;
|
|
7
|
+
export interface HandlerError {
|
|
8
|
+
status: number;
|
|
9
|
+
message?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare type HandlerOutput = HandlerError | void;
|
|
12
|
+
export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
|
13
|
+
auth: HA;
|
|
14
|
+
params: QueryParams;
|
|
15
|
+
input: HandlerInput;
|
|
16
|
+
req: express.Request;
|
|
17
|
+
res: express.Response;
|
|
18
|
+
};
|
|
19
|
+
export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { HandlerAuth } from '@atproto/xrpc-server';
|
|
3
|
+
export interface QueryParams {
|
|
4
|
+
}
|
|
5
|
+
export declare type InputSchema = undefined;
|
|
6
|
+
export interface OutputSchema {
|
|
7
|
+
tokenRequired: boolean;
|
|
8
|
+
[k: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export declare type HandlerInput = undefined;
|
|
11
|
+
export interface HandlerSuccess {
|
|
12
|
+
encoding: 'application/json';
|
|
13
|
+
body: OutputSchema;
|
|
14
|
+
headers?: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface HandlerError {
|
|
19
|
+
status: number;
|
|
20
|
+
message?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare type HandlerOutput = HandlerError | HandlerSuccess;
|
|
23
|
+
export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
|
24
|
+
auth: HA;
|
|
25
|
+
params: QueryParams;
|
|
26
|
+
input: HandlerInput;
|
|
27
|
+
req: express.Request;
|
|
28
|
+
res: express.Response;
|
|
29
|
+
};
|
|
30
|
+
export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { HandlerAuth } from '@atproto/xrpc-server';
|
|
3
|
+
export interface QueryParams {
|
|
4
|
+
}
|
|
5
|
+
export declare type InputSchema = undefined;
|
|
6
|
+
export interface OutputSchema {
|
|
7
|
+
signingKey: string;
|
|
8
|
+
[k: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export declare type HandlerInput = undefined;
|
|
11
|
+
export interface HandlerSuccess {
|
|
12
|
+
encoding: 'application/json';
|
|
13
|
+
body: OutputSchema;
|
|
14
|
+
headers?: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface HandlerError {
|
|
19
|
+
status: number;
|
|
20
|
+
message?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare type HandlerOutput = HandlerError | HandlerSuccess;
|
|
23
|
+
export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
|
24
|
+
auth: HA;
|
|
25
|
+
params: QueryParams;
|
|
26
|
+
input: HandlerInput;
|
|
27
|
+
req: express.Request;
|
|
28
|
+
res: express.Response;
|
|
29
|
+
};
|
|
30
|
+
export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { HandlerAuth } from '@atproto/xrpc-server';
|
|
3
|
+
export interface QueryParams {
|
|
4
|
+
}
|
|
5
|
+
export interface InputSchema {
|
|
6
|
+
email: string;
|
|
7
|
+
token?: string;
|
|
8
|
+
[k: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface HandlerInput {
|
|
11
|
+
encoding: 'application/json';
|
|
12
|
+
body: InputSchema;
|
|
13
|
+
}
|
|
14
|
+
export interface HandlerError {
|
|
15
|
+
status: number;
|
|
16
|
+
message?: string;
|
|
17
|
+
error?: 'ExpiredToken' | 'InvalidToken' | 'TokenRequired';
|
|
18
|
+
}
|
|
19
|
+
export declare type HandlerOutput = HandlerError | void;
|
|
20
|
+
export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
|
21
|
+
auth: HA;
|
|
22
|
+
params: QueryParams;
|
|
23
|
+
input: HandlerInput;
|
|
24
|
+
req: express.Request;
|
|
25
|
+
res: express.Response;
|
|
26
|
+
};
|
|
27
|
+
export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
|
|
@@ -15,10 +15,10 @@ export declare class ActorService {
|
|
|
15
15
|
getActorDid(handleOrDid: string): Promise<string | null>;
|
|
16
16
|
getActor(handleOrDid: string, includeSoftDeleted?: boolean): Promise<ActorResult | null>;
|
|
17
17
|
getActors(handleOrDids: string[], includeSoftDeleted?: boolean): Promise<ActorResult[]>;
|
|
18
|
-
getSearchResults({ cursor, limit,
|
|
18
|
+
getSearchResults({ cursor, limit, query, includeSoftDeleted, }: {
|
|
19
19
|
cursor?: string;
|
|
20
20
|
limit?: number;
|
|
21
|
-
|
|
21
|
+
query?: string;
|
|
22
22
|
includeSoftDeleted?: boolean;
|
|
23
23
|
}): Promise<{
|
|
24
24
|
results: Actor[];
|
|
@@ -85,6 +85,7 @@ export declare type RelationshipPair = [didA: string, didB: string];
|
|
|
85
85
|
export declare class BlockAndMuteState {
|
|
86
86
|
hasIdx: Map<string, Set<string>>;
|
|
87
87
|
blockIdx: Map<string, Map<string, string>>;
|
|
88
|
+
blockListIdx: Map<string, Map<string, string>>;
|
|
88
89
|
muteIdx: Map<string, Set<string>>;
|
|
89
90
|
muteListIdx: Map<string, Map<string, string>>;
|
|
90
91
|
constructor(items?: BlockAndMuteInfo[]);
|
|
@@ -93,6 +94,7 @@ export declare class BlockAndMuteState {
|
|
|
93
94
|
blocking(pair: RelationshipPair): string | null;
|
|
94
95
|
blockedBy(pair: RelationshipPair): string | null;
|
|
95
96
|
mute(pair: RelationshipPair): boolean;
|
|
97
|
+
blockList(pair: RelationshipPair): string | null;
|
|
96
98
|
muteList(pair: RelationshipPair): string | null;
|
|
97
99
|
has(pair: RelationshipPair): boolean;
|
|
98
100
|
}
|
|
@@ -6,6 +6,8 @@ import { ModerationAction, ModerationReport } from '../../db/tables/moderation';
|
|
|
6
6
|
import { ModerationViews } from './views';
|
|
7
7
|
import { ImageUriBuilder } from '../../image/uri';
|
|
8
8
|
import { ImageInvalidator } from '../../image/invalidator';
|
|
9
|
+
import { RepoRef, RepoBlobRef } from '../../lexicon/types/com/atproto/admin/defs';
|
|
10
|
+
import { Main as StrongRef } from '../../lexicon/types/com/atproto/repo/strongRef';
|
|
9
11
|
export declare class ModerationService {
|
|
10
12
|
db: PrimaryDatabase;
|
|
11
13
|
imgUriBuilder: ImageUriBuilder;
|
|
@@ -74,20 +76,24 @@ export declare class ModerationService {
|
|
|
74
76
|
durationInHours?: number;
|
|
75
77
|
}): Promise<ModerationActionRow>;
|
|
76
78
|
getActionsDueForReversal(): Promise<ModerationActionRow[]>;
|
|
77
|
-
revertAction({ id, createdBy, createdAt, reason, }: ReversibleModerationAction): Promise<
|
|
79
|
+
revertAction({ id, createdBy, createdAt, reason, }: ReversibleModerationAction): Promise<{
|
|
80
|
+
result: ModerationActionRow;
|
|
81
|
+
restored?: TakedownSubjects;
|
|
82
|
+
}>;
|
|
78
83
|
logReverseAction(info: ReversibleModerationAction): Promise<ModerationActionRow>;
|
|
79
84
|
takedownRepo(info: {
|
|
80
85
|
takedownId: number;
|
|
81
86
|
did: string;
|
|
82
|
-
}): Promise<
|
|
87
|
+
}): Promise<TakedownSubjects>;
|
|
83
88
|
reverseTakedownRepo(info: {
|
|
84
89
|
did: string;
|
|
85
90
|
}): Promise<void>;
|
|
86
91
|
takedownRecord(info: {
|
|
87
92
|
takedownId: number;
|
|
88
93
|
uri: AtUri;
|
|
94
|
+
cid: CID;
|
|
89
95
|
blobCids?: CID[];
|
|
90
|
-
}): Promise<
|
|
96
|
+
}): Promise<TakedownSubjects>;
|
|
91
97
|
reverseTakedownRecord(info: {
|
|
92
98
|
uri: AtUri;
|
|
93
99
|
}): Promise<void>;
|
|
@@ -110,6 +116,10 @@ export declare class ModerationService {
|
|
|
110
116
|
createdAt?: Date;
|
|
111
117
|
}): Promise<ModerationReportRow>;
|
|
112
118
|
}
|
|
119
|
+
export declare type TakedownSubjects = {
|
|
120
|
+
did: string;
|
|
121
|
+
subjects: (RepoRef | RepoBlobRef | StrongRef)[];
|
|
122
|
+
};
|
|
113
123
|
export declare type ModerationActionRow = Selectable<ModerationAction>;
|
|
114
124
|
export declare type ReversibleModerationAction = Pick<ModerationActionRow, 'id' | 'createdBy' | 'reason'> & {
|
|
115
125
|
createdAt?: Date;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Database } from '../../db';
|
|
2
2
|
import { GenericKeyset } from '../../db/pagination';
|
|
3
3
|
export declare const getUserSearchQuery: (db: Database, opts: {
|
|
4
|
-
|
|
4
|
+
query: string;
|
|
5
5
|
limit: number;
|
|
6
6
|
cursor?: string;
|
|
7
7
|
includeSoftDeleted?: boolean;
|
|
@@ -10,13 +10,13 @@ export declare const getUserSearchQuery: (db: Database, opts: {
|
|
|
10
10
|
distance: number;
|
|
11
11
|
}, "results">>, "actor" | "results", {}>;
|
|
12
12
|
export declare const getUserSearchQuerySimple: (db: Database, opts: {
|
|
13
|
-
|
|
13
|
+
query: string;
|
|
14
14
|
limit: number;
|
|
15
15
|
}) => import("kysely").SelectQueryBuilder<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, import("kysely").AliasedQueryBuilder<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, import("kysely").AliasedQueryBuilder<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "actor">, "actor", import("kysely").Selection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "actor">, "actor", import("kysely").AliasedRawBuilder<number, "distance"> | import("kysely").AliasedRawBuilder<unknown, "did">>, "accounts_and_profiles">>, "accounts_and_profiles", {
|
|
16
16
|
did: unknown;
|
|
17
17
|
distance: number;
|
|
18
18
|
}, "results">>, "actor" | "results", {}>;
|
|
19
|
-
export declare const
|
|
19
|
+
export declare const cleanQuery: (query: string) => string;
|
|
20
20
|
declare type Result = {
|
|
21
21
|
distance: number;
|
|
22
22
|
did: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/bsky",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Reference implementation of app.bsky App View (Bluesky API)",
|
|
6
6
|
"keywords": [
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"@isaacs/ttlcache": "^1.4.1",
|
|
21
21
|
"compression": "^1.7.4",
|
|
22
22
|
"cors": "^2.8.5",
|
|
23
|
-
"dotenv": "^16.0.0",
|
|
24
23
|
"express": "^4.17.2",
|
|
25
24
|
"express-async-errors": "^3.1.1",
|
|
26
25
|
"form-data": "^4.0.0",
|
|
@@ -36,14 +35,14 @@
|
|
|
36
35
|
"sharp": "^0.31.2",
|
|
37
36
|
"typed-emitter": "^2.1.0",
|
|
38
37
|
"uint8arrays": "3.0.0",
|
|
39
|
-
"@atproto/api": "^0.6.
|
|
40
|
-
"@atproto/common": "^0.3.
|
|
38
|
+
"@atproto/api": "^0.6.21",
|
|
39
|
+
"@atproto/common": "^0.3.2",
|
|
41
40
|
"@atproto/crypto": "^0.2.2",
|
|
42
|
-
"@atproto/syntax": "^0.1.
|
|
43
|
-
"@atproto/identity": "^0.
|
|
44
|
-
"@atproto/lexicon": "^0.2.
|
|
45
|
-
"@atproto/repo": "^0.3.
|
|
46
|
-
"@atproto/xrpc-server": "^0.3.
|
|
41
|
+
"@atproto/syntax": "^0.1.3",
|
|
42
|
+
"@atproto/identity": "^0.3.0",
|
|
43
|
+
"@atproto/lexicon": "^0.2.3",
|
|
44
|
+
"@atproto/repo": "^0.3.3",
|
|
45
|
+
"@atproto/xrpc-server": "^0.3.3"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"@did-plc/server": "^0.0.1",
|
|
@@ -54,11 +53,11 @@
|
|
|
54
53
|
"@types/qs": "^6.9.7",
|
|
55
54
|
"@types/sharp": "^0.31.0",
|
|
56
55
|
"axios": "^0.27.2",
|
|
57
|
-
"@atproto/api": "^0.6.
|
|
58
|
-
"@atproto/dev-env": "^0.2.
|
|
59
|
-
"@atproto/lex-cli": "^0.2.
|
|
60
|
-
"@atproto/pds": "^0.
|
|
61
|
-
"@atproto/xrpc": "^0.3.
|
|
56
|
+
"@atproto/api": "^0.6.21",
|
|
57
|
+
"@atproto/dev-env": "^0.2.12",
|
|
58
|
+
"@atproto/lex-cli": "^0.2.3",
|
|
59
|
+
"@atproto/pds": "^0.3.0",
|
|
60
|
+
"@atproto/xrpc": "^0.3.3"
|
|
62
61
|
},
|
|
63
62
|
"scripts": {
|
|
64
63
|
"codegen": "lex gen-server ./src/lexicon ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
|
|
@@ -2,7 +2,7 @@ import { sql } from 'kysely'
|
|
|
2
2
|
import AppContext from '../../../../context'
|
|
3
3
|
import { Server } from '../../../../lexicon'
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
cleanQuery,
|
|
6
6
|
getUserSearchQuery,
|
|
7
7
|
SearchKeyset,
|
|
8
8
|
} from '../../../../services/util/search'
|
|
@@ -11,37 +11,51 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
11
11
|
server.app.bsky.actor.searchActors({
|
|
12
12
|
auth: ctx.authOptionalVerifier,
|
|
13
13
|
handler: async ({ auth, params }) => {
|
|
14
|
-
|
|
14
|
+
const { cursor, limit } = params
|
|
15
15
|
const requester = auth.credentials.did
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (rawQ) {
|
|
19
|
-
rawTerm = rawQ
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const term = cleanTerm(rawTerm || '')
|
|
23
|
-
|
|
16
|
+
const rawQuery = params.q ?? params.term
|
|
17
|
+
const query = cleanQuery(rawQuery || '')
|
|
24
18
|
const db = ctx.db.getReplica('search')
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
let results: string[]
|
|
21
|
+
let resCursor: string | undefined
|
|
22
|
+
if (ctx.searchAgent) {
|
|
23
|
+
const res =
|
|
24
|
+
await ctx.searchAgent.api.app.bsky.unspecced.searchActorsSkeleton({
|
|
25
|
+
q: query,
|
|
26
|
+
cursor,
|
|
27
|
+
limit,
|
|
28
|
+
})
|
|
29
|
+
results = res.data.actors.map((a) => a.did)
|
|
30
|
+
resCursor = res.data.cursor
|
|
31
|
+
} else {
|
|
32
|
+
const res = query
|
|
33
|
+
? await getUserSearchQuery(db, { query, limit, cursor })
|
|
34
|
+
.select('distance')
|
|
35
|
+
.selectAll('actor')
|
|
36
|
+
.execute()
|
|
37
|
+
: []
|
|
38
|
+
results = res.map((a) => a.did)
|
|
39
|
+
const keyset = new SearchKeyset(sql``, sql``)
|
|
40
|
+
resCursor = keyset.packFromResult(res)
|
|
41
|
+
}
|
|
33
42
|
|
|
34
43
|
const actors = await ctx.services
|
|
35
44
|
.actor(db)
|
|
36
|
-
.views.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
45
|
+
.views.profiles(results, requester)
|
|
46
|
+
|
|
47
|
+
const SKIP = []
|
|
48
|
+
const filtered = results.flatMap((did) => {
|
|
49
|
+
const actor = actors[did]
|
|
50
|
+
if (!actor) return SKIP
|
|
51
|
+
if (actor.viewer?.blocking || actor.viewer?.blockedBy) return SKIP
|
|
52
|
+
return actor
|
|
53
|
+
})
|
|
40
54
|
|
|
41
55
|
return {
|
|
42
56
|
encoding: 'application/json',
|
|
43
57
|
body: {
|
|
44
|
-
cursor:
|
|
58
|
+
cursor: resCursor,
|
|
45
59
|
actors: filtered,
|
|
46
60
|
},
|
|
47
61
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AppContext from '../../../../context'
|
|
2
2
|
import { Server } from '../../../../lexicon'
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
cleanQuery,
|
|
5
5
|
getUserSearchQuerySimple,
|
|
6
6
|
} from '../../../../services/util/search'
|
|
7
7
|
|
|
@@ -9,31 +9,38 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
9
9
|
server.app.bsky.actor.searchActorsTypeahead({
|
|
10
10
|
auth: ctx.authOptionalVerifier,
|
|
11
11
|
handler: async ({ params, auth }) => {
|
|
12
|
-
|
|
12
|
+
const { limit } = params
|
|
13
13
|
const requester = auth.credentials.did
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (rawQ) {
|
|
17
|
-
rawTerm = rawQ
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const term = cleanTerm(rawTerm || '')
|
|
21
|
-
|
|
14
|
+
const rawQuery = params.q ?? params.term
|
|
15
|
+
const query = cleanQuery(rawQuery || '')
|
|
22
16
|
const db = ctx.db.getReplica('search')
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
let results: string[]
|
|
19
|
+
if (ctx.searchAgent) {
|
|
20
|
+
const res =
|
|
21
|
+
await ctx.searchAgent.api.app.bsky.unspecced.searchActorsSkeleton({
|
|
22
|
+
q: query,
|
|
23
|
+
typeahead: true,
|
|
24
|
+
limit,
|
|
25
|
+
})
|
|
26
|
+
results = res.data.actors.map((a) => a.did)
|
|
27
|
+
} else {
|
|
28
|
+
const res = query
|
|
29
|
+
? await getUserSearchQuerySimple(db, { query, limit })
|
|
30
|
+
.selectAll('actor')
|
|
31
|
+
.execute()
|
|
32
|
+
: []
|
|
33
|
+
results = res.map((a) => a.did)
|
|
34
|
+
}
|
|
29
35
|
|
|
30
36
|
const actors = await ctx.services
|
|
31
37
|
.actor(db)
|
|
32
38
|
.views.profilesBasic(results, requester, { omitLabels: true })
|
|
33
39
|
|
|
34
40
|
const SKIP = []
|
|
35
|
-
const filtered = results.flatMap((
|
|
36
|
-
const actor = actors[
|
|
41
|
+
const filtered = results.flatMap((did) => {
|
|
42
|
+
const actor = actors[did]
|
|
43
|
+
if (!actor) return SKIP
|
|
37
44
|
if (actor.viewer?.blocking || actor.viewer?.blockedBy) return SKIP
|
|
38
45
|
return actor
|
|
39
46
|
})
|
|
@@ -89,8 +89,8 @@ export const skeleton = async (
|
|
|
89
89
|
|
|
90
90
|
if (filter === 'posts_with_media') {
|
|
91
91
|
feedItemsQb = feedItemsQb
|
|
92
|
-
//
|
|
93
|
-
.where('
|
|
92
|
+
// only your own posts
|
|
93
|
+
.where('type', '=', 'post')
|
|
94
94
|
// only posts with media
|
|
95
95
|
.whereExists((qb) =>
|
|
96
96
|
qb
|
|
@@ -37,9 +37,9 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
37
37
|
presentation,
|
|
38
38
|
)
|
|
39
39
|
server.app.bsky.feed.getPostThread({
|
|
40
|
-
auth: ctx.
|
|
40
|
+
auth: ctx.authOptionalAccessOrRoleVerifier,
|
|
41
41
|
handler: async ({ params, auth, res }) => {
|
|
42
|
-
const viewer = auth.credentials.did
|
|
42
|
+
const viewer = 'did' in auth.credentials ? auth.credentials.did : null
|
|
43
43
|
const db = ctx.db.getReplica('thread')
|
|
44
44
|
const feedService = ctx.services.feed(db)
|
|
45
45
|
const actorService = ctx.services.actor(db)
|