@atproto/bsky 0.0.15 → 0.0.17
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 +18 -0
- package/dist/api/com/atproto/moderation/util.d.ts +4 -3
- package/dist/cache/read-through.d.ts +30 -0
- package/dist/config.d.ts +18 -0
- package/dist/context.d.ts +21 -6
- package/dist/daemon/config.d.ts +15 -0
- package/dist/daemon/context.d.ts +15 -0
- package/dist/daemon/index.d.ts +23 -0
- package/dist/daemon/logger.d.ts +3 -0
- package/dist/daemon/notifications.d.ts +18 -0
- package/dist/daemon/services.d.ts +11 -0
- package/dist/db/database-schema.d.ts +1 -2
- package/dist/db/index.js +41 -1
- package/dist/db/index.js.map +3 -3
- package/dist/db/migrations/20231003T202833377Z-create-moderation-subject-status.d.ts +3 -0
- package/dist/db/migrations/20231205T000257238Z-remove-did-cache.d.ts +3 -0
- package/dist/db/migrations/index.d.ts +2 -0
- package/dist/db/pagination.d.ts +2 -1
- package/dist/db/{periodic-moderation-action-reversal.d.ts → periodic-moderation-event-reversal.d.ts} +3 -5
- package/dist/db/tables/moderation.d.ts +24 -34
- package/dist/did-cache.d.ts +10 -7
- package/dist/feed-gen/types.d.ts +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +4370 -2758
- package/dist/index.js.map +3 -3
- package/dist/indexer/context.d.ts +2 -0
- package/dist/indexer/index.d.ts +1 -0
- package/dist/lexicon/index.d.ts +23 -18
- package/dist/lexicon/lexicons.d.ts +561 -412
- package/dist/lexicon/types/app/bsky/feed/defs.d.ts +1 -7
- package/dist/lexicon/types/app/bsky/graph/defs.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/admin/defs.d.ts +114 -48
- package/dist/lexicon/types/com/atproto/admin/{resolveModerationReports.d.ts → deleteAccount.d.ts} +2 -13
- package/dist/lexicon/types/com/atproto/admin/{takeModerationAction.d.ts → emitModerationEvent.d.ts} +5 -6
- package/dist/lexicon/types/com/atproto/admin/{getModerationAction.d.ts → getModerationEvent.d.ts} +1 -1
- package/dist/lexicon/types/com/atproto/admin/{getModerationActions.d.ts → queryModerationEvents.d.ts} +5 -1
- package/dist/lexicon/types/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +12 -6
- package/dist/lexicon/types/com/atproto/admin/sendEmail.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/{admin/getModerationReport.d.ts → temp/importRepo.d.ts} +10 -7
- package/dist/lexicon/types/com/atproto/temp/pushBlob.d.ts +25 -0
- package/dist/lexicon/types/com/atproto/{admin/reverseModerationAction.d.ts → temp/transferAccount.d.ts} +11 -5
- package/dist/logger.d.ts +1 -0
- package/dist/migrate-moderation-data.d.ts +1 -0
- package/dist/redis.d.ts +10 -1
- package/dist/services/actor/index.d.ts +18 -4
- package/dist/services/actor/views.d.ts +6 -8
- package/dist/services/feed/index.d.ts +7 -4
- package/dist/services/feed/util.d.ts +9 -1
- package/dist/services/feed/views.d.ts +11 -21
- package/dist/services/graph/index.d.ts +5 -29
- package/dist/services/graph/types.d.ts +1 -0
- package/dist/services/index.d.ts +3 -7
- package/dist/services/label/index.d.ts +10 -4
- package/dist/services/moderation/index.d.ts +134 -72
- package/dist/services/moderation/pagination.d.ts +36 -0
- package/dist/services/moderation/status.d.ts +13 -0
- package/dist/services/moderation/types.d.ts +35 -0
- package/dist/services/moderation/views.d.ts +18 -14
- package/dist/services/types.d.ts +3 -0
- package/dist/services/util/notification.d.ts +5 -0
- package/dist/services/util/post.d.ts +6 -6
- package/dist/util/debug.d.ts +1 -1
- package/dist/util/retry.d.ts +1 -6
- package/package.json +11 -11
- package/src/api/app/bsky/feed/getActorFeeds.ts +2 -1
- package/src/api/app/bsky/feed/getActorLikes.ts +1 -3
- package/src/api/app/bsky/feed/getAuthorFeed.ts +1 -3
- package/src/api/app/bsky/feed/getFeed.ts +9 -9
- package/src/api/app/bsky/feed/getFeedGenerator.ts +3 -0
- package/src/api/app/bsky/feed/getFeedGenerators.ts +2 -1
- package/src/api/app/bsky/feed/getListFeed.ts +1 -3
- package/src/api/app/bsky/feed/getPostThread.ts +15 -54
- package/src/api/app/bsky/feed/getPosts.ts +21 -18
- package/src/api/app/bsky/feed/getSuggestedFeeds.ts +2 -1
- package/src/api/app/bsky/feed/getTimeline.ts +1 -3
- package/src/api/app/bsky/feed/searchPosts.ts +20 -17
- package/src/api/app/bsky/graph/getList.ts +6 -3
- package/src/api/app/bsky/graph/getListBlocks.ts +3 -2
- package/src/api/app/bsky/graph/getListMutes.ts +2 -1
- package/src/api/app/bsky/graph/getLists.ts +2 -1
- package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +3 -1
- package/src/api/blob-resolver.ts +6 -11
- package/src/api/com/atproto/admin/emitModerationEvent.ts +220 -0
- package/src/api/com/atproto/admin/{getModerationActions.ts → getModerationEvent.ts} +5 -11
- package/src/api/com/atproto/admin/getRecord.ts +1 -0
- package/src/api/com/atproto/admin/{getModerationReports.ts → queryModerationEvents.ts} +13 -16
- package/src/api/com/atproto/admin/queryModerationStatuses.ts +55 -0
- package/src/api/com/atproto/moderation/createReport.ts +9 -7
- package/src/api/com/atproto/moderation/util.ts +38 -20
- package/src/api/index.ts +8 -14
- package/src/auth.ts +29 -21
- package/src/auto-moderator/index.ts +26 -19
- package/src/cache/read-through.ts +151 -0
- package/src/config.ts +90 -1
- package/src/context.ts +11 -7
- package/src/daemon/config.ts +60 -0
- package/src/daemon/context.ts +27 -0
- package/src/daemon/index.ts +78 -0
- package/src/daemon/logger.ts +6 -0
- package/src/daemon/notifications.ts +54 -0
- package/src/daemon/services.ts +22 -0
- package/src/db/database-schema.ts +0 -2
- package/src/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +123 -0
- package/src/db/migrations/20231205T000257238Z-remove-did-cache.ts +14 -0
- package/src/db/migrations/index.ts +2 -0
- package/src/db/pagination.ts +26 -3
- package/src/db/{periodic-moderation-action-reversal.ts → periodic-moderation-event-reversal.ts} +50 -46
- package/src/db/tables/moderation.ts +35 -52
- package/src/did-cache.ts +33 -56
- package/src/feed-gen/bsky-team.ts +1 -1
- package/src/feed-gen/hot-classic.ts +1 -1
- package/src/feed-gen/index.ts +0 -4
- package/src/feed-gen/mutuals.ts +6 -2
- package/src/feed-gen/types.ts +1 -1
- package/src/index.ts +57 -17
- package/src/indexer/context.ts +5 -0
- package/src/indexer/index.ts +10 -7
- package/src/lexicon/index.ts +80 -67
- package/src/lexicon/lexicons.ts +698 -507
- package/src/lexicon/types/app/bsky/feed/defs.ts +1 -18
- package/src/lexicon/types/app/bsky/graph/defs.ts +1 -0
- package/src/lexicon/types/com/atproto/admin/defs.ts +276 -84
- package/src/lexicon/types/com/atproto/admin/{resolveModerationReports.ts → deleteAccount.ts} +2 -13
- package/src/lexicon/types/com/atproto/admin/{takeModerationAction.ts → emitModerationEvent.ts} +13 -11
- package/src/lexicon/types/com/atproto/admin/{getModerationReport.ts → getModerationEvent.ts} +1 -1
- package/src/lexicon/types/com/atproto/admin/{getModerationActions.ts → queryModerationEvents.ts} +8 -1
- package/src/lexicon/types/com/atproto/admin/{getModerationReports.ts → queryModerationStatuses.ts} +21 -14
- package/src/lexicon/types/com/atproto/admin/sendEmail.ts +1 -0
- package/src/lexicon/types/com/atproto/{admin/getModerationAction.ts → temp/importRepo.ts} +11 -7
- package/src/lexicon/types/com/atproto/temp/pushBlob.ts +39 -0
- package/src/lexicon/types/com/atproto/{admin/reverseModerationAction.ts → temp/transferAccount.ts} +18 -5
- package/src/logger.ts +2 -0
- package/src/migrate-moderation-data.ts +414 -0
- package/src/redis.ts +43 -3
- package/src/services/actor/index.ts +55 -7
- package/src/services/actor/views.ts +18 -21
- package/src/services/feed/index.ts +52 -19
- package/src/services/feed/util.ts +47 -19
- package/src/services/feed/views.ts +87 -13
- package/src/services/graph/index.ts +21 -3
- package/src/services/graph/types.ts +1 -0
- package/src/services/index.ts +14 -14
- package/src/services/indexing/index.ts +7 -10
- package/src/services/indexing/plugins/block.ts +2 -3
- package/src/services/indexing/plugins/feed-generator.ts +2 -3
- package/src/services/indexing/plugins/follow.ts +2 -3
- package/src/services/indexing/plugins/like.ts +2 -3
- package/src/services/indexing/plugins/list-block.ts +2 -3
- package/src/services/indexing/plugins/list-item.ts +2 -3
- package/src/services/indexing/plugins/list.ts +2 -3
- package/src/services/indexing/plugins/post.ts +16 -4
- package/src/services/indexing/plugins/repost.ts +2 -3
- package/src/services/indexing/plugins/thread-gate.ts +2 -3
- package/src/services/label/index.ts +68 -25
- package/src/services/moderation/index.ts +380 -395
- package/src/services/moderation/pagination.ts +96 -0
- package/src/services/moderation/status.ts +241 -0
- package/src/services/moderation/types.ts +49 -0
- package/src/services/moderation/views.ts +278 -329
- package/src/services/types.ts +4 -0
- package/src/services/util/notification.ts +70 -0
- package/src/util/debug.ts +2 -2
- package/src/util/retry.ts +1 -44
- package/tests/__snapshots__/feed-generation.test.ts.snap +322 -6
- package/tests/__snapshots__/indexing.test.ts.snap +0 -6
- package/tests/admin/__snapshots__/get-record.test.ts.snap +30 -132
- package/tests/admin/__snapshots__/get-repo.test.ts.snap +14 -60
- package/tests/admin/__snapshots__/moderation-events.test.ts.snap +146 -0
- package/tests/admin/__snapshots__/moderation-statuses.test.ts.snap +64 -0
- package/tests/admin/__snapshots__/moderation.test.ts.snap +0 -125
- package/tests/admin/get-record.test.ts +5 -9
- package/tests/admin/get-repo.test.ts +10 -12
- package/tests/admin/moderation-events.test.ts +221 -0
- package/tests/admin/moderation-statuses.test.ts +145 -0
- package/tests/admin/moderation.test.ts +512 -860
- package/tests/admin/repo-search.test.ts +3 -3
- package/tests/algos/hot-classic.test.ts +1 -2
- package/tests/auth.test.ts +1 -1
- package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -1
- package/tests/auto-moderator/labeler.test.ts +19 -20
- package/tests/auto-moderator/takedowns.test.ts +61 -28
- package/tests/blob-resolver.test.ts +4 -2
- package/tests/daemon.test.ts +191 -0
- package/tests/did-cache.test.ts +20 -5
- package/tests/feed-generation.test.ts +57 -9
- package/tests/handle-invalidation.test.ts +1 -5
- package/tests/indexing.test.ts +20 -13
- package/tests/redis-cache.test.ts +231 -0
- package/tests/seeds/basic.ts +3 -0
- package/tests/subscription/repo.test.ts +4 -7
- package/tests/views/__snapshots__/block-lists.test.ts.snap +3 -9
- package/tests/views/__snapshots__/blocks.test.ts.snap +0 -9
- package/tests/views/__snapshots__/mute-lists.test.ts.snap +5 -5
- package/tests/views/__snapshots__/mutes.test.ts.snap +0 -3
- package/tests/views/__snapshots__/thread.test.ts.snap +0 -30
- package/tests/views/actor-search.test.ts +2 -3
- package/tests/views/author-feed.test.ts +42 -36
- package/tests/views/follows.test.ts +40 -35
- package/tests/views/list-feed.test.ts +17 -9
- package/tests/views/notifications.test.ts +13 -9
- package/tests/views/profile.test.ts +20 -19
- package/tests/views/thread.test.ts +117 -94
- package/tests/views/threadgating.test.ts +89 -19
- package/tests/views/timeline.test.ts +21 -13
- package/dist/api/com/atproto/admin/resolveModerationReports.d.ts +0 -3
- package/dist/api/com/atproto/admin/reverseModerationAction.d.ts +0 -3
- package/dist/api/com/atproto/admin/takeModerationAction.d.ts +0 -3
- package/dist/db/tables/did-cache.d.ts +0 -10
- package/dist/feed-gen/best-of-follows.d.ts +0 -29
- package/dist/feed-gen/whats-hot.d.ts +0 -29
- package/dist/feed-gen/with-friends.d.ts +0 -3
- package/dist/label-cache.d.ts +0 -19
- package/src/api/com/atproto/admin/getModerationAction.ts +0 -44
- package/src/api/com/atproto/admin/getModerationReport.ts +0 -43
- package/src/api/com/atproto/admin/resolveModerationReports.ts +0 -24
- package/src/api/com/atproto/admin/reverseModerationAction.ts +0 -115
- package/src/api/com/atproto/admin/takeModerationAction.ts +0 -156
- package/src/db/tables/did-cache.ts +0 -13
- package/src/feed-gen/best-of-follows.ts +0 -74
- package/src/feed-gen/whats-hot.ts +0 -101
- package/src/feed-gen/with-friends.ts +0 -39
- package/src/label-cache.ts +0 -90
- package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +0 -172
- package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +0 -178
- package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +0 -177
- package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +0 -307
- package/tests/admin/get-moderation-action.test.ts +0 -100
- package/tests/admin/get-moderation-actions.test.ts +0 -164
- package/tests/admin/get-moderation-report.test.ts +0 -100
- package/tests/admin/get-moderation-reports.test.ts +0 -332
- package/tests/algos/whats-hot.test.ts +0 -118
- package/tests/algos/with-friends.test.ts +0 -145
- /package/dist/api/com/atproto/admin/{getModerationAction.d.ts → emitModerationEvent.d.ts} +0 -0
- /package/dist/api/com/atproto/admin/{getModerationActions.d.ts → getModerationEvent.d.ts} +0 -0
- /package/dist/api/com/atproto/admin/{getModerationReport.d.ts → queryModerationEvents.d.ts} +0 -0
- /package/dist/api/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +0 -0
|
@@ -7,26 +7,27 @@ import { ViewBlocked, ViewNotFound, ViewRecord } from '../../lexicon/types/app/b
|
|
|
7
7
|
import { PostEmbedViews, FeedGenInfo, FeedRow, MaybePostView, PostInfoMap, RecordEmbedViewRecord, PostBlocksMap, FeedHydrationState, ThreadgateInfoMap, ThreadgateInfo } from './types';
|
|
8
8
|
import { Labels } from '../label';
|
|
9
9
|
import { ImageUriBuilder } from '../../image/uri';
|
|
10
|
-
import { LabelCache } from '../../label-cache';
|
|
11
10
|
import { ActorInfoMap, ActorService } from '../actor';
|
|
12
11
|
import { ListInfoMap, GraphService } from '../graph';
|
|
12
|
+
import { FromDb } from '../types';
|
|
13
13
|
export declare class FeedViews {
|
|
14
14
|
db: Database;
|
|
15
15
|
imgUriBuilder: ImageUriBuilder;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
static creator(imgUriBuilder: ImageUriBuilder, labelCache: LabelCache): (db: Database) => FeedViews;
|
|
16
|
+
private actor;
|
|
17
|
+
private graph;
|
|
19
18
|
services: {
|
|
20
19
|
actor: ActorService;
|
|
21
20
|
graph: GraphService;
|
|
22
21
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
constructor(db: Database, imgUriBuilder: ImageUriBuilder, actor: FromDb<ActorService>, graph: FromDb<GraphService>);
|
|
23
|
+
static creator(imgUriBuilder: ImageUriBuilder, actor: FromDb<ActorService>, graph: FromDb<GraphService>): (db: Database) => FeedViews;
|
|
24
|
+
formatFeedGeneratorView(info: FeedGenInfo, profiles: ActorInfoMap): GeneratorView | undefined;
|
|
25
|
+
formatFeed(items: FeedRow[], state: FeedHydrationState, viewer: string | null, opts?: {
|
|
26
26
|
usePostViewUnion?: boolean;
|
|
27
27
|
}): FeedViewPost[];
|
|
28
|
-
formatPostView(uri: string, actors: ActorInfoMap, posts: PostInfoMap, threadgates: ThreadgateInfoMap, embeds: PostEmbedViews, labels: Labels, lists: ListInfoMap): PostView | undefined;
|
|
29
|
-
|
|
28
|
+
formatPostView(uri: string, actors: ActorInfoMap, posts: PostInfoMap, threadgates: ThreadgateInfoMap, embeds: PostEmbedViews, labels: Labels, lists: ListInfoMap, viewer: string | null): PostView | undefined;
|
|
29
|
+
userReplyDisabled(uri: string, actors: ActorInfoMap, posts: PostInfoMap, threadgates: ThreadgateInfoMap, lists: ListInfoMap, viewer: string | null): boolean | undefined;
|
|
30
|
+
formatMaybePostView(uri: string, actors: ActorInfoMap, posts: PostInfoMap, threadgates: ThreadgateInfoMap, embeds: PostEmbedViews, labels: Labels, lists: ListInfoMap, blocks: PostBlocksMap, viewer: string | null, opts?: {
|
|
30
31
|
usePostViewUnion?: boolean;
|
|
31
32
|
}): MaybePostView | undefined;
|
|
32
33
|
blockedPost(post: PostView): {
|
|
@@ -78,17 +79,6 @@ export declare class FeedViews {
|
|
|
78
79
|
uri: string;
|
|
79
80
|
cid: string;
|
|
80
81
|
record: import("../../lexicon/types/app/bsky/feed/threadgate").Record;
|
|
81
|
-
lists:
|
|
82
|
-
uri: string;
|
|
83
|
-
cid: string;
|
|
84
|
-
name: string;
|
|
85
|
-
purpose: string;
|
|
86
|
-
avatar: string | undefined;
|
|
87
|
-
indexedAt: string;
|
|
88
|
-
viewer: {
|
|
89
|
-
muted: boolean;
|
|
90
|
-
blocked: string | undefined;
|
|
91
|
-
};
|
|
92
|
-
}[];
|
|
82
|
+
lists: import("../../lexicon/types/app/bsky/graph/defs").ListViewBasic[];
|
|
93
83
|
};
|
|
94
84
|
}
|
|
@@ -2,6 +2,7 @@ import { Database } from '../../db';
|
|
|
2
2
|
import { ImageUriBuilder } from '../../image/uri';
|
|
3
3
|
import { ListInfo } from './types';
|
|
4
4
|
import { ActorInfoMap } from '../actor';
|
|
5
|
+
import { ListView, ListViewBasic } from '../../lexicon/types/app/bsky/graph/defs';
|
|
5
6
|
export * from './types';
|
|
6
7
|
export declare class GraphService {
|
|
7
8
|
db: Database;
|
|
@@ -43,43 +44,18 @@ export declare class GraphService {
|
|
|
43
44
|
handle: string | null;
|
|
44
45
|
indexedAt: string;
|
|
45
46
|
takedownId: number | null;
|
|
46
|
-
} & import("kysely").Selection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list">, "list" | "actor", "list.sortAt as sortAt">, import("kysely").AliasedQueryBuilder<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list_mute">, "list_mute", import("kysely").Selection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list_mute">, "list_mute", "list_mute.listUri">, "viewerMuted"> | import("kysely").AliasedQueryBuilder<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list_block">, "list_block", import("kysely").Selection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list_block">, "list_block", "list_block.uri">, "viewerListBlockUri">>;
|
|
47
|
+
} & import("kysely").Selection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list">, "list" | "actor", "list.sortAt as sortAt">, import("kysely").AliasedQueryBuilder<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list_mute">, "list_mute", import("kysely").Selection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list_mute">, "list_mute", "list_mute.listUri">, "viewerMuted"> | import("kysely").AliasedQueryBuilder<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list_block">, "list_block", import("kysely").Selection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list_block">, "list_block", "list_block.uri">, "viewerListBlockUri"> | import("kysely").AliasedQueryBuilder<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list_item">, "list_item", import("kysely").Selection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list_item">, "list_item", "list_item.uri">, "viewerInList">>;
|
|
47
48
|
getListItemsQb(): import("kysely/dist/cjs/parser/select-parser").QueryBuilderWithSelection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "list_item"> & Record<"subject", import("../../db/tables/actor").Actor>, "list_item" | "subject", {
|
|
48
49
|
did: string;
|
|
49
50
|
handle: string | null;
|
|
50
51
|
indexedAt: string;
|
|
51
52
|
takedownId: number | null;
|
|
52
|
-
}, "list_item.cid as cid" | "list_item.sortAt as sortAt">;
|
|
53
|
+
}, "list_item.uri as uri" | "list_item.cid as cid" | "list_item.sortAt as sortAt">;
|
|
53
54
|
getBlockAndMuteState(pairs: RelationshipPair[], bam?: BlockAndMuteState): Promise<BlockAndMuteState>;
|
|
54
55
|
getBlockState(pairs: RelationshipPair[], bam?: BlockAndMuteState): Promise<BlockAndMuteState>;
|
|
55
56
|
getListViews(listUris: string[], requester: string | null): Promise<{}>;
|
|
56
|
-
formatListView(list: ListInfo, profiles: ActorInfoMap):
|
|
57
|
-
|
|
58
|
-
description: string | undefined;
|
|
59
|
-
descriptionFacets: any;
|
|
60
|
-
uri: string;
|
|
61
|
-
cid: string;
|
|
62
|
-
name: string;
|
|
63
|
-
purpose: string;
|
|
64
|
-
avatar: string | undefined;
|
|
65
|
-
indexedAt: string;
|
|
66
|
-
viewer: {
|
|
67
|
-
muted: boolean;
|
|
68
|
-
blocked: string | undefined;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
formatListViewBasic(list: ListInfo): {
|
|
72
|
-
uri: string;
|
|
73
|
-
cid: string;
|
|
74
|
-
name: string;
|
|
75
|
-
purpose: string;
|
|
76
|
-
avatar: string | undefined;
|
|
77
|
-
indexedAt: string;
|
|
78
|
-
viewer: {
|
|
79
|
-
muted: boolean;
|
|
80
|
-
blocked: string | undefined;
|
|
81
|
-
};
|
|
82
|
-
};
|
|
57
|
+
formatListView(list: ListInfo, profiles: ActorInfoMap): ListView | undefined;
|
|
58
|
+
formatListViewBasic(list: ListInfo): ListViewBasic;
|
|
83
59
|
}
|
|
84
60
|
export declare type RelationshipPair = [didA: string, didB: string];
|
|
85
61
|
export declare class BlockAndMuteState {
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { Database, PrimaryDatabase } from '../db';
|
|
2
1
|
import { ImageUriBuilder } from '../image/uri';
|
|
3
2
|
import { ActorService } from './actor';
|
|
4
3
|
import { FeedService } from './feed';
|
|
5
4
|
import { GraphService } from './graph';
|
|
6
5
|
import { ModerationService } from './moderation';
|
|
7
|
-
import { LabelService } from './label';
|
|
6
|
+
import { LabelCacheOpts, LabelService } from './label';
|
|
8
7
|
import { ImageInvalidator } from '../image/invalidator';
|
|
9
|
-
import {
|
|
8
|
+
import { FromDb, FromDbPrimary } from './types';
|
|
10
9
|
export declare function createServices(resources: {
|
|
11
10
|
imgUriBuilder: ImageUriBuilder;
|
|
12
11
|
imgInvalidator: ImageInvalidator;
|
|
13
|
-
|
|
12
|
+
labelCacheOpts: LabelCacheOpts;
|
|
14
13
|
}): Services;
|
|
15
14
|
export declare type Services = {
|
|
16
15
|
actor: FromDb<ActorService>;
|
|
@@ -19,6 +18,3 @@ export declare type Services = {
|
|
|
19
18
|
moderation: FromDbPrimary<ModerationService>;
|
|
20
19
|
label: FromDb<LabelService>;
|
|
21
20
|
};
|
|
22
|
-
declare type FromDb<T> = (db: Database) => T;
|
|
23
|
-
declare type FromDbPrimary<T> = (db: PrimaryDatabase) => T;
|
|
24
|
-
export {};
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { Database } from '../../db';
|
|
2
2
|
import { Label } from '../../lexicon/types/com/atproto/label/defs';
|
|
3
|
-
import {
|
|
3
|
+
import { ReadThroughCache } from '../../cache/read-through';
|
|
4
|
+
import { Redis } from '../../redis';
|
|
4
5
|
export declare type Labels = Record<string, Label[]>;
|
|
6
|
+
export declare type LabelCacheOpts = {
|
|
7
|
+
redis: Redis;
|
|
8
|
+
staleTTL: number;
|
|
9
|
+
maxTTL: number;
|
|
10
|
+
};
|
|
5
11
|
export declare class LabelService {
|
|
6
12
|
db: Database;
|
|
7
|
-
cache:
|
|
8
|
-
constructor(db: Database,
|
|
9
|
-
static creator(
|
|
13
|
+
cache: ReadThroughCache<Label[]> | null;
|
|
14
|
+
constructor(db: Database, cacheOpts: LabelCacheOpts | null);
|
|
15
|
+
static creator(cacheOpts: LabelCacheOpts | null): (db: Database) => LabelService;
|
|
10
16
|
formatAndCreate(src: string, uri: string, cid: string | null, labels: {
|
|
11
17
|
create?: string[];
|
|
12
18
|
negate?: string[];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Selectable } from 'kysely';
|
|
2
1
|
import { CID } from 'multiformats/cid';
|
|
3
2
|
import { AtUri } from '@atproto/syntax';
|
|
4
3
|
import { PrimaryDatabase } from '../../db';
|
|
5
|
-
import { ModerationAction, ModerationReport } from '../../db/tables/moderation';
|
|
6
4
|
import { ModerationViews } from './views';
|
|
7
5
|
import { ImageUriBuilder } from '../../image/uri';
|
|
6
|
+
import { Main as StrongRef } from '../../lexicon/types/com/atproto/repo/strongRef';
|
|
8
7
|
import { ImageInvalidator } from '../../image/invalidator';
|
|
9
8
|
import { RepoRef, RepoBlobRef } from '../../lexicon/types/com/atproto/admin/defs';
|
|
10
|
-
import {
|
|
9
|
+
import { ModEventType, ModerationEventRow, ModerationEventRowWithHandle, ModerationSubjectStatusRow, ReversibleModerationEvent, SubjectInfo } from './types';
|
|
10
|
+
import { ModerationEvent } from '../../db/tables/moderation';
|
|
11
11
|
export declare class ModerationService {
|
|
12
12
|
db: PrimaryDatabase;
|
|
13
13
|
imgUriBuilder: ImageUriBuilder;
|
|
@@ -15,52 +15,52 @@ export declare class ModerationService {
|
|
|
15
15
|
constructor(db: PrimaryDatabase, imgUriBuilder: ImageUriBuilder, imgInvalidator: ImageInvalidator);
|
|
16
16
|
static creator(imgUriBuilder: ImageUriBuilder, imgInvalidator: ImageInvalidator): (db: PrimaryDatabase) => ModerationService;
|
|
17
17
|
views: ModerationViews;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
getEvent(id: number): Promise<ModerationEventRow | undefined>;
|
|
19
|
+
getEventOrThrow(id: number): Promise<ModerationEventRow>;
|
|
20
|
+
getEvents(opts: {
|
|
21
21
|
subject?: string;
|
|
22
|
+
createdBy?: string;
|
|
22
23
|
limit: number;
|
|
23
24
|
cursor?: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
resolved?: boolean;
|
|
29
|
-
actionType?: string;
|
|
30
|
-
limit: number;
|
|
25
|
+
includeAllUserRecords: boolean;
|
|
26
|
+
types: ModerationEvent['action'][];
|
|
27
|
+
sortDirection?: 'asc' | 'desc';
|
|
28
|
+
}): Promise<{
|
|
31
29
|
cursor?: string;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}): Promise<ModerationReportRowWithHandle[]>;
|
|
37
|
-
getReportOrThrow(id: number): Promise<ModerationReportRow>;
|
|
38
|
-
getCurrentActions(subject: {
|
|
30
|
+
events: ModerationEventRowWithHandle[];
|
|
31
|
+
}>;
|
|
32
|
+
getReport(id: number): Promise<ModerationEventRow | undefined>;
|
|
33
|
+
getCurrentStatus(subject: {
|
|
39
34
|
did: string;
|
|
40
35
|
} | {
|
|
41
36
|
uri: AtUri;
|
|
42
37
|
} | {
|
|
43
38
|
cids: CID[];
|
|
44
39
|
}): Promise<{
|
|
40
|
+
did: string;
|
|
45
41
|
id: number;
|
|
46
|
-
action: "com.atproto.admin.defs#takedown" | "com.atproto.admin.defs#flag" | "com.atproto.admin.defs#acknowledge" | "com.atproto.admin.defs#escalate";
|
|
47
|
-
reason: string;
|
|
48
|
-
createdBy: string;
|
|
49
42
|
createdAt: string;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
+
recordCid: string | null;
|
|
54
|
+
recordPath: string;
|
|
61
55
|
}[]>;
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
buildSubjectInfo(subject: {
|
|
57
|
+
did: string;
|
|
58
|
+
} | {
|
|
59
|
+
uri: AtUri;
|
|
60
|
+
cid: CID;
|
|
61
|
+
}, subjectBlobCids?: CID[]): SubjectInfo;
|
|
62
|
+
logEvent(info: {
|
|
63
|
+
event: ModEventType;
|
|
64
64
|
subject: {
|
|
65
65
|
did: string;
|
|
66
66
|
} | {
|
|
@@ -68,19 +68,31 @@ export declare class ModerationService {
|
|
|
68
68
|
cid: CID;
|
|
69
69
|
};
|
|
70
70
|
subjectBlobCids?: CID[];
|
|
71
|
-
reason: string;
|
|
72
|
-
createLabelVals?: string[];
|
|
73
|
-
negateLabelVals?: string[];
|
|
74
71
|
createdBy: string;
|
|
75
72
|
createdAt?: Date;
|
|
76
|
-
|
|
77
|
-
}): Promise<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
}): Promise<ModerationEventRow>;
|
|
74
|
+
getLastReversibleEventForSubject({ did, muteUntil, recordPath, suspendUntil, }: ModerationSubjectStatusRow): Promise<{
|
|
75
|
+
id: number;
|
|
76
|
+
createdBy: string;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
comment: string | null;
|
|
79
|
+
createLabelVals: string | null;
|
|
80
|
+
negateLabelVals: string | null;
|
|
81
|
+
durationInHours: number | null;
|
|
82
|
+
action: "com.atproto.admin.defs#modEventTakedown" | "com.atproto.admin.defs#modEventReverseTakedown" | "com.atproto.admin.defs#modEventComment" | "com.atproto.admin.defs#modEventReport" | "com.atproto.admin.defs#modEventLabel" | "com.atproto.admin.defs#modEventAcknowledge" | "com.atproto.admin.defs#modEventEscalate" | "com.atproto.admin.defs#modEventMute" | "com.atproto.admin.defs#modEventEmail";
|
|
83
|
+
subjectCid: string | null;
|
|
84
|
+
subjectDid: string;
|
|
85
|
+
subjectType: "com.atproto.repo.strongRef" | "com.atproto.admin.defs#repoRef";
|
|
86
|
+
subjectUri: string | null;
|
|
87
|
+
expiresAt: string | null;
|
|
88
|
+
meta: Record<string, string | boolean> | null;
|
|
89
|
+
legacyRefId: number | null;
|
|
90
|
+
} | null | undefined>;
|
|
91
|
+
getSubjectsDueForReversal(): Promise<ModerationSubjectStatusRow[]>;
|
|
92
|
+
revertState({ createdBy, createdAt, comment, action, subject, }: ReversibleModerationEvent): Promise<{
|
|
93
|
+
result: ModerationEventRow;
|
|
81
94
|
restored?: TakedownSubjects;
|
|
82
95
|
}>;
|
|
83
|
-
logReverseAction(info: ReversibleModerationAction): Promise<ModerationActionRow>;
|
|
84
96
|
takedownRepo(info: {
|
|
85
97
|
takedownId: number;
|
|
86
98
|
did: string;
|
|
@@ -97,14 +109,8 @@ export declare class ModerationService {
|
|
|
97
109
|
reverseTakedownRecord(info: {
|
|
98
110
|
uri: AtUri;
|
|
99
111
|
}): Promise<void>;
|
|
100
|
-
resolveReports(info: {
|
|
101
|
-
reportIds: number[];
|
|
102
|
-
actionId: number;
|
|
103
|
-
createdBy: string;
|
|
104
|
-
createdAt?: Date;
|
|
105
|
-
}): Promise<void>;
|
|
106
112
|
report(info: {
|
|
107
|
-
reasonType:
|
|
113
|
+
reasonType: NonNullable<ModerationEventRow['meta']>['reportType'];
|
|
108
114
|
reason?: string;
|
|
109
115
|
subject: {
|
|
110
116
|
did: string;
|
|
@@ -114,28 +120,84 @@ export declare class ModerationService {
|
|
|
114
120
|
};
|
|
115
121
|
reportedBy: string;
|
|
116
122
|
createdAt?: Date;
|
|
117
|
-
}): Promise<
|
|
123
|
+
}): Promise<ModerationEventRow>;
|
|
124
|
+
getSubjectStatuses({ cursor, limit, takendown, reviewState, reviewedAfter, reviewedBefore, reportedAfter, reportedBefore, includeMuted, ignoreSubjects, sortDirection, lastReviewedBy, sortField, subject, }: {
|
|
125
|
+
cursor?: string;
|
|
126
|
+
limit?: number;
|
|
127
|
+
takendown?: boolean;
|
|
128
|
+
reviewedBefore?: string;
|
|
129
|
+
reviewState?: ModerationSubjectStatusRow['reviewState'];
|
|
130
|
+
reviewedAfter?: string;
|
|
131
|
+
reportedAfter?: string;
|
|
132
|
+
reportedBefore?: string;
|
|
133
|
+
includeMuted?: boolean;
|
|
134
|
+
subject?: string;
|
|
135
|
+
ignoreSubjects?: string[];
|
|
136
|
+
sortDirection: 'asc' | 'desc';
|
|
137
|
+
lastReviewedBy?: string;
|
|
138
|
+
sortField: 'lastReviewedAt' | 'lastReportedAt';
|
|
139
|
+
}): Promise<{
|
|
140
|
+
statuses: (import("kysely").Selection<{
|
|
141
|
+
record: import("../../db/tables/record").Record;
|
|
142
|
+
subscription: import("../../db/tables/subscription").Subscription;
|
|
143
|
+
post: import("../../db/tables/post").Post;
|
|
144
|
+
duplicate_record: import("../../db/tables/duplicate-record").DuplicateRecord;
|
|
145
|
+
profile: import("../../db/tables/profile").Profile;
|
|
146
|
+
profile_agg: import("../../db/tables/profile-agg").ProfileAgg;
|
|
147
|
+
post_embed_image: import("../../db/tables/post-embed").PostEmbedImage;
|
|
148
|
+
post_embed_external: import("../../db/tables/post-embed").PostEmbedExternal;
|
|
149
|
+
post_embed_record: import("../../db/tables/post-embed").PostEmbedRecord;
|
|
150
|
+
post_agg: import("../../db/tables/post-agg").PostAgg;
|
|
151
|
+
repost: import("../../db/tables/repost").Repost;
|
|
152
|
+
thread_gate: import("../../db/tables/thread-gate").ThreadGate;
|
|
153
|
+
feed_item: import("../../db/tables/feed-item").FeedItem;
|
|
154
|
+
follow: import("../../db/tables/follow").Follow;
|
|
155
|
+
like: import("../../db/tables/like").Like;
|
|
156
|
+
list: import("../../db/tables/list").List;
|
|
157
|
+
list_item: import("../../db/tables/list-item").ListItem;
|
|
158
|
+
list_mute: import("../../db/tables/list-mute").ListMute;
|
|
159
|
+
list_block: import("../../db/tables/list-block").ListBlock;
|
|
160
|
+
mute: import("../../db/tables/mute").Mute;
|
|
161
|
+
actor_block: import("../../db/tables/actor-block").ActorBlock;
|
|
162
|
+
feed_generator: import("../../db/tables/feed-generator").FeedGenerator;
|
|
163
|
+
actor: import("kysely/dist/cjs/util/type-utils").Nullable<import("../../db/tables/actor").Actor>;
|
|
164
|
+
actor_state: import("../../db/tables/actor-state").ActorState;
|
|
165
|
+
actor_sync: import("../../db/tables/actor-sync").ActorSync;
|
|
166
|
+
notification: import("../../db/tables/notification").Notification;
|
|
167
|
+
notification_push_token: import("../../db/tables/notification-push-token").NotificationPushToken;
|
|
168
|
+
label: import("../../db/tables/label").Label;
|
|
169
|
+
moderation_event: ModerationEvent;
|
|
170
|
+
moderation_subject_status: import("../../db/tables/moderation").ModerationSubjectStatus;
|
|
171
|
+
algo_whats_hot_view: import("../../db/tables/algo").AlgoWhatsHotView;
|
|
172
|
+
view_param: import("../../db/tables/view-param").ViewParam;
|
|
173
|
+
suggested_follow: import("../../db/tables/suggested-follow").SuggestedFollow;
|
|
174
|
+
suggested_feed: import("../../db/tables/suggested-feed").SuggestedFeed;
|
|
175
|
+
}, "actor" | "moderation_subject_status", "actor.handle as handle"> & {
|
|
176
|
+
did: string;
|
|
177
|
+
id: number;
|
|
178
|
+
createdAt: string;
|
|
179
|
+
updatedAt: string;
|
|
180
|
+
reviewState: "com.atproto.admin.defs#reviewOpen" | "com.atproto.admin.defs#reviewEscalated" | "com.atproto.admin.defs#reviewClosed";
|
|
181
|
+
blobCids: string[] | null;
|
|
182
|
+
comment: string | null;
|
|
183
|
+
lastReportedAt: string | null;
|
|
184
|
+
lastReviewedAt: string | null;
|
|
185
|
+
muteUntil: string | null;
|
|
186
|
+
lastReviewedBy: string | null;
|
|
187
|
+
takendown: boolean;
|
|
188
|
+
suspendUntil: string | null;
|
|
189
|
+
recordCid: string | null;
|
|
190
|
+
recordPath: string;
|
|
191
|
+
})[];
|
|
192
|
+
cursor: string | undefined;
|
|
193
|
+
}>;
|
|
194
|
+
isSubjectTakendown(subject: {
|
|
195
|
+
did: string;
|
|
196
|
+
} | {
|
|
197
|
+
uri: AtUri;
|
|
198
|
+
}): Promise<boolean>;
|
|
118
199
|
}
|
|
119
200
|
export declare type TakedownSubjects = {
|
|
120
201
|
did: string;
|
|
121
202
|
subjects: (RepoRef | RepoBlobRef | StrongRef)[];
|
|
122
203
|
};
|
|
123
|
-
export declare type ModerationActionRow = Selectable<ModerationAction>;
|
|
124
|
-
export declare type ReversibleModerationAction = Pick<ModerationActionRow, 'id' | 'createdBy' | 'reason'> & {
|
|
125
|
-
createdAt?: Date;
|
|
126
|
-
};
|
|
127
|
-
export declare type ModerationReportRow = Selectable<ModerationReport>;
|
|
128
|
-
export declare type ModerationReportRowWithHandle = ModerationReportRow & {
|
|
129
|
-
handle?: string | null;
|
|
130
|
-
};
|
|
131
|
-
export declare type SubjectInfo = {
|
|
132
|
-
subjectType: 'com.atproto.admin.defs#repoRef';
|
|
133
|
-
subjectDid: string;
|
|
134
|
-
subjectUri: null;
|
|
135
|
-
subjectCid: null;
|
|
136
|
-
} | {
|
|
137
|
-
subjectType: 'com.atproto.repo.strongRef';
|
|
138
|
-
subjectDid: string;
|
|
139
|
-
subjectUri: string;
|
|
140
|
-
subjectCid: string;
|
|
141
|
-
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Cursor, GenericKeyset } from '../../db/pagination';
|
|
2
|
+
declare type StatusKeysetParam = {
|
|
3
|
+
lastReviewedAt: string | null;
|
|
4
|
+
lastReportedAt: string | null;
|
|
5
|
+
id: number;
|
|
6
|
+
};
|
|
7
|
+
export declare class StatusKeyset extends GenericKeyset<StatusKeysetParam, Cursor> {
|
|
8
|
+
labelResult(result: StatusKeysetParam): Cursor;
|
|
9
|
+
labeledResultToCursor(labeled: Cursor): {
|
|
10
|
+
primary: string;
|
|
11
|
+
secondary: string;
|
|
12
|
+
};
|
|
13
|
+
cursorToLabeledResult(cursor: Cursor): {
|
|
14
|
+
primary: string;
|
|
15
|
+
secondary: string;
|
|
16
|
+
};
|
|
17
|
+
unpackCursor(cursorStr?: string): Cursor | undefined;
|
|
18
|
+
getSql(labeled?: Cursor, direction?: 'asc' | 'desc'): import("kysely").RawBuilder<unknown> | undefined;
|
|
19
|
+
}
|
|
20
|
+
declare type TimeIdKeysetParam = {
|
|
21
|
+
id: number;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
};
|
|
24
|
+
declare type TimeIdResult = TimeIdKeysetParam;
|
|
25
|
+
export declare class TimeIdKeyset extends GenericKeyset<TimeIdKeysetParam, Cursor> {
|
|
26
|
+
labelResult(result: TimeIdResult): Cursor;
|
|
27
|
+
labeledResultToCursor(labeled: Cursor): {
|
|
28
|
+
primary: string;
|
|
29
|
+
secondary: string;
|
|
30
|
+
};
|
|
31
|
+
cursorToLabeledResult(cursor: Cursor): {
|
|
32
|
+
primary: string;
|
|
33
|
+
secondary: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AtUri } from '@atproto/syntax';
|
|
2
|
+
import { PrimaryDatabase } from '../../db';
|
|
3
|
+
import { ModerationSubjectStatus } from '../../db/tables/moderation';
|
|
4
|
+
import { ModerationEventRow } from './types';
|
|
5
|
+
import { CID } from 'multiformats/cid';
|
|
6
|
+
export declare const adjustModerationSubjectStatus: (db: PrimaryDatabase, moderationEvent: ModerationEventRow, blobCids?: CID[]) => Promise<import("kysely").InsertResult | null>;
|
|
7
|
+
declare type ModerationSubjectStatusFilter = Pick<ModerationSubjectStatus, 'did'> | Pick<ModerationSubjectStatus, 'did' | 'recordPath'> | Pick<ModerationSubjectStatus, 'did' | 'recordPath' | 'recordCid'>;
|
|
8
|
+
export declare const getModerationSubjectStatus: (db: PrimaryDatabase, filters: ModerationSubjectStatusFilter) => Promise<{} | undefined>;
|
|
9
|
+
export declare const getStatusIdentifierFromSubject: (subject: string | AtUri) => {
|
|
10
|
+
did: string;
|
|
11
|
+
recordPath: string;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Selectable } from 'kysely';
|
|
2
|
+
import { ModerationEvent, ModerationSubjectStatus } from '../../db/tables/moderation';
|
|
3
|
+
import { AtUri } from '@atproto/syntax';
|
|
4
|
+
import { CID } from 'multiformats/cid';
|
|
5
|
+
import { ComAtprotoAdminDefs } from '@atproto/api';
|
|
6
|
+
export declare type SubjectInfo = {
|
|
7
|
+
subjectType: 'com.atproto.admin.defs#repoRef';
|
|
8
|
+
subjectDid: string;
|
|
9
|
+
subjectUri: null;
|
|
10
|
+
subjectCid: null;
|
|
11
|
+
} | {
|
|
12
|
+
subjectType: 'com.atproto.repo.strongRef';
|
|
13
|
+
subjectDid: string;
|
|
14
|
+
subjectUri: string;
|
|
15
|
+
subjectCid: string;
|
|
16
|
+
};
|
|
17
|
+
export declare type ModerationEventRow = Selectable<ModerationEvent>;
|
|
18
|
+
export declare type ReversibleModerationEvent = Pick<ModerationEventRow, 'createdBy' | 'comment' | 'action'> & {
|
|
19
|
+
createdAt?: Date;
|
|
20
|
+
subject: {
|
|
21
|
+
did: string;
|
|
22
|
+
} | {
|
|
23
|
+
uri: AtUri;
|
|
24
|
+
cid: CID;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare type ModerationEventRowWithHandle = ModerationEventRow & {
|
|
28
|
+
subjectHandle?: string | null;
|
|
29
|
+
creatorHandle?: string | null;
|
|
30
|
+
};
|
|
31
|
+
export declare type ModerationSubjectStatusRow = Selectable<ModerationSubjectStatus>;
|
|
32
|
+
export declare type ModerationSubjectStatusRowWithHandle = ModerationSubjectStatusRow & {
|
|
33
|
+
handle: string | null;
|
|
34
|
+
};
|
|
35
|
+
export declare type ModEventType = ComAtprotoAdminDefs.ModEventTakedown | ComAtprotoAdminDefs.ModEventAcknowledge | ComAtprotoAdminDefs.ModEventEscalate | ComAtprotoAdminDefs.ModEventComment | ComAtprotoAdminDefs.ModEventLabel | ComAtprotoAdminDefs.ModEventReport | ComAtprotoAdminDefs.ModEventMute | ComAtprotoAdminDefs.ModEventReverseTakedown;
|
|
@@ -1,37 +1,41 @@
|
|
|
1
|
-
import { Selectable } from 'kysely';
|
|
2
1
|
import { BlobRef } from '@atproto/lexicon';
|
|
3
2
|
import { Database } from '../../db';
|
|
4
3
|
import { Actor } from '../../db/tables/actor';
|
|
5
4
|
import { Record as RecordRow } from '../../db/tables/record';
|
|
6
|
-
import {
|
|
7
|
-
import { RepoView, RepoViewDetail, RecordView, RecordViewDetail, ActionView, ActionViewDetail, ReportView, ReportViewDetail, BlobView } from '../../lexicon/types/com/atproto/admin/defs';
|
|
5
|
+
import { ModEventView, RepoView, RepoViewDetail, RecordView, RecordViewDetail, ReportViewDetail, BlobView, SubjectStatusView, ModEventViewDetail } from '../../lexicon/types/com/atproto/admin/defs';
|
|
8
6
|
import { OutputSchema as ReportOutput } from '../../lexicon/types/com/atproto/moderation/createReport';
|
|
9
7
|
import { Label } from '../../lexicon/types/com/atproto/label/defs';
|
|
10
|
-
import {
|
|
8
|
+
import { ModerationEventRowWithHandle, ModerationSubjectStatusRowWithHandle } from './types';
|
|
11
9
|
export declare class ModerationViews {
|
|
12
10
|
private db;
|
|
13
11
|
constructor(db: Database);
|
|
14
12
|
repo(result: RepoResult): Promise<RepoView>;
|
|
15
13
|
repo(result: RepoResult[]): Promise<RepoView[]>;
|
|
14
|
+
event(result: EventResult): Promise<ModEventView>;
|
|
15
|
+
event(result: EventResult[]): Promise<ModEventView[]>;
|
|
16
|
+
eventDetail(result: EventResult): Promise<ModEventViewDetail>;
|
|
16
17
|
repoDetail(result: RepoResult): Promise<RepoViewDetail>;
|
|
17
18
|
record(result: RecordResult): Promise<RecordView>;
|
|
18
19
|
record(result: RecordResult[]): Promise<RecordView[]>;
|
|
19
20
|
recordDetail(result: RecordResult): Promise<RecordViewDetail>;
|
|
20
|
-
action(result: ActionResult): Promise<ActionView>;
|
|
21
|
-
action(result: ActionResult[]): Promise<ActionView[]>;
|
|
22
|
-
actionDetail(result: ActionResult): Promise<ActionViewDetail>;
|
|
23
|
-
report(result: ReportResult): Promise<ReportView>;
|
|
24
|
-
report(result: ReportResult[]): Promise<ReportView[]>;
|
|
25
21
|
reportPublic(report: ReportResult): ReportOutput;
|
|
26
|
-
reportDetail(result: ReportResult): Promise<ReportViewDetail>;
|
|
27
22
|
subject(result: SubjectResult): Promise<SubjectView>;
|
|
28
23
|
blob(blobs: BlobRef[]): Promise<BlobView[]>;
|
|
29
24
|
labels(subject: string, includeNeg?: boolean): Promise<Label[]>;
|
|
25
|
+
getSubjectStatus(subject: {
|
|
26
|
+
did: string;
|
|
27
|
+
recordPath?: string;
|
|
28
|
+
} | {
|
|
29
|
+
did: string;
|
|
30
|
+
recordPath?: string;
|
|
31
|
+
}[]): Promise<ModerationSubjectStatusRowWithHandle[]>;
|
|
32
|
+
subjectStatus(result: ModerationSubjectStatusRowWithHandle): SubjectStatusView;
|
|
33
|
+
subjectStatus(result: ModerationSubjectStatusRowWithHandle[]): SubjectStatusView[];
|
|
30
34
|
}
|
|
31
35
|
declare type RepoResult = Actor;
|
|
32
|
-
declare type
|
|
33
|
-
declare type ReportResult =
|
|
36
|
+
declare type EventResult = ModerationEventRowWithHandle;
|
|
37
|
+
declare type ReportResult = ModerationEventRowWithHandle;
|
|
34
38
|
declare type RecordResult = RecordRow;
|
|
35
|
-
declare type SubjectResult = Pick<
|
|
36
|
-
declare type SubjectView =
|
|
39
|
+
declare type SubjectResult = Pick<EventResult & ReportResult, 'id' | 'subjectType' | 'subjectDid' | 'subjectUri' | 'subjectCid'>;
|
|
40
|
+
declare type SubjectView = ModEventViewDetail['subject'] & ReportViewDetail['subject'];
|
|
37
41
|
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PrimaryDatabase } from '../../db';
|
|
2
|
+
export declare const BEFORE_LAST_SEEN_DAYS = 30;
|
|
3
|
+
export declare const BEFORE_LATEST_UNREAD_DAYS = 180;
|
|
4
|
+
export declare const UNREAD_KEPT_COUNT = 500;
|
|
5
|
+
export declare const tidyNotifications: (db: PrimaryDatabase, did: string) => Promise<void>;
|