@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.
Files changed (236) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/api/com/atproto/moderation/util.d.ts +4 -3
  3. package/dist/cache/read-through.d.ts +30 -0
  4. package/dist/config.d.ts +18 -0
  5. package/dist/context.d.ts +21 -6
  6. package/dist/daemon/config.d.ts +15 -0
  7. package/dist/daemon/context.d.ts +15 -0
  8. package/dist/daemon/index.d.ts +23 -0
  9. package/dist/daemon/logger.d.ts +3 -0
  10. package/dist/daemon/notifications.d.ts +18 -0
  11. package/dist/daemon/services.d.ts +11 -0
  12. package/dist/db/database-schema.d.ts +1 -2
  13. package/dist/db/index.js +41 -1
  14. package/dist/db/index.js.map +3 -3
  15. package/dist/db/migrations/20231003T202833377Z-create-moderation-subject-status.d.ts +3 -0
  16. package/dist/db/migrations/20231205T000257238Z-remove-did-cache.d.ts +3 -0
  17. package/dist/db/migrations/index.d.ts +2 -0
  18. package/dist/db/pagination.d.ts +2 -1
  19. package/dist/db/{periodic-moderation-action-reversal.d.ts → periodic-moderation-event-reversal.d.ts} +3 -5
  20. package/dist/db/tables/moderation.d.ts +24 -34
  21. package/dist/did-cache.d.ts +10 -7
  22. package/dist/feed-gen/types.d.ts +1 -1
  23. package/dist/index.d.ts +6 -1
  24. package/dist/index.js +4370 -2758
  25. package/dist/index.js.map +3 -3
  26. package/dist/indexer/context.d.ts +2 -0
  27. package/dist/indexer/index.d.ts +1 -0
  28. package/dist/lexicon/index.d.ts +23 -18
  29. package/dist/lexicon/lexicons.d.ts +561 -412
  30. package/dist/lexicon/types/app/bsky/feed/defs.d.ts +1 -7
  31. package/dist/lexicon/types/app/bsky/graph/defs.d.ts +1 -0
  32. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +114 -48
  33. package/dist/lexicon/types/com/atproto/admin/{resolveModerationReports.d.ts → deleteAccount.d.ts} +2 -13
  34. package/dist/lexicon/types/com/atproto/admin/{takeModerationAction.d.ts → emitModerationEvent.d.ts} +5 -6
  35. package/dist/lexicon/types/com/atproto/admin/{getModerationAction.d.ts → getModerationEvent.d.ts} +1 -1
  36. package/dist/lexicon/types/com/atproto/admin/{getModerationActions.d.ts → queryModerationEvents.d.ts} +5 -1
  37. package/dist/lexicon/types/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +12 -6
  38. package/dist/lexicon/types/com/atproto/admin/sendEmail.d.ts +1 -0
  39. package/dist/lexicon/types/com/atproto/{admin/getModerationReport.d.ts → temp/importRepo.d.ts} +10 -7
  40. package/dist/lexicon/types/com/atproto/temp/pushBlob.d.ts +25 -0
  41. package/dist/lexicon/types/com/atproto/{admin/reverseModerationAction.d.ts → temp/transferAccount.d.ts} +11 -5
  42. package/dist/logger.d.ts +1 -0
  43. package/dist/migrate-moderation-data.d.ts +1 -0
  44. package/dist/redis.d.ts +10 -1
  45. package/dist/services/actor/index.d.ts +18 -4
  46. package/dist/services/actor/views.d.ts +6 -8
  47. package/dist/services/feed/index.d.ts +7 -4
  48. package/dist/services/feed/util.d.ts +9 -1
  49. package/dist/services/feed/views.d.ts +11 -21
  50. package/dist/services/graph/index.d.ts +5 -29
  51. package/dist/services/graph/types.d.ts +1 -0
  52. package/dist/services/index.d.ts +3 -7
  53. package/dist/services/label/index.d.ts +10 -4
  54. package/dist/services/moderation/index.d.ts +134 -72
  55. package/dist/services/moderation/pagination.d.ts +36 -0
  56. package/dist/services/moderation/status.d.ts +13 -0
  57. package/dist/services/moderation/types.d.ts +35 -0
  58. package/dist/services/moderation/views.d.ts +18 -14
  59. package/dist/services/types.d.ts +3 -0
  60. package/dist/services/util/notification.d.ts +5 -0
  61. package/dist/services/util/post.d.ts +6 -6
  62. package/dist/util/debug.d.ts +1 -1
  63. package/dist/util/retry.d.ts +1 -6
  64. package/package.json +11 -11
  65. package/src/api/app/bsky/feed/getActorFeeds.ts +2 -1
  66. package/src/api/app/bsky/feed/getActorLikes.ts +1 -3
  67. package/src/api/app/bsky/feed/getAuthorFeed.ts +1 -3
  68. package/src/api/app/bsky/feed/getFeed.ts +9 -9
  69. package/src/api/app/bsky/feed/getFeedGenerator.ts +3 -0
  70. package/src/api/app/bsky/feed/getFeedGenerators.ts +2 -1
  71. package/src/api/app/bsky/feed/getListFeed.ts +1 -3
  72. package/src/api/app/bsky/feed/getPostThread.ts +15 -54
  73. package/src/api/app/bsky/feed/getPosts.ts +21 -18
  74. package/src/api/app/bsky/feed/getSuggestedFeeds.ts +2 -1
  75. package/src/api/app/bsky/feed/getTimeline.ts +1 -3
  76. package/src/api/app/bsky/feed/searchPosts.ts +20 -17
  77. package/src/api/app/bsky/graph/getList.ts +6 -3
  78. package/src/api/app/bsky/graph/getListBlocks.ts +3 -2
  79. package/src/api/app/bsky/graph/getListMutes.ts +2 -1
  80. package/src/api/app/bsky/graph/getLists.ts +2 -1
  81. package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +3 -1
  82. package/src/api/blob-resolver.ts +6 -11
  83. package/src/api/com/atproto/admin/emitModerationEvent.ts +220 -0
  84. package/src/api/com/atproto/admin/{getModerationActions.ts → getModerationEvent.ts} +5 -11
  85. package/src/api/com/atproto/admin/getRecord.ts +1 -0
  86. package/src/api/com/atproto/admin/{getModerationReports.ts → queryModerationEvents.ts} +13 -16
  87. package/src/api/com/atproto/admin/queryModerationStatuses.ts +55 -0
  88. package/src/api/com/atproto/moderation/createReport.ts +9 -7
  89. package/src/api/com/atproto/moderation/util.ts +38 -20
  90. package/src/api/index.ts +8 -14
  91. package/src/auth.ts +29 -21
  92. package/src/auto-moderator/index.ts +26 -19
  93. package/src/cache/read-through.ts +151 -0
  94. package/src/config.ts +90 -1
  95. package/src/context.ts +11 -7
  96. package/src/daemon/config.ts +60 -0
  97. package/src/daemon/context.ts +27 -0
  98. package/src/daemon/index.ts +78 -0
  99. package/src/daemon/logger.ts +6 -0
  100. package/src/daemon/notifications.ts +54 -0
  101. package/src/daemon/services.ts +22 -0
  102. package/src/db/database-schema.ts +0 -2
  103. package/src/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +123 -0
  104. package/src/db/migrations/20231205T000257238Z-remove-did-cache.ts +14 -0
  105. package/src/db/migrations/index.ts +2 -0
  106. package/src/db/pagination.ts +26 -3
  107. package/src/db/{periodic-moderation-action-reversal.ts → periodic-moderation-event-reversal.ts} +50 -46
  108. package/src/db/tables/moderation.ts +35 -52
  109. package/src/did-cache.ts +33 -56
  110. package/src/feed-gen/bsky-team.ts +1 -1
  111. package/src/feed-gen/hot-classic.ts +1 -1
  112. package/src/feed-gen/index.ts +0 -4
  113. package/src/feed-gen/mutuals.ts +6 -2
  114. package/src/feed-gen/types.ts +1 -1
  115. package/src/index.ts +57 -17
  116. package/src/indexer/context.ts +5 -0
  117. package/src/indexer/index.ts +10 -7
  118. package/src/lexicon/index.ts +80 -67
  119. package/src/lexicon/lexicons.ts +698 -507
  120. package/src/lexicon/types/app/bsky/feed/defs.ts +1 -18
  121. package/src/lexicon/types/app/bsky/graph/defs.ts +1 -0
  122. package/src/lexicon/types/com/atproto/admin/defs.ts +276 -84
  123. package/src/lexicon/types/com/atproto/admin/{resolveModerationReports.ts → deleteAccount.ts} +2 -13
  124. package/src/lexicon/types/com/atproto/admin/{takeModerationAction.ts → emitModerationEvent.ts} +13 -11
  125. package/src/lexicon/types/com/atproto/admin/{getModerationReport.ts → getModerationEvent.ts} +1 -1
  126. package/src/lexicon/types/com/atproto/admin/{getModerationActions.ts → queryModerationEvents.ts} +8 -1
  127. package/src/lexicon/types/com/atproto/admin/{getModerationReports.ts → queryModerationStatuses.ts} +21 -14
  128. package/src/lexicon/types/com/atproto/admin/sendEmail.ts +1 -0
  129. package/src/lexicon/types/com/atproto/{admin/getModerationAction.ts → temp/importRepo.ts} +11 -7
  130. package/src/lexicon/types/com/atproto/temp/pushBlob.ts +39 -0
  131. package/src/lexicon/types/com/atproto/{admin/reverseModerationAction.ts → temp/transferAccount.ts} +18 -5
  132. package/src/logger.ts +2 -0
  133. package/src/migrate-moderation-data.ts +414 -0
  134. package/src/redis.ts +43 -3
  135. package/src/services/actor/index.ts +55 -7
  136. package/src/services/actor/views.ts +18 -21
  137. package/src/services/feed/index.ts +52 -19
  138. package/src/services/feed/util.ts +47 -19
  139. package/src/services/feed/views.ts +87 -13
  140. package/src/services/graph/index.ts +21 -3
  141. package/src/services/graph/types.ts +1 -0
  142. package/src/services/index.ts +14 -14
  143. package/src/services/indexing/index.ts +7 -10
  144. package/src/services/indexing/plugins/block.ts +2 -3
  145. package/src/services/indexing/plugins/feed-generator.ts +2 -3
  146. package/src/services/indexing/plugins/follow.ts +2 -3
  147. package/src/services/indexing/plugins/like.ts +2 -3
  148. package/src/services/indexing/plugins/list-block.ts +2 -3
  149. package/src/services/indexing/plugins/list-item.ts +2 -3
  150. package/src/services/indexing/plugins/list.ts +2 -3
  151. package/src/services/indexing/plugins/post.ts +16 -4
  152. package/src/services/indexing/plugins/repost.ts +2 -3
  153. package/src/services/indexing/plugins/thread-gate.ts +2 -3
  154. package/src/services/label/index.ts +68 -25
  155. package/src/services/moderation/index.ts +380 -395
  156. package/src/services/moderation/pagination.ts +96 -0
  157. package/src/services/moderation/status.ts +241 -0
  158. package/src/services/moderation/types.ts +49 -0
  159. package/src/services/moderation/views.ts +278 -329
  160. package/src/services/types.ts +4 -0
  161. package/src/services/util/notification.ts +70 -0
  162. package/src/util/debug.ts +2 -2
  163. package/src/util/retry.ts +1 -44
  164. package/tests/__snapshots__/feed-generation.test.ts.snap +322 -6
  165. package/tests/__snapshots__/indexing.test.ts.snap +0 -6
  166. package/tests/admin/__snapshots__/get-record.test.ts.snap +30 -132
  167. package/tests/admin/__snapshots__/get-repo.test.ts.snap +14 -60
  168. package/tests/admin/__snapshots__/moderation-events.test.ts.snap +146 -0
  169. package/tests/admin/__snapshots__/moderation-statuses.test.ts.snap +64 -0
  170. package/tests/admin/__snapshots__/moderation.test.ts.snap +0 -125
  171. package/tests/admin/get-record.test.ts +5 -9
  172. package/tests/admin/get-repo.test.ts +10 -12
  173. package/tests/admin/moderation-events.test.ts +221 -0
  174. package/tests/admin/moderation-statuses.test.ts +145 -0
  175. package/tests/admin/moderation.test.ts +512 -860
  176. package/tests/admin/repo-search.test.ts +3 -3
  177. package/tests/algos/hot-classic.test.ts +1 -2
  178. package/tests/auth.test.ts +1 -1
  179. package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -1
  180. package/tests/auto-moderator/labeler.test.ts +19 -20
  181. package/tests/auto-moderator/takedowns.test.ts +61 -28
  182. package/tests/blob-resolver.test.ts +4 -2
  183. package/tests/daemon.test.ts +191 -0
  184. package/tests/did-cache.test.ts +20 -5
  185. package/tests/feed-generation.test.ts +57 -9
  186. package/tests/handle-invalidation.test.ts +1 -5
  187. package/tests/indexing.test.ts +20 -13
  188. package/tests/redis-cache.test.ts +231 -0
  189. package/tests/seeds/basic.ts +3 -0
  190. package/tests/subscription/repo.test.ts +4 -7
  191. package/tests/views/__snapshots__/block-lists.test.ts.snap +3 -9
  192. package/tests/views/__snapshots__/blocks.test.ts.snap +0 -9
  193. package/tests/views/__snapshots__/mute-lists.test.ts.snap +5 -5
  194. package/tests/views/__snapshots__/mutes.test.ts.snap +0 -3
  195. package/tests/views/__snapshots__/thread.test.ts.snap +0 -30
  196. package/tests/views/actor-search.test.ts +2 -3
  197. package/tests/views/author-feed.test.ts +42 -36
  198. package/tests/views/follows.test.ts +40 -35
  199. package/tests/views/list-feed.test.ts +17 -9
  200. package/tests/views/notifications.test.ts +13 -9
  201. package/tests/views/profile.test.ts +20 -19
  202. package/tests/views/thread.test.ts +117 -94
  203. package/tests/views/threadgating.test.ts +89 -19
  204. package/tests/views/timeline.test.ts +21 -13
  205. package/dist/api/com/atproto/admin/resolveModerationReports.d.ts +0 -3
  206. package/dist/api/com/atproto/admin/reverseModerationAction.d.ts +0 -3
  207. package/dist/api/com/atproto/admin/takeModerationAction.d.ts +0 -3
  208. package/dist/db/tables/did-cache.d.ts +0 -10
  209. package/dist/feed-gen/best-of-follows.d.ts +0 -29
  210. package/dist/feed-gen/whats-hot.d.ts +0 -29
  211. package/dist/feed-gen/with-friends.d.ts +0 -3
  212. package/dist/label-cache.d.ts +0 -19
  213. package/src/api/com/atproto/admin/getModerationAction.ts +0 -44
  214. package/src/api/com/atproto/admin/getModerationReport.ts +0 -43
  215. package/src/api/com/atproto/admin/resolveModerationReports.ts +0 -24
  216. package/src/api/com/atproto/admin/reverseModerationAction.ts +0 -115
  217. package/src/api/com/atproto/admin/takeModerationAction.ts +0 -156
  218. package/src/db/tables/did-cache.ts +0 -13
  219. package/src/feed-gen/best-of-follows.ts +0 -74
  220. package/src/feed-gen/whats-hot.ts +0 -101
  221. package/src/feed-gen/with-friends.ts +0 -39
  222. package/src/label-cache.ts +0 -90
  223. package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +0 -172
  224. package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +0 -178
  225. package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +0 -177
  226. package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +0 -307
  227. package/tests/admin/get-moderation-action.test.ts +0 -100
  228. package/tests/admin/get-moderation-actions.test.ts +0 -164
  229. package/tests/admin/get-moderation-report.test.ts +0 -100
  230. package/tests/admin/get-moderation-reports.test.ts +0 -332
  231. package/tests/algos/whats-hot.test.ts +0 -118
  232. package/tests/algos/with-friends.test.ts +0 -145
  233. /package/dist/api/com/atproto/admin/{getModerationAction.d.ts → emitModerationEvent.d.ts} +0 -0
  234. /package/dist/api/com/atproto/admin/{getModerationActions.d.ts → getModerationEvent.d.ts} +0 -0
  235. /package/dist/api/com/atproto/admin/{getModerationReport.d.ts → queryModerationEvents.d.ts} +0 -0
  236. /package/dist/api/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +0 -0
