@atproto/bsky 0.0.14 → 0.0.16

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.
Files changed (195) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/api/app/bsky/feed/searchPosts.d.ts +3 -0
  3. package/dist/api/com/atproto/moderation/util.d.ts +4 -3
  4. package/dist/config.d.ts +2 -2
  5. package/dist/context.d.ts +16 -1
  6. package/dist/db/index.js +26 -1
  7. package/dist/db/index.js.map +3 -3
  8. package/dist/db/migrations/20231003T202833377Z-create-moderation-subject-status.d.ts +3 -0
  9. package/dist/db/migrations/index.d.ts +1 -0
  10. package/dist/db/pagination.d.ts +2 -1
  11. package/dist/db/{periodic-moderation-action-reversal.d.ts → periodic-moderation-event-reversal.d.ts} +3 -5
  12. package/dist/db/tables/moderation.d.ts +24 -34
  13. package/dist/feed-gen/types.d.ts +1 -1
  14. package/dist/index.d.ts +2 -1
  15. package/dist/index.js +3332 -2430
  16. package/dist/index.js.map +3 -3
  17. package/dist/lexicon/index.d.ts +18 -18
  18. package/dist/lexicon/lexicons.d.ts +460 -385
  19. package/dist/lexicon/types/app/bsky/feed/defs.d.ts +1 -7
  20. package/dist/lexicon/types/app/bsky/graph/defs.d.ts +1 -0
  21. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +116 -48
  22. package/dist/lexicon/types/com/atproto/admin/{takeModerationAction.d.ts → emitModerationEvent.d.ts} +5 -6
  23. package/dist/lexicon/types/com/atproto/admin/{getModerationAction.d.ts → getModerationEvent.d.ts} +1 -1
  24. package/dist/lexicon/types/com/atproto/admin/{getModerationActions.d.ts → queryModerationEvents.d.ts} +5 -1
  25. package/dist/lexicon/types/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +12 -6
  26. package/dist/lexicon/types/com/atproto/admin/sendEmail.d.ts +1 -0
  27. package/dist/lexicon/types/com/atproto/{admin/getModerationReport.d.ts → temp/fetchLabels.d.ts} +7 -3
  28. package/dist/migrate-moderation-data.d.ts +1 -0
  29. package/dist/services/actor/views.d.ts +2 -5
  30. package/dist/services/feed/index.d.ts +1 -0
  31. package/dist/services/feed/util.d.ts +9 -1
  32. package/dist/services/feed/views.d.ts +6 -17
  33. package/dist/services/graph/index.d.ts +5 -29
  34. package/dist/services/graph/types.d.ts +1 -0
  35. package/dist/services/moderation/index.d.ts +135 -72
  36. package/dist/services/moderation/pagination.d.ts +36 -0
  37. package/dist/services/moderation/status.d.ts +13 -0
  38. package/dist/services/moderation/types.d.ts +35 -0
  39. package/dist/services/moderation/views.d.ts +18 -14
  40. package/dist/util/debug.d.ts +1 -1
  41. package/package.json +14 -15
  42. package/src/api/app/bsky/actor/getSuggestions.ts +45 -21
  43. package/src/api/app/bsky/feed/getActorFeeds.ts +2 -1
  44. package/src/api/app/bsky/feed/getActorLikes.ts +1 -3
  45. package/src/api/app/bsky/feed/getAuthorFeed.ts +1 -3
  46. package/src/api/app/bsky/feed/getFeed.ts +9 -9
  47. package/src/api/app/bsky/feed/getFeedGenerator.ts +3 -0
  48. package/src/api/app/bsky/feed/getFeedGenerators.ts +2 -1
  49. package/src/api/app/bsky/feed/getListFeed.ts +1 -3
  50. package/src/api/app/bsky/feed/getPostThread.ts +31 -58
  51. package/src/api/app/bsky/feed/getPosts.ts +21 -18
  52. package/src/api/app/bsky/feed/getSuggestedFeeds.ts +2 -1
  53. package/src/api/app/bsky/feed/getTimeline.ts +1 -3
  54. package/src/api/app/bsky/feed/searchPosts.ts +130 -0
  55. package/src/api/app/bsky/graph/getList.ts +6 -3
  56. package/src/api/app/bsky/graph/getListBlocks.ts +3 -2
  57. package/src/api/app/bsky/graph/getListMutes.ts +2 -1
  58. package/src/api/app/bsky/graph/getLists.ts +2 -1
  59. package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +3 -1
  60. package/src/api/blob-resolver.ts +6 -11
  61. package/src/api/com/atproto/admin/emitModerationEvent.ts +220 -0
  62. package/src/api/com/atproto/admin/{getModerationActions.ts → getModerationEvent.ts} +5 -11
  63. package/src/api/com/atproto/admin/getRecord.ts +1 -0
  64. package/src/api/com/atproto/admin/{getModerationReports.ts → queryModerationEvents.ts} +13 -16
  65. package/src/api/com/atproto/admin/queryModerationStatuses.ts +55 -0
  66. package/src/api/com/atproto/admin/util.ts +3 -1
  67. package/src/api/com/atproto/moderation/createReport.ts +9 -7
  68. package/src/api/com/atproto/moderation/util.ts +38 -20
  69. package/src/api/com/atproto/temp/fetchLabels.ts +30 -0
  70. package/src/api/index.ts +12 -14
  71. package/src/auth.ts +29 -21
  72. package/src/auto-moderator/index.ts +26 -19
  73. package/src/config.ts +6 -6
  74. package/src/context.ts +15 -9
  75. package/src/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +123 -0
  76. package/src/db/migrations/index.ts +1 -0
  77. package/src/db/pagination.ts +26 -3
  78. package/src/db/{periodic-moderation-action-reversal.ts → periodic-moderation-event-reversal.ts} +51 -55
  79. package/src/db/tables/moderation.ts +35 -52
  80. package/src/feed-gen/best-of-follows.ts +6 -3
  81. package/src/feed-gen/bsky-team.ts +1 -1
  82. package/src/feed-gen/hot-classic.ts +1 -1
  83. package/src/feed-gen/mutuals.ts +6 -2
  84. package/src/feed-gen/types.ts +1 -1
  85. package/src/feed-gen/whats-hot.ts +1 -1
  86. package/src/feed-gen/with-friends.ts +7 -3
  87. package/src/index.ts +2 -1
  88. package/src/lexicon/index.ts +52 -67
  89. package/src/lexicon/lexicons.ts +674 -579
  90. package/src/lexicon/types/app/bsky/actor/defs.ts +2 -2
  91. package/src/lexicon/types/app/bsky/actor/searchActors.ts +2 -2
  92. package/src/lexicon/types/app/bsky/actor/searchActorsTypeahead.ts +2 -2
  93. package/src/lexicon/types/app/bsky/feed/defs.ts +1 -18
  94. package/src/lexicon/types/app/bsky/feed/searchPosts.ts +3 -3
  95. package/src/lexicon/types/app/bsky/graph/defs.ts +3 -2
  96. package/src/lexicon/types/app/bsky/unspecced/searchActorsSkeleton.ts +4 -4
  97. package/src/lexicon/types/app/bsky/unspecced/searchPostsSkeleton.ts +3 -3
  98. package/src/lexicon/types/com/atproto/admin/defs.ts +278 -84
  99. package/src/lexicon/types/com/atproto/admin/disableAccountInvites.ts +1 -1
  100. package/src/lexicon/types/com/atproto/admin/{takeModerationAction.ts → emitModerationEvent.ts} +13 -11
  101. package/src/lexicon/types/com/atproto/admin/enableAccountInvites.ts +1 -1
  102. package/src/lexicon/types/com/atproto/admin/{getModerationReport.ts → getModerationEvent.ts} +1 -1
  103. package/src/lexicon/types/com/atproto/admin/{getModerationReports.ts → queryModerationEvents.ts} +8 -15
  104. package/src/lexicon/types/com/atproto/admin/queryModerationStatuses.ts +70 -0
  105. package/src/lexicon/types/com/atproto/admin/sendEmail.ts +1 -0
  106. package/src/lexicon/types/com/atproto/label/defs.ts +9 -9
  107. package/src/lexicon/types/com/atproto/label/queryLabels.ts +2 -2
  108. package/src/lexicon/types/com/atproto/repo/applyWrites.ts +1 -1
  109. package/src/lexicon/types/com/atproto/repo/createRecord.ts +2 -2
  110. package/src/lexicon/types/com/atproto/repo/deleteRecord.ts +2 -2
  111. package/src/lexicon/types/com/atproto/repo/listRecords.ts +1 -1
  112. package/src/lexicon/types/com/atproto/repo/putRecord.ts +3 -3
  113. package/src/lexicon/types/com/atproto/sync/listBlobs.ts +1 -1
  114. package/src/lexicon/types/com/atproto/sync/subscribeRepos.ts +4 -4
  115. package/src/lexicon/types/com/atproto/{admin/getModerationActions.ts → temp/fetchLabels.ts} +3 -5
  116. package/src/migrate-moderation-data.ts +414 -0
  117. package/src/services/actor/views.ts +5 -14
  118. package/src/services/feed/index.ts +26 -7
  119. package/src/services/feed/util.ts +47 -19
  120. package/src/services/feed/views.ts +68 -4
  121. package/src/services/graph/index.ts +21 -3
  122. package/src/services/graph/types.ts +1 -0
  123. package/src/services/indexing/plugins/block.ts +2 -3
  124. package/src/services/indexing/plugins/feed-generator.ts +2 -3
  125. package/src/services/indexing/plugins/follow.ts +2 -3
  126. package/src/services/indexing/plugins/like.ts +2 -3
  127. package/src/services/indexing/plugins/list-block.ts +2 -3
  128. package/src/services/indexing/plugins/list-item.ts +2 -3
  129. package/src/services/indexing/plugins/list.ts +2 -3
  130. package/src/services/indexing/plugins/post.ts +3 -4
  131. package/src/services/indexing/plugins/repost.ts +2 -3
  132. package/src/services/indexing/plugins/thread-gate.ts +2 -3
  133. package/src/services/label/index.ts +2 -3
  134. package/src/services/moderation/index.ts +380 -395
  135. package/src/services/moderation/pagination.ts +96 -0
  136. package/src/services/moderation/status.ts +244 -0
  137. package/src/services/moderation/types.ts +49 -0
  138. package/src/services/moderation/views.ts +278 -329
  139. package/src/util/debug.ts +2 -2
  140. package/tests/__snapshots__/feed-generation.test.ts.snap +322 -6
  141. package/tests/__snapshots__/indexing.test.ts.snap +0 -6
  142. package/tests/admin/__snapshots__/get-record.test.ts.snap +30 -132
  143. package/tests/admin/__snapshots__/get-repo.test.ts.snap +14 -60
  144. package/tests/admin/__snapshots__/moderation-events.test.ts.snap +146 -0
  145. package/tests/admin/__snapshots__/moderation-statuses.test.ts.snap +64 -0
  146. package/tests/admin/__snapshots__/moderation.test.ts.snap +0 -125
  147. package/tests/admin/get-record.test.ts +5 -9
  148. package/tests/admin/get-repo.test.ts +38 -9
  149. package/tests/admin/moderation-events.test.ts +221 -0
  150. package/tests/admin/moderation-statuses.test.ts +145 -0
  151. package/tests/admin/moderation.test.ts +512 -860
  152. package/tests/admin/repo-search.test.ts +2 -3
  153. package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -1
  154. package/tests/auto-moderator/takedowns.test.ts +45 -18
  155. package/tests/feed-generation.test.ts +57 -9
  156. package/tests/views/__snapshots__/block-lists.test.ts.snap +3 -9
  157. package/tests/views/__snapshots__/blocks.test.ts.snap +0 -9
  158. package/tests/views/__snapshots__/mute-lists.test.ts.snap +5 -5
  159. package/tests/views/__snapshots__/mutes.test.ts.snap +0 -3
  160. package/tests/views/__snapshots__/thread.test.ts.snap +0 -30
  161. package/tests/views/actor-search.test.ts +2 -3
  162. package/tests/views/author-feed.test.ts +42 -36
  163. package/tests/views/follows.test.ts +40 -35
  164. package/tests/views/list-feed.test.ts +17 -9
  165. package/tests/views/notifications.test.ts +13 -9
  166. package/tests/views/profile.test.ts +20 -18
  167. package/tests/views/suggestions.test.ts +15 -7
  168. package/tests/views/thread.test.ts +54 -26
  169. package/tests/views/threadgating.test.ts +51 -19
  170. package/tests/views/timeline.test.ts +21 -13
  171. package/dist/api/com/atproto/admin/reverseModerationAction.d.ts +0 -3
  172. package/dist/api/com/atproto/admin/takeModerationAction.d.ts +0 -3
  173. package/dist/lexicon/types/com/atproto/admin/resolveModerationReports.d.ts +0 -36
  174. package/dist/lexicon/types/com/atproto/admin/reverseModerationAction.d.ts +0 -36
  175. package/src/api/com/atproto/admin/getModerationAction.ts +0 -44
  176. package/src/api/com/atproto/admin/getModerationReport.ts +0 -43
  177. package/src/api/com/atproto/admin/resolveModerationReports.ts +0 -24
  178. package/src/api/com/atproto/admin/reverseModerationAction.ts +0 -115
  179. package/src/api/com/atproto/admin/takeModerationAction.ts +0 -156
  180. package/src/lexicon/types/com/atproto/admin/getModerationAction.ts +0 -41
  181. package/src/lexicon/types/com/atproto/admin/resolveModerationReports.ts +0 -49
  182. package/src/lexicon/types/com/atproto/admin/reverseModerationAction.ts +0 -49
  183. package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +0 -172
  184. package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +0 -178
  185. package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +0 -177
  186. package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +0 -307
  187. package/tests/admin/get-moderation-action.test.ts +0 -100
  188. package/tests/admin/get-moderation-actions.test.ts +0 -164
  189. package/tests/admin/get-moderation-report.test.ts +0 -100
  190. package/tests/admin/get-moderation-reports.test.ts +0 -332
  191. /package/dist/api/com/atproto/admin/{getModerationAction.d.ts → emitModerationEvent.d.ts} +0 -0
  192. /package/dist/api/com/atproto/admin/{getModerationActions.d.ts → getModerationEvent.d.ts} +0 -0
  193. /package/dist/api/com/atproto/admin/{getModerationReport.d.ts → queryModerationEvents.d.ts} +0 -0
  194. /package/dist/api/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +0 -0
  195. /package/dist/api/com/atproto/{admin/resolveModerationReports.d.ts → temp/fetchLabels.d.ts} +0 -0