@@ -48,6 +48,7 @@ export function validatePostView(v: unknown): ValidationResult {
48
48
  export interface ViewerState {
49
49
  repost?: string
50
50
  like?: string
51
+ replyDisabled?: boolean
51
52
  [k: string]: unknown
52
53
  }
53
54
 
@@ -137,7 +138,6 @@ export interface ThreadViewPost {
137
138
  | BlockedPost
138
139
  | { $type: string; [k: string]: unknown }
139
140
  )[]
140
- viewer?: ViewerThreadState
141
141
  [k: string]: unknown
142
142
  }
143
143
 
@@ -208,23 +208,6 @@ export function validateBlockedAuthor(v: unknown): ValidationResult {
208
208
  return lexicons.validate('app.bsky.feed.defs#blockedAuthor', v)
209
209
  }
210
210
 
211
- export interface ViewerThreadState {
212
- canReply?: boolean
213
- [k: string]: unknown
214
- }
215
-
216
- export function isViewerThreadState(v: unknown): v is ViewerThreadState {
217
- return (
218
- isObj(v) &&
219
- hasProp(v, '$type') &&
220
- v.$type === 'app.bsky.feed.defs#viewerThreadState'
221
- )
222
- }
223
-
224
- export function validateViewerThreadState(v: unknown): ValidationResult {
225
- return lexicons.validate('app.bsky.feed.defs#viewerThreadState', v)
226
- }
227
-
228
211
  export interface GeneratorView {
229
212
  uri: string
230
213
  cid: string
@@ -58,6 +58,7 @@ export function validateListView(v: unknown): ValidationResult {
58
58
  }
59
59
 
60
60
  export interface ListItemView {
61
+ uri: string
61
62
  subject: AppBskyActorDefs.ProfileView
62
63
  [k: string]: unknown
63
64
  }
@@ -28,43 +28,55 @@ export function validateStatusAttr(v: unknown): ValidationResult {
28
28
  return lexicons.validate('com.atproto.admin.defs#statusAttr', v)
29
29
  }
30
30
 
31
- export interface ActionView {
31
+ export interface ModEventView {
32
32
  id: number
33
- action: ActionType
34
- /** Indicates how long this action is meant to be in effect before automatically expiring. */
35
- durationInHours?: number
33
+ event:
34
+ | ModEventTakedown
35
+ | ModEventReverseTakedown
36
+ | ModEventComment
37
+ | ModEventReport
38
+ | ModEventLabel
39
+ | ModEventAcknowledge
40
+ | ModEventEscalate
41
+ | ModEventMute
42
+ | ModEventEmail
43
+ | { $type: string; [k: string]: unknown }
36
44
  subject:
37
45
  | RepoRef
38
46
  | ComAtprotoRepoStrongRef.Main
39
47
  | { $type: string; [k: string]: unknown }
40
48
  subjectBlobCids: string[]
41
- createLabelVals?: string[]
42
- negateLabelVals?: string[]
43
- reason: string
44
49
  createdBy: string
45
50
  createdAt: string
46
- reversal?: ActionReversal
47
- resolvedReportIds: number[]
51
+ creatorHandle?: string
52
+ subjectHandle?: string
48
53
  [k: string]: unknown
49
54
  }
50
55
 
51
- export function isActionView(v: unknown): v is ActionView {
56
+ export function isModEventView(v: unknown): v is ModEventView {
52
57
  return (
53
58
  isObj(v) &&
54
59
  hasProp(v, '$type') &&
55
- v.$type === 'com.atproto.admin.defs#actionView'
60
+ v.$type === 'com.atproto.admin.defs#modEventView'
56
61
  )
57
62
  }
58
63
 
59
- export function validateActionView(v: unknown): ValidationResult {
60
- return lexicons.validate('com.atproto.admin.defs#actionView', v)
64
+ export function validateModEventView(v: unknown): ValidationResult {
65
+ return lexicons.validate('com.atproto.admin.defs#modEventView', v)
61
66
  }
62
67
 
63
- export interface ActionViewDetail {
68
+ export interface ModEventViewDetail {
64
69
  id: number
65
- action: ActionType
66
- /** Indicates how long this action is meant to be in effect before automatically expiring. */
67
- durationInHours?: number
70
+ event:
71
+ | ModEventTakedown
72
+ | ModEventReverseTakedown
73
+ | ModEventComment
74
+ | ModEventReport
75
+ | ModEventLabel
76
+ | ModEventAcknowledge
77
+ | ModEventEscalate
78
+ | ModEventMute
79
+ | { $type: string; [k: string]: unknown }
68
80
  subject:
69
81
  | RepoView
70
82
  | RepoViewNotFound
@@ -72,123 +84,100 @@ export interface ActionViewDetail {
72
84
  | RecordViewNotFound
73
85
  | { $type: string; [k: string]: unknown }
74
86
  subjectBlobs: BlobView[]
75
- createLabelVals?: string[]
76
- negateLabelVals?: string[]
77
- reason: string
78
87
  createdBy: string
79
88
  createdAt: string
80
- reversal?: ActionReversal
81
- resolvedReports: ReportView[]
82
89
  [k: string]: unknown
83
90
  }
84
91
 
85
- export function isActionViewDetail(v: unknown): v is ActionViewDetail {
92
+ export function isModEventViewDetail(v: unknown): v is ModEventViewDetail {
86
93
  return (
87
94
  isObj(v) &&
88
95
  hasProp(v, '$type') &&
89
- v.$type === 'com.atproto.admin.defs#actionViewDetail'
96
+ v.$type === 'com.atproto.admin.defs#modEventViewDetail'
90
97
  )
91
98
  }
92
99
 
93
- export function validateActionViewDetail(v: unknown): ValidationResult {
94
- return lexicons.validate('com.atproto.admin.defs#actionViewDetail', v)
100
+ export function validateModEventViewDetail(v: unknown): ValidationResult {
101
+ return lexicons.validate('com.atproto.admin.defs#modEventViewDetail', v)
95
102
  }
96
103
 
97
- export interface ActionViewCurrent {
104
+ export interface ReportView {
98
105
  id: number
99
- action: ActionType
100
- /** Indicates how long this action is meant to be in effect before automatically expiring. */
101
- durationInHours?: number
102
- [k: string]: unknown
103
- }
104
-
105
- export function isActionViewCurrent(v: unknown): v is ActionViewCurrent {
106
- return (
107
- isObj(v) &&
108
- hasProp(v, '$type') &&
109
- v.$type === 'com.atproto.admin.defs#actionViewCurrent'
110
- )
111
- }
112
-
113
- export function validateActionViewCurrent(v: unknown): ValidationResult {
114
- return lexicons.validate('com.atproto.admin.defs#actionViewCurrent', v)
115
- }
116
-
117
- export interface ActionReversal {
118
- reason: string
119
- createdBy: string
106
+ reasonType: ComAtprotoModerationDefs.ReasonType
107
+ comment?: string
108
+ subjectRepoHandle?: string
109
+ subject:
110
+ | RepoRef
111
+ | ComAtprotoRepoStrongRef.Main
112
+ | { $type: string; [k: string]: unknown }
113
+ reportedBy: string
120
114
  createdAt: string
115
+ resolvedByActionIds: number[]
121
116
  [k: string]: unknown
122
117
  }
123
118
 
124
- export function isActionReversal(v: unknown): v is ActionReversal {
119
+ export function isReportView(v: unknown): v is ReportView {
125
120
  return (
126
121
  isObj(v) &&
127
122
  hasProp(v, '$type') &&
128
- v.$type === 'com.atproto.admin.defs#actionReversal'
123
+ v.$type === 'com.atproto.admin.defs#reportView'
129
124
  )
130
125
  }
131
126
 
132
- export function validateActionReversal(v: unknown): ValidationResult {
133
- return lexicons.validate('com.atproto.admin.defs#actionReversal', v)
127
+ export function validateReportView(v: unknown): ValidationResult {
128
+ return lexicons.validate('com.atproto.admin.defs#reportView', v)
134
129
  }
135
130
 
136
- export type ActionType =
137
- | 'lex:com.atproto.admin.defs#takedown'
138
- | 'lex:com.atproto.admin.defs#flag'
139
- | 'lex:com.atproto.admin.defs#acknowledge'
140
- | 'lex:com.atproto.admin.defs#escalate'
141
- | (string & {})
142
-
143
- /** Moderation action type: Takedown. Indicates that content should not be served by the PDS. */
144
- export const TAKEDOWN = 'com.atproto.admin.defs#takedown'
145
- /** Moderation action type: Flag. Indicates that the content was reviewed and considered to violate PDS rules, but may still be served. */
146
- export const FLAG = 'com.atproto.admin.defs#flag'
147
- /** Moderation action type: Acknowledge. Indicates that the content was reviewed and not considered to violate PDS rules. */
148
- export const ACKNOWLEDGE = 'com.atproto.admin.defs#acknowledge'
149
- /** Moderation action type: Escalate. Indicates that the content has been flagged for additional review. */
150
- export const ESCALATE = 'com.atproto.admin.defs#escalate'
151
-
152
- export interface ReportView {
131
+ export interface SubjectStatusView {
153
132
  id: number
154
- reasonType: ComAtprotoModerationDefs.ReasonType
155
- reason?: string
156
- subjectRepoHandle?: string
157
133
  subject:
158
134
  | RepoRef
159
135
  | ComAtprotoRepoStrongRef.Main
160
136
  | { $type: string; [k: string]: unknown }
161
- reportedBy: string
137
+ subjectBlobCids?: string[]
138
+ subjectRepoHandle?: string
139
+ /** Timestamp referencing when the last update was made to the moderation status of the subject */
140
+ updatedAt: string
141
+ /** Timestamp referencing the first moderation status impacting event was emitted on the subject */
162
142
  createdAt: string
163
- resolvedByActionIds: number[]
143
+ reviewState: SubjectReviewState
144
+ /** Sticky comment on the subject. */
145
+ comment?: string
146
+ muteUntil?: string
147
+ lastReviewedBy?: string
148
+ lastReviewedAt?: string
149
+ lastReportedAt?: string
150
+ takendown?: boolean
151
+ suspendUntil?: string
164
152
  [k: string]: unknown
165
153
  }
166
154
 
167
- export function isReportView(v: unknown): v is ReportView {
155
+ export function isSubjectStatusView(v: unknown): v is SubjectStatusView {
168
156
  return (
169
157
  isObj(v) &&
170
158
  hasProp(v, '$type') &&
171
- v.$type === 'com.atproto.admin.defs#reportView'
159
+ v.$type === 'com.atproto.admin.defs#subjectStatusView'
172
160
  )
173
161
  }
174
162
 
175
- export function validateReportView(v: unknown): ValidationResult {
176
- return lexicons.validate('com.atproto.admin.defs#reportView', v)
163
+ export function validateSubjectStatusView(v: unknown): ValidationResult {
164
+ return lexicons.validate('com.atproto.admin.defs#subjectStatusView', v)
177
165
  }
178
166
 
179
167
  export interface ReportViewDetail {
180
168
  id: number
181
169
  reasonType: ComAtprotoModerationDefs.ReasonType
182
- reason?: string
170
+ comment?: string
183
171
  subject:
184
172
  | RepoView
185
173
  | RepoViewNotFound
186
174
  | RecordView
187
175
  | RecordViewNotFound
188
176
  | { $type: string; [k: string]: unknown }
177
+ subjectStatus?: SubjectStatusView
189
178
  reportedBy: string
190
179
  createdAt: string
191
- resolvedByActions: ActionView[]
180
+ resolvedByActions: ModEventView[]
192
181
  [k: string]: unknown
193
182
  }
194
183
 
@@ -400,7 +389,7 @@ export function validateRecordViewNotFound(v: unknown): ValidationResult {
400
389
  }
401
390
 
402
391
  export interface Moderation {
403
- currentAction?: ActionViewCurrent
392
+ subjectStatus?: SubjectStatusView
404
393
  [k: string]: unknown
405
394
  }
406
395
 
@@ -417,9 +406,7 @@ export function validateModeration(v: unknown): ValidationResult {
417
406
  }
418
407
 
419
408
  export interface ModerationDetail {
420
- currentAction?: ActionViewCurrent
421
- actions: ActionView[]
422
- reports: ReportView[]
409
+ subjectStatus?: SubjectStatusView
423
410
  [k: string]: unknown
424
411
  }
425
412
 
@@ -496,3 +483,208 @@ export function isVideoDetails(v: unknown): v is VideoDetails {
496
483
  export function validateVideoDetails(v: unknown): ValidationResult {
497
484
  return lexicons.validate('com.atproto.admin.defs#videoDetails', v)
498
485
  }
486
+
487
+ export type SubjectReviewState =
488
+ | 'lex:com.atproto.admin.defs#reviewOpen'
489
+ | 'lex:com.atproto.admin.defs#reviewEscalated'
490
+ | 'lex:com.atproto.admin.defs#reviewClosed'
491
+ | (string & {})
492
+
493
+ /** Moderator review status of a subject: Open. Indicates that the subject needs to be reviewed by a moderator */
494
+ export const REVIEWOPEN = 'com.atproto.admin.defs#reviewOpen'
495
+ /** Moderator review status of a subject: Escalated. Indicates that the subject was escalated for review by a moderator */
496
+ export const REVIEWESCALATED = 'com.atproto.admin.defs#reviewEscalated'
497
+ /** Moderator review status of a subject: Closed. Indicates that the subject was already reviewed and resolved by a moderator */
498
+ export const REVIEWCLOSED = 'com.atproto.admin.defs#reviewClosed'
499
+
500
+ /** Take down a subject permanently or temporarily */
501
+ export interface ModEventTakedown {
502
+ comment?: string
503
+ /** Indicates how long the takedown should be in effect before automatically expiring. */
504
+ durationInHours?: number
505
+ [k: string]: unknown
506
+ }
507
+
508
+ export function isModEventTakedown(v: unknown): v is ModEventTakedown {
509
+ return (
510
+ isObj(v) &&
511
+ hasProp(v, '$type') &&
512
+ v.$type === 'com.atproto.admin.defs#modEventTakedown'
513
+ )
514
+ }
515
+
516
+ export function validateModEventTakedown(v: unknown): ValidationResult {
517
+ return lexicons.validate('com.atproto.admin.defs#modEventTakedown', v)
518
+ }
519
+
520
+ /** Revert take down action on a subject */
521
+ export interface ModEventReverseTakedown {
522
+ /** Describe reasoning behind the reversal. */
523
+ comment?: string
524
+ [k: string]: unknown
525
+ }
526
+
527
+ export function isModEventReverseTakedown(
528
+ v: unknown,
529
+ ): v is ModEventReverseTakedown {
530
+ return (
531
+ isObj(v) &&
532
+ hasProp(v, '$type') &&
533
+ v.$type === 'com.atproto.admin.defs#modEventReverseTakedown'
534
+ )
535
+ }
536
+
537
+ export function validateModEventReverseTakedown(v: unknown): ValidationResult {
538
+ return lexicons.validate('com.atproto.admin.defs#modEventReverseTakedown', v)
539
+ }
540
+
541
+ /** Add a comment to a subject */
542
+ export interface ModEventComment {
543
+ comment: string
544
+ /** Make the comment persistent on the subject */
545
+ sticky?: boolean
546
+ [k: string]: unknown
547
+ }
548
+
549
+ export function isModEventComment(v: unknown): v is ModEventComment {
550
+ return (
551
+ isObj(v) &&
552
+ hasProp(v, '$type') &&
553
+ v.$type === 'com.atproto.admin.defs#modEventComment'
554
+ )
555
+ }
556
+
557
+ export function validateModEventComment(v: unknown): ValidationResult {
558
+ return lexicons.validate('com.atproto.admin.defs#modEventComment', v)
559
+ }
560
+
561
+ /** Report a subject */
562
+ export interface ModEventReport {
563
+ comment?: string
564
+ reportType: ComAtprotoModerationDefs.ReasonType
565
+ [k: string]: unknown
566
+ }
567
+
568
+ export function isModEventReport(v: unknown): v is ModEventReport {
569
+ return (
570
+ isObj(v) &&
571
+ hasProp(v, '$type') &&
572
+ v.$type === 'com.atproto.admin.defs#modEventReport'
573
+ )
574
+ }
575
+
576
+ export function validateModEventReport(v: unknown): ValidationResult {
577
+ return lexicons.validate('com.atproto.admin.defs#modEventReport', v)
578
+ }
579
+
580
+ /** Apply/Negate labels on a subject */
581
+ export interface ModEventLabel {
582
+ comment?: string
583
+ createLabelVals: string[]
584
+ negateLabelVals: string[]
585
+ [k: string]: unknown
586
+ }
587
+
588
+ export function isModEventLabel(v: unknown): v is ModEventLabel {
589
+ return (
590
+ isObj(v) &&
591
+ hasProp(v, '$type') &&
592
+ v.$type === 'com.atproto.admin.defs#modEventLabel'
593
+ )
594
+ }
595
+
596
+ export function validateModEventLabel(v: unknown): ValidationResult {
597
+ return lexicons.validate('com.atproto.admin.defs#modEventLabel', v)
598
+ }
599
+
600
+ export interface ModEventAcknowledge {
601
+ comment?: string
602
+ [k: string]: unknown
603
+ }
604
+
605
+ export function isModEventAcknowledge(v: unknown): v is ModEventAcknowledge {
606
+ return (
607
+ isObj(v) &&
608
+ hasProp(v, '$type') &&
609
+ v.$type === 'com.atproto.admin.defs#modEventAcknowledge'
610
+ )
611
+ }
612
+
613
+ export function validateModEventAcknowledge(v: unknown): ValidationResult {
614
+ return lexicons.validate('com.atproto.admin.defs#modEventAcknowledge', v)
615
+ }
616
+
617
+ export interface ModEventEscalate {
618
+ comment?: string
619
+ [k: string]: unknown
620
+ }
621
+
622
+ export function isModEventEscalate(v: unknown): v is ModEventEscalate {
623
+ return (
624
+ isObj(v) &&
625
+ hasProp(v, '$type') &&
626
+ v.$type === 'com.atproto.admin.defs#modEventEscalate'
627
+ )
628
+ }
629
+
630
+ export function validateModEventEscalate(v: unknown): ValidationResult {
631
+ return lexicons.validate('com.atproto.admin.defs#modEventEscalate', v)
632
+ }
633
+
634
+ /** Mute incoming reports on a subject */
635
+ export interface ModEventMute {
636
+ comment?: string
637
+ /** Indicates how long the subject should remain muted. */
638
+ durationInHours: number
639
+ [k: string]: unknown
640
+ }
641
+
642
+ export function isModEventMute(v: unknown): v is ModEventMute {
643
+ return (
644
+ isObj(v) &&
645
+ hasProp(v, '$type') &&
646
+ v.$type === 'com.atproto.admin.defs#modEventMute'
647
+ )
648
+ }
649
+
650
+ export function validateModEventMute(v: unknown): ValidationResult {
651
+ return lexicons.validate('com.atproto.admin.defs#modEventMute', v)
652
+ }
653
+
654
+ /** Unmute action on a subject */
655
+ export interface ModEventUnmute {
656
+ /** Describe reasoning behind the reversal. */
657
+ comment?: string
658
+ [k: string]: unknown
659
+ }
660
+
661
+ export function isModEventUnmute(v: unknown): v is ModEventUnmute {
662
+ return (
663
+ isObj(v) &&
664
+ hasProp(v, '$type') &&
665
+ v.$type === 'com.atproto.admin.defs#modEventUnmute'
666
+ )
667
+ }
668
+
669
+ export function validateModEventUnmute(v: unknown): ValidationResult {
670
+ return lexicons.validate('com.atproto.admin.defs#modEventUnmute', v)
671
+ }
672
+
673
+ /** Keep a log of outgoing email to a user */
674
+ export interface ModEventEmail {
675
+ /** The subject line of the email sent to the user. */
676
+ subjectLine: string
677
+ [k: string]: unknown
678
+ }
679
+
680
+ export function isModEventEmail(v: unknown): v is ModEventEmail {
681
+ return (
682
+ isObj(v) &&
683
+ hasProp(v, '$type') &&
684
+ v.$type === 'com.atproto.admin.defs#modEventEmail'
685
+ )
686
+ }
687
+
688
+ export function validateModEventEmail(v: unknown): ValidationResult {
689
+ return lexicons.validate('com.atproto.admin.defs#modEventEmail', v)
690
+ }
@@ -7,36 +7,25 @@ import { lexicons } from '../../../../lexicons'
7
7
  import { isObj, hasProp } from '../../../../util'
8
8
  import { CID } from 'multiformats/cid'
9
9
  import { HandlerAuth } from '@atproto/xrpc-server'
10
- import * as ComAtprotoAdminDefs from './defs'
11
10
 
12
11
  export interface QueryParams {}
13
12
 
14
13
  export interface InputSchema {
15
- actionId: number
16
- reportIds: number[]
17
- createdBy: string
14
+ did: string
18
15
  [k: string]: unknown
19
16
  }
20
17
 
21
- export type OutputSchema = ComAtprotoAdminDefs.ActionView
22
-
23
18
  export interface HandlerInput {
24
19
  encoding: 'application/json'
25
20
  body: InputSchema
26
21
  }
27
22
 
28
- export interface HandlerSuccess {
29
- encoding: 'application/json'
30
- body: OutputSchema
31
- headers?: { [key: string]: string }
32
- }
33
-
34
23
  export interface HandlerError {
35
24
  status: number
36
25
  message?: string
37
26
  }
38
27
 
39
- export type HandlerOutput = HandlerError | HandlerSuccess
28
+ export type HandlerOutput = HandlerError | void
40
29
  export type HandlerReqCtx<HA extends HandlerAuth = never> = {
41
30
  auth: HA
42
31
  params: QueryParams
@@ -13,26 +13,28 @@ import * as ComAtprotoRepoStrongRef from '../repo/strongRef'
13
13
  export interface QueryParams {}
14
14
 
15
15
  export interface InputSchema {
16
- action:
17
- | 'com.atproto.admin.defs#takedown'
18
- | 'com.atproto.admin.defs#flag'
19
- | 'com.atproto.admin.defs#acknowledge'
20
- | (string & {})
16
+ event:
17
+ | ComAtprotoAdminDefs.ModEventTakedown
18
+ | ComAtprotoAdminDefs.ModEventAcknowledge
19
+ | ComAtprotoAdminDefs.ModEventEscalate
20
+ | ComAtprotoAdminDefs.ModEventComment
21
+ | ComAtprotoAdminDefs.ModEventLabel
22
+ | ComAtprotoAdminDefs.ModEventReport
23
+ | ComAtprotoAdminDefs.ModEventMute
24
+ | ComAtprotoAdminDefs.ModEventReverseTakedown
25
+ | ComAtprotoAdminDefs.ModEventUnmute
26
+ | ComAtprotoAdminDefs.ModEventEmail
27
+ | { $type: string; [k: string]: unknown }
21
28
  subject:
22
29
  | ComAtprotoAdminDefs.RepoRef
23
30
  | ComAtprotoRepoStrongRef.Main
24
31
  | { $type: string; [k: string]: unknown }
25
32
  subjectBlobCids?: string[]
26
- createLabelVals?: string[]
27
- negateLabelVals?: string[]
28
- reason: string
29
- /** Indicates how long this action is meant to be in effect before automatically expiring. */
30
- durationInHours?: number
31
33
  createdBy: string
32
34
  [k: string]: unknown
33
35
  }
34
36
 
35
- export type OutputSchema = ComAtprotoAdminDefs.ActionView
37
+ export type OutputSchema = ComAtprotoAdminDefs.ModEventView
36
38
 
37
39
  export interface HandlerInput {
38
40
  encoding: 'application/json'
@@ -14,7 +14,7 @@ export interface QueryParams {
14
14
  }
15
15
 
16
16
  export type InputSchema = undefined
17
- export type OutputSchema = ComAtprotoAdminDefs.ReportViewDetail
17
+ export type OutputSchema = ComAtprotoAdminDefs.ModEventViewDetail
18
18
  export type HandlerInput = undefined
19
19
 
20
20
  export interface HandlerSuccess {
@@ -10,7 +10,14 @@ import { HandlerAuth } from '@atproto/xrpc-server'
10
10
  import * as ComAtprotoAdminDefs from './defs'
11
11
 
12
12
  export interface QueryParams {
13
+ /** The types of events (fully qualified string in the format of com.atproto.admin#modEvent<name>) to filter by. If not specified, all events are returned. */
14
+ types?: string[]
15
+ createdBy?: string
16
+ /** Sort direction for the events. Defaults to descending order of created at timestamp. */
17
+ sortDirection: 'asc' | 'desc'
13
18
  subject?: string
19
+ /** If true, events on all record types (posts, lists, profile etc.) owned by the did are returned */
20
+ includeAllUserRecords: boolean
14
21
  limit: number
15
22
  cursor?: string
16
23
  }
@@ -19,7 +26,7 @@ export type InputSchema = undefined
19
26
 
20
27
  export interface OutputSchema {
21
28
  cursor?: string
22
- actions: ComAtprotoAdminDefs.ActionView[]
29
+ events: ComAtprotoAdminDefs.ModEventView[]
23
30
  [k: string]: unknown
24
31
  }
25
32
 
@@ -11,29 +11,36 @@ import * as ComAtprotoAdminDefs from './defs'
11
11
 
12
12
  export interface QueryParams {
13
13
  subject?: string
14
+ /** Search subjects by keyword from comments */
15
+ comment?: string
16
+ /** Search subjects reported after a given timestamp */
17
+ reportedAfter?: string
18
+ /** Search subjects reported before a given timestamp */
19
+ reportedBefore?: string
20
+ /** Search subjects reviewed after a given timestamp */
21
+ reviewedAfter?: string
22
+ /** Search subjects reviewed before a given timestamp */
23
+ reviewedBefore?: string
24
+ /** By default, we don't include muted subjects in the results. Set this to true to include them. */
25
+ includeMuted?: boolean
26
+ /** Specify when fetching subjects in a certain state */
27
+ reviewState?: string
14
28
  ignoreSubjects?: string[]
15
- /** Get all reports that were actioned by a specific moderator. */
16
- actionedBy?: string
17
- /** Filter reports made by one or more DIDs. */
18
- reporters?: string[]
19
- resolved?: boolean
20
- actionType?:
21
- | 'com.atproto.admin.defs#takedown'
22
- | 'com.atproto.admin.defs#flag'
23
- | 'com.atproto.admin.defs#acknowledge'
24
- | 'com.atproto.admin.defs#escalate'
25
- | (string & {})
29
+ /** Get all subject statuses that were reviewed by a specific moderator */
30
+ lastReviewedBy?: string
31
+ sortField: 'lastReviewedAt' | 'lastReportedAt'
32
+ sortDirection: 'asc' | 'desc'
33
+ /** Get subjects that were taken down */
34
+ takendown?: boolean
26
35
  limit: number
27
36
  cursor?: string
28
- /** Reverse the order of the returned records. When true, returns reports in chronological order. */
29
- reverse?: boolean
30
37
  }
31
38
 
32
39
  export type InputSchema = undefined
33
40
 
34
41
  export interface OutputSchema {
35
42
  cursor?: string
36
- reports: ComAtprotoAdminDefs.ReportView[]
43
+ subjectStatuses: ComAtprotoAdminDefs.SubjectStatusView[]
37
44
  [k: string]: unknown
38
45
  }
39
46
 
@@ -14,6 +14,7 @@ export interface InputSchema {
14
14
  recipientDid: string
15
15
  content: string
16
16
  subject?: string
17
+ senderDid: string
17
18
  [k: string]: unknown
18
19
  }
19
20