@@ -1,156 +0,0 @@
1
- import { CID } from 'multiformats/cid'
2
- import { AtUri } from '@atproto/syntax'
3
- import {
4
- AuthRequiredError,
5
- InvalidRequestError,
6
- UpstreamFailureError,
7
- } from '@atproto/xrpc-server'
8
- import { Server } from '../../../../lexicon'
9
- import AppContext from '../../../../context'
10
- import {
11
- ACKNOWLEDGE,
12
- ESCALATE,
13
- TAKEDOWN,
14
- } from '../../../../lexicon/types/com/atproto/admin/defs'
15
- import { getSubject, getAction } from '../moderation/util'
16
- import { TakedownSubjects } from '../../../../services/moderation'
17
- import { retryHttp } from '../../../../util/retry'
18
-
19
- export default function (server: Server, ctx: AppContext) {
20
- server.com.atproto.admin.takeModerationAction({
21
- auth: ctx.roleVerifier,
22
- handler: async ({ input, auth }) => {
23
- const access = auth.credentials
24
- const db = ctx.db.getPrimary()
25
- const moderationService = ctx.services.moderation(db)
26
- const {
27
- action,
28
- subject,
29
- reason,
30
- createdBy,
31
- createLabelVals,
32
- negateLabelVals,
33
- subjectBlobCids,
34
- durationInHours,
35
- } = input.body
36
-
37
- // apply access rules
38
-
39
- // if less than admin access then can not takedown an account
40
- if (!access.moderator && action === TAKEDOWN && 'did' in subject) {
41
- throw new AuthRequiredError(
42
- 'Must be a full moderator to perform an account takedown',
43
- )
44
- }
45
- // if less than moderator access then can only take ack and escalation actions
46
- if (!access.moderator && ![ACKNOWLEDGE, ESCALATE].includes(action)) {
47
- throw new AuthRequiredError(
48
- 'Must be a full moderator to take this type of action',
49
- )
50
- }
51
- // if less than moderator access then can not apply labels
52
- if (
53
- !access.moderator &&
54
- (createLabelVals?.length || negateLabelVals?.length)
55
- ) {
56
- throw new AuthRequiredError('Must be a full moderator to label content')
57
- }
58
-
59
- validateLabels([...(createLabelVals ?? []), ...(negateLabelVals ?? [])])
60
-
61
- const { result, takenDown } = await db.transaction(async (dbTxn) => {
62
- const moderationTxn = ctx.services.moderation(dbTxn)
63
- const labelTxn = ctx.services.label(dbTxn)
64
-
65
- const result = await moderationTxn.logAction({
66
- action: getAction(action),
67
- subject: getSubject(subject),
68
- subjectBlobCids: subjectBlobCids?.map((cid) => CID.parse(cid)) ?? [],
69
- createLabelVals,
70
- negateLabelVals,
71
- createdBy,
72
- reason,
73
- durationInHours,
74
- })
75
-
76
- let takenDown: TakedownSubjects | undefined
77
-
78
- if (
79
- result.action === TAKEDOWN &&
80
- result.subjectType === 'com.atproto.admin.defs#repoRef' &&
81
- result.subjectDid
82
- ) {
83
- // No credentials to revoke on appview
84
- takenDown = await moderationTxn.takedownRepo({
85
- takedownId: result.id,
86
- did: result.subjectDid,
87
- })
88
- }
89
-
90
- if (
91
- result.action === TAKEDOWN &&
92
- result.subjectType === 'com.atproto.repo.strongRef' &&
93
- result.subjectUri &&
94
- result.subjectCid
95
- ) {
96
- takenDown = await moderationTxn.takedownRecord({
97
- takedownId: result.id,
98
- uri: new AtUri(result.subjectUri),
99
- cid: CID.parse(result.subjectCid),
100
- blobCids: subjectBlobCids?.map((cid) => CID.parse(cid)) ?? [],
101
- })
102
- }
103
-
104
- await labelTxn.formatAndCreate(
105
- ctx.cfg.labelerDid,
106
- result.subjectUri ?? result.subjectDid,
107
- result.subjectCid,
108
- { create: createLabelVals, negate: negateLabelVals },
109
- )
110
-
111
- return { result, takenDown }
112
- })
113
-
114
- if (takenDown) {
115
- const { did, subjects } = takenDown
116
- if (did && subjects.length > 0) {
117
- const agent = await ctx.pdsAdminAgent(did)
118
- const results = await Promise.allSettled(
119
- subjects.map((subject) =>
120
- retryHttp(() =>
121
- agent.api.com.atproto.admin.updateSubjectStatus({
122
- subject,
123
- takedown: {
124
- applied: true,
125
- ref: result.id.toString(),
126
- },
127
- }),
128
- ),
129
- ),
130
- )
131
- const hadFailure = results.some((r) => r.status === 'rejected')
132
- if (hadFailure) {
133
- throw new UpstreamFailureError('failed to apply action on PDS')
134
- }
135
- }
136
- }
137
-
138
- return {
139
- encoding: 'application/json',
140
- body: await moderationService.views.action(result),
141
- }
142
- },
143
- })
144
- }
145
-
146
- const validateLabels = (labels: string[]) => {
147
- for (const label of labels) {
148
- for (const char of badChars) {
149
- if (label.includes(char)) {
150
- throw new InvalidRequestError(`Invalid label: ${label}`)
151
- }
152
- }
153
- }
154
- }
155
-
156
- const badChars = [' ', ',', ';', `'`, `"`]
@@ -1,41 +0,0 @@
1
- /**
2
- * GENERATED CODE - DO NOT MODIFY
3
- */
4
- import express from 'express'
5
- import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
- import { lexicons } from '../../../../lexicons'
7
- import { isObj, hasProp } from '../../../../util'
8
- import { CID } from 'multiformats/cid'
9
- import { HandlerAuth } from '@atproto/xrpc-server'
10
- import * as ComAtprotoAdminDefs from './defs'
11
-
12
- export interface QueryParams {
13
- id: number
14
- }
15
-
16
- export type InputSchema = undefined
17
- export type OutputSchema = ComAtprotoAdminDefs.ActionViewDetail
18
- export type HandlerInput = undefined
19
-
20
- export interface HandlerSuccess {
21
- encoding: 'application/json'
22
- body: OutputSchema
23
- headers?: { [key: string]: string }
24
- }
25
-
26
- export interface HandlerError {
27
- status: number
28
- message?: string
29
- }
30
-
31
- export type HandlerOutput = HandlerError | HandlerSuccess
32
- export 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 type Handler<HA extends HandlerAuth = never> = (
40
- ctx: HandlerReqCtx<HA>,
41
- ) => Promise<HandlerOutput> | HandlerOutput
@@ -1,49 +0,0 @@
1
- /**
2
- * GENERATED CODE - DO NOT MODIFY
3
- */
4
- import express from 'express'
5
- import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
- import { lexicons } from '../../../../lexicons'
7
- import { isObj, hasProp } from '../../../../util'
8
- import { CID } from 'multiformats/cid'
9
- import { HandlerAuth } from '@atproto/xrpc-server'
10
- import * as ComAtprotoAdminDefs from './defs'
11
-
12
- export interface QueryParams {}
13
-
14
- export interface InputSchema {
15
- actionId: number
16
- reportIds: number[]
17
- createdBy: string
18
- [k: string]: unknown
19
- }
20
-
21
- export type OutputSchema = ComAtprotoAdminDefs.ActionView
22
-
23
- export interface HandlerInput {
24
- encoding: 'application/json'
25
- body: InputSchema
26
- }
27
-
28
- export interface HandlerSuccess {
29
- encoding: 'application/json'
30
- body: OutputSchema
31
- headers?: { [key: string]: string }
32
- }
33
-
34
- export interface HandlerError {
35
- status: number
36
- message?: string
37
- }
38
-
39
- export type HandlerOutput = HandlerError | HandlerSuccess
40
- export type HandlerReqCtx<HA extends HandlerAuth = never> = {
41
- auth: HA
42
- params: QueryParams
43
- input: HandlerInput
44
- req: express.Request
45
- res: express.Response
46
- }
47
- export type Handler<HA extends HandlerAuth = never> = (
48
- ctx: HandlerReqCtx<HA>,
49
- ) => Promise<HandlerOutput> | HandlerOutput
@@ -1,49 +0,0 @@
1
- /**
2
- * GENERATED CODE - DO NOT MODIFY
3
- */
4
- import express from 'express'
5
- import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
- import { lexicons } from '../../../../lexicons'
7
- import { isObj, hasProp } from '../../../../util'
8
- import { CID } from 'multiformats/cid'
9
- import { HandlerAuth } from '@atproto/xrpc-server'
10
- import * as ComAtprotoAdminDefs from './defs'
11
-
12
- export interface QueryParams {}
13
-
14
- export interface InputSchema {
15
- id: number
16
- reason: string
17
- createdBy: string
18
- [k: string]: unknown
19
- }
20
-
21
- export type OutputSchema = ComAtprotoAdminDefs.ActionView
22
-
23
- export interface HandlerInput {
24
- encoding: 'application/json'
25
- body: InputSchema
26
- }
27
-
28
- export interface HandlerSuccess {
29
- encoding: 'application/json'
30
- body: OutputSchema
31
- headers?: { [key: string]: string }
32
- }
33
-
34
- export interface HandlerError {
35
- status: number
36
- message?: string
37
- }
38
-
39
- export type HandlerOutput = HandlerError | HandlerSuccess
40
- export type HandlerReqCtx<HA extends HandlerAuth = never> = {
41
- auth: HA
42
- params: QueryParams
43
- input: HandlerInput
44
- req: express.Request
45
- res: express.Response
46
- }
47
- export type Handler<HA extends HandlerAuth = never> = (
48
- ctx: HandlerReqCtx<HA>,
49
- ) => Promise<HandlerOutput> | HandlerOutput
@@ -1,172 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`admin get moderation action view gets moderation action for a record. 1`] = `
4
- Object {
5
- "action": "com.atproto.admin.defs#takedown",
6
- "createdAt": "1970-01-01T00:00:00.000Z",
7
- "createdBy": "did:example:admin",
8
- "id": 2,
9
- "reason": "X",
10
- "resolvedReports": Array [
11
- Object {
12
- "createdAt": "1970-01-01T00:00:00.000Z",
13
- "id": 2,
14
- "reason": "defamation",
15
- "reasonType": "com.atproto.moderation.defs#reasonOther",
16
- "reportedBy": "user(1)",
17
- "resolvedByActionIds": Array [
18
- 2,
19
- 1,
20
- ],
21
- "subject": Object {
22
- "$type": "com.atproto.repo.strongRef",
23
- "cid": "cids(0)",
24
- "uri": "record(0)",
25
- },
26
- },
27
- ],
28
- "subject": Object {
29
- "$type": "com.atproto.admin.defs#recordView",
30
- "blobCids": Array [],
31
- "cid": "cids(0)",
32
- "indexedAt": "1970-01-01T00:00:00.000Z",
33
- "moderation": Object {
34
- "currentAction": Object {
35
- "action": "com.atproto.admin.defs#takedown",
36
- "id": 2,
37
- },
38
- },
39
- "repo": Object {
40
- "did": "user(0)",
41
- "email": "alice@test.com",
42
- "handle": "alice.test",
43
- "indexedAt": "1970-01-01T00:00:00.000Z",
44
- "invitesDisabled": false,
45
- "moderation": Object {},
46
- "relatedRecords": Array [
47
- Object {
48
- "$type": "app.bsky.actor.profile",
49
- "avatar": Object {
50
- "$type": "blob",
51
- "mimeType": "image/jpeg",
52
- "ref": Object {
53
- "$link": "cids(1)",
54
- },
55
- "size": 3976,
56
- },
57
- "description": "its me!",
58
- "displayName": "ali",
59
- "labels": Object {
60
- "$type": "com.atproto.label.defs#selfLabels",
61
- "values": Array [
62
- Object {
63
- "val": "self-label-a",
64
- },
65
- Object {
66
- "val": "self-label-b",
67
- },
68
- ],
69
- },
70
- },
71
- ],
72
- },
73
- "uri": "record(0)",
74
- "value": Object {
75
- "$type": "app.bsky.feed.post",
76
- "createdAt": "1970-01-01T00:00:00.000Z",
77
- "labels": Object {
78
- "$type": "com.atproto.label.defs#selfLabels",
79
- "values": Array [
80
- Object {
81
- "val": "self-label",
82
- },
83
- ],
84
- },
85
- "text": "hey there",
86
- },
87
- },
88
- "subjectBlobs": Array [],
89
- }
90
- `;
91
-
92
- exports[`admin get moderation action view gets moderation action for a repo. 1`] = `
93
- Object {
94
- "action": "com.atproto.admin.defs#flag",
95
- "createdAt": "1970-01-01T00:00:00.000Z",
96
- "createdBy": "did:example:admin",
97
- "id": 1,
98
- "reason": "X",
99
- "resolvedReports": Array [
100
- Object {
101
- "createdAt": "1970-01-01T00:00:00.000Z",
102
- "id": 2,
103
- "reason": "defamation",
104
- "reasonType": "com.atproto.moderation.defs#reasonOther",
105
- "reportedBy": "user(1)",
106
- "resolvedByActionIds": Array [
107
- 2,
108
- 1,
109
- ],
110
- "subject": Object {
111
- "$type": "com.atproto.repo.strongRef",
112
- "cid": "cids(1)",
113
- "uri": "record(0)",
114
- },
115
- },
116
- Object {
117
- "createdAt": "1970-01-01T00:00:00.000Z",
118
- "id": 1,
119
- "reasonType": "com.atproto.moderation.defs#reasonSpam",
120
- "reportedBy": "user(2)",
121
- "resolvedByActionIds": Array [
122
- 1,
123
- ],
124
- "subject": Object {
125
- "$type": "com.atproto.admin.defs#repoRef",
126
- "did": "user(0)",
127
- },
128
- },
129
- ],
130
- "reversal": Object {
131
- "createdAt": "1970-01-01T00:00:00.000Z",
132
- "createdBy": "did:example:admin",
133
- "reason": "X",
134
- },
135
- "subject": Object {
136
- "$type": "com.atproto.admin.defs#repoView",
137
- "did": "user(0)",
138
- "email": "alice@test.com",
139
- "handle": "alice.test",
140
- "indexedAt": "1970-01-01T00:00:00.000Z",
141
- "invitesDisabled": false,
142
- "moderation": Object {},
143
- "relatedRecords": Array [
144
- Object {
145
- "$type": "app.bsky.actor.profile",
146
- "avatar": Object {
147
- "$type": "blob",
148
- "mimeType": "image/jpeg",
149
- "ref": Object {
150
- "$link": "cids(0)",
151
- },
152
- "size": 3976,
153
- },
154
- "description": "its me!",
155
- "displayName": "ali",
156
- "labels": Object {
157
- "$type": "com.atproto.label.defs#selfLabels",
158
- "values": Array [
159
- Object {
160
- "val": "self-label-a",
161
- },
162
- Object {
163
- "val": "self-label-b",
164
- },
165
- ],
166
- },
167
- },
168
- ],
169
- },
170
- "subjectBlobs": Array [],
171
- }
172
- `;
@@ -1,178 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`admin get moderation actions view gets all moderation actions for a record. 1`] = `
4
- Array [
5
- Object {
6
- "action": "com.atproto.admin.defs#flag",
7
- "createdAt": "1970-01-01T00:00:00.000Z",
8
- "createdBy": "did:example:admin",
9
- "id": 1,
10
- "reason": "X",
11
- "resolvedReportIds": Array [
12
- 1,
13
- ],
14
- "reversal": Object {
15
- "createdAt": "1970-01-01T00:00:00.000Z",
16
- "createdBy": "did:example:admin",
17
- "reason": "X",
18
- },
19
- "subject": Object {
20
- "$type": "com.atproto.repo.strongRef",
21
- "cid": "cids(0)",
22
- "uri": "record(0)",
23
- },
24
- "subjectBlobCids": Array [],
25
- },
26
- ]
27
- `;
28
-
29
- exports[`admin get moderation actions view gets all moderation actions for a repo. 1`] = `
30
- Array [
31
- Object {
32
- "action": "com.atproto.admin.defs#flag",
33
- "createdAt": "1970-01-01T00:00:00.000Z",
34
- "createdBy": "did:example:admin",
35
- "id": 5,
36
- "reason": "X",
37
- "resolvedReportIds": Array [
38
- 3,
39
- ],
40
- "subject": Object {
41
- "$type": "com.atproto.admin.defs#repoRef",
42
- "did": "user(0)",
43
- },
44
- "subjectBlobCids": Array [],
45
- },
46
- Object {
47
- "action": "com.atproto.admin.defs#acknowledge",
48
- "createdAt": "1970-01-01T00:00:00.000Z",
49
- "createdBy": "did:example:admin",
50
- "id": 2,
51
- "reason": "X",
52
- "resolvedReportIds": Array [],
53
- "subject": Object {
54
- "$type": "com.atproto.repo.strongRef",
55
- "cid": "cids(0)",
56
- "uri": "record(0)",
57
- },
58
- "subjectBlobCids": Array [],
59
- },
60
- Object {
61
- "action": "com.atproto.admin.defs#flag",
62
- "createdAt": "1970-01-01T00:00:00.000Z",
63
- "createdBy": "did:example:admin",
64
- "id": 1,
65
- "reason": "X",
66
- "resolvedReportIds": Array [
67
- 1,
68
- ],
69
- "reversal": Object {
70
- "createdAt": "1970-01-01T00:00:00.000Z",
71
- "createdBy": "did:example:admin",
72
- "reason": "X",
73
- },
74
- "subject": Object {
75
- "$type": "com.atproto.repo.strongRef",
76
- "cid": "cids(1)",
77
- "uri": "record(1)",
78
- },
79
- "subjectBlobCids": Array [],
80
- },
81
- ]
82
- `;
83
-
84
- exports[`admin get moderation actions view gets all moderation actions. 1`] = `
85
- Array [
86
- Object {
87
- "action": "com.atproto.admin.defs#acknowledge",
88
- "createdAt": "1970-01-01T00:00:00.000Z",
89
- "createdBy": "did:example:admin",
90
- "id": 6,
91
- "reason": "X",
92
- "resolvedReportIds": Array [],
93
- "subject": Object {
94
- "$type": "com.atproto.admin.defs#repoRef",
95
- "did": "user(0)",
96
- },
97
- "subjectBlobCids": Array [],
98
- },
99
- Object {
100
- "action": "com.atproto.admin.defs#flag",
101
- "createdAt": "1970-01-01T00:00:00.000Z",
102
- "createdBy": "did:example:admin",
103
- "id": 5,
104
- "reason": "X",
105
- "resolvedReportIds": Array [
106
- 3,
107
- ],
108
- "subject": Object {
109
- "$type": "com.atproto.admin.defs#repoRef",
110
- "did": "user(1)",
111
- },
112
- "subjectBlobCids": Array [],
113
- },
114
- Object {
115
- "action": "com.atproto.admin.defs#flag",
116
- "createdAt": "1970-01-01T00:00:00.000Z",
117
- "createdBy": "did:example:admin",
118
- "id": 4,
119
- "reason": "X",
120
- "resolvedReportIds": Array [],
121
- "subject": Object {
122
- "$type": "com.atproto.repo.strongRef",
123
- "cid": "cids(0)",
124
- "uri": "record(0)",
125
- },
126
- "subjectBlobCids": Array [],
127
- },
128
- Object {
129
- "action": "com.atproto.admin.defs#takedown",
130
- "createdAt": "1970-01-01T00:00:00.000Z",
131
- "createdBy": "did:example:admin",
132
- "id": 3,
133
- "reason": "X",
134
- "resolvedReportIds": Array [],
135
- "subject": Object {
136
- "$type": "com.atproto.repo.strongRef",
137
- "cid": "cids(1)",
138
- "uri": "record(1)",
139
- },
140
- "subjectBlobCids": Array [],
141
- },
142
- Object {
143
- "action": "com.atproto.admin.defs#acknowledge",
144
- "createdAt": "1970-01-01T00:00:00.000Z",
145
- "createdBy": "did:example:admin",
146
- "id": 2,
147
- "reason": "X",
148
- "resolvedReportIds": Array [],
149
- "subject": Object {
150
- "$type": "com.atproto.repo.strongRef",
151
- "cid": "cids(2)",
152
- "uri": "record(2)",
153
- },
154
- "subjectBlobCids": Array [],
155
- },
156
- Object {
157
- "action": "com.atproto.admin.defs#flag",
158
- "createdAt": "1970-01-01T00:00:00.000Z",
159
- "createdBy": "did:example:admin",
160
- "id": 1,
161
- "reason": "X",
162
- "resolvedReportIds": Array [
163
- 1,
164
- ],
165
- "reversal": Object {
166
- "createdAt": "1970-01-01T00:00:00.000Z",
167
- "createdBy": "did:example:admin",
168
- "reason": "X",
169
- },
170
- "subject": Object {
171
- "$type": "com.atproto.repo.strongRef",
172
- "cid": "cids(3)",
173
- "uri": "record(3)",
174
- },
175
- "subjectBlobCids": Array [],
176
- },
177
- ]
178
- `;