@atproto/ozone 0.1.14 → 0.1.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 (206) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/api/chat/getActorMetadata.d.ts +4 -0
  3. package/dist/api/chat/getActorMetadata.d.ts.map +1 -0
  4. package/dist/api/chat/getActorMetadata.js +20 -0
  5. package/dist/api/chat/getActorMetadata.js.map +1 -0
  6. package/dist/api/chat/getMessageContext.d.ts +4 -0
  7. package/dist/api/chat/getMessageContext.d.ts.map +1 -0
  8. package/dist/api/chat/getMessageContext.js +34 -0
  9. package/dist/api/chat/getMessageContext.js.map +1 -0
  10. package/dist/api/chat/index.d.ts +4 -0
  11. package/dist/api/chat/index.d.ts.map +1 -0
  12. package/dist/api/chat/index.js +14 -0
  13. package/dist/api/chat/index.js.map +1 -0
  14. package/dist/api/index.d.ts.map +1 -1
  15. package/dist/api/index.js +2 -0
  16. package/dist/api/index.js.map +1 -1
  17. package/dist/api/moderation/emitEvent.d.ts.map +1 -1
  18. package/dist/api/moderation/emitEvent.js +22 -0
  19. package/dist/api/moderation/emitEvent.js.map +1 -1
  20. package/dist/api/moderation/getRecord.d.ts.map +1 -1
  21. package/dist/api/moderation/getRecord.js +3 -2
  22. package/dist/api/moderation/getRecord.js.map +1 -1
  23. package/dist/api/moderation/getRepo.d.ts.map +1 -1
  24. package/dist/api/moderation/getRepo.js +3 -2
  25. package/dist/api/moderation/getRepo.js.map +1 -1
  26. package/dist/api/proxied.d.ts.map +1 -1
  27. package/dist/api/proxied.js +10 -0
  28. package/dist/api/proxied.js.map +1 -1
  29. package/dist/api/util.js +1 -0
  30. package/dist/api/util.js.map +1 -1
  31. package/dist/config/config.d.ts +5 -0
  32. package/dist/config/config.d.ts.map +1 -1
  33. package/dist/config/config.js +9 -0
  34. package/dist/config/config.js.map +1 -1
  35. package/dist/config/env.d.ts +2 -0
  36. package/dist/config/env.d.ts.map +1 -1
  37. package/dist/config/env.js +2 -0
  38. package/dist/config/env.js.map +1 -1
  39. package/dist/context.d.ts +10 -0
  40. package/dist/context.d.ts.map +1 -1
  41. package/dist/context.js +26 -0
  42. package/dist/context.js.map +1 -1
  43. package/dist/db/migrations/20240506T225055595Z-message-subject.d.ts +4 -0
  44. package/dist/db/migrations/20240506T225055595Z-message-subject.d.ts.map +1 -0
  45. package/dist/db/migrations/20240506T225055595Z-message-subject.js +24 -0
  46. package/dist/db/migrations/20240506T225055595Z-message-subject.js.map +1 -0
  47. package/dist/db/migrations/index.d.ts +1 -0
  48. package/dist/db/migrations/index.d.ts.map +1 -1
  49. package/dist/db/migrations/index.js +2 -1
  50. package/dist/db/migrations/index.js.map +1 -1
  51. package/dist/db/schema/moderation_event.d.ts +2 -1
  52. package/dist/db/schema/moderation_event.d.ts.map +1 -1
  53. package/dist/lexicon/index.d.ts +59 -0
  54. package/dist/lexicon/index.d.ts.map +1 -1
  55. package/dist/lexicon/index.js +164 -1
  56. package/dist/lexicon/index.js.map +1 -1
  57. package/dist/lexicon/lexicons.d.ts +898 -0
  58. package/dist/lexicon/lexicons.d.ts.map +1 -1
  59. package/dist/lexicon/lexicons.js +924 -0
  60. package/dist/lexicon/lexicons.js.map +1 -1
  61. package/dist/lexicon/types/chat/bsky/actor/declaration.d.ts +11 -0
  62. package/dist/lexicon/types/chat/bsky/actor/declaration.d.ts.map +1 -0
  63. package/dist/lexicon/types/chat/bsky/actor/declaration.js +17 -0
  64. package/dist/lexicon/types/chat/bsky/actor/declaration.js.map +1 -0
  65. package/dist/lexicon/types/chat/bsky/actor/defs.d.ts +21 -0
  66. package/dist/lexicon/types/chat/bsky/actor/defs.d.ts.map +1 -0
  67. package/dist/lexicon/types/chat/bsky/actor/defs.js +16 -0
  68. package/dist/lexicon/types/chat/bsky/actor/defs.js.map +1 -0
  69. package/dist/lexicon/types/chat/bsky/actor/deleteAccount.d.ts +33 -0
  70. package/dist/lexicon/types/chat/bsky/actor/deleteAccount.d.ts.map +1 -0
  71. package/dist/lexicon/types/chat/bsky/actor/deleteAccount.js +3 -0
  72. package/dist/lexicon/types/chat/bsky/actor/deleteAccount.js.map +1 -0
  73. package/dist/lexicon/types/chat/bsky/actor/exportAccountData.d.ts +32 -0
  74. package/dist/lexicon/types/chat/bsky/actor/exportAccountData.d.ts.map +1 -0
  75. package/dist/lexicon/types/chat/bsky/actor/exportAccountData.js +3 -0
  76. package/dist/lexicon/types/chat/bsky/actor/exportAccountData.js.map +1 -0
  77. package/dist/lexicon/types/chat/bsky/convo/defs.d.ts +109 -0
  78. package/dist/lexicon/types/chat/bsky/convo/defs.d.ts.map +1 -0
  79. package/dist/lexicon/types/chat/bsky/convo/defs.js +106 -0
  80. package/dist/lexicon/types/chat/bsky/convo/defs.js.map +1 -0
  81. package/dist/lexicon/types/chat/bsky/convo/deleteMessageForSelf.d.ts +39 -0
  82. package/dist/lexicon/types/chat/bsky/convo/deleteMessageForSelf.d.ts.map +1 -0
  83. package/dist/lexicon/types/chat/bsky/convo/deleteMessageForSelf.js +3 -0
  84. package/dist/lexicon/types/chat/bsky/convo/deleteMessageForSelf.js.map +1 -0
  85. package/dist/lexicon/types/chat/bsky/convo/getConvo.d.ts +36 -0
  86. package/dist/lexicon/types/chat/bsky/convo/getConvo.d.ts.map +1 -0
  87. package/dist/lexicon/types/chat/bsky/convo/getConvo.js +3 -0
  88. package/dist/lexicon/types/chat/bsky/convo/getConvo.js.map +1 -0
  89. package/dist/lexicon/types/chat/bsky/convo/getConvoForMembers.d.ts +36 -0
  90. package/dist/lexicon/types/chat/bsky/convo/getConvoForMembers.d.ts.map +1 -0
  91. package/dist/lexicon/types/chat/bsky/convo/getConvoForMembers.js +3 -0
  92. package/dist/lexicon/types/chat/bsky/convo/getConvoForMembers.js.map +1 -0
  93. package/dist/lexicon/types/chat/bsky/convo/getLog.d.ts +40 -0
  94. package/dist/lexicon/types/chat/bsky/convo/getLog.d.ts.map +1 -0
  95. package/dist/lexicon/types/chat/bsky/convo/getLog.js +3 -0
  96. package/dist/lexicon/types/chat/bsky/convo/getLog.js.map +1 -0
  97. package/dist/lexicon/types/chat/bsky/convo/getMessages.d.ts +42 -0
  98. package/dist/lexicon/types/chat/bsky/convo/getMessages.d.ts.map +1 -0
  99. package/dist/lexicon/types/chat/bsky/convo/getMessages.js +3 -0
  100. package/dist/lexicon/types/chat/bsky/convo/getMessages.js.map +1 -0
  101. package/dist/lexicon/types/chat/bsky/convo/leaveConvo.d.ts +41 -0
  102. package/dist/lexicon/types/chat/bsky/convo/leaveConvo.d.ts.map +1 -0
  103. package/dist/lexicon/types/chat/bsky/convo/leaveConvo.js +3 -0
  104. package/dist/lexicon/types/chat/bsky/convo/leaveConvo.js.map +1 -0
  105. package/dist/lexicon/types/chat/bsky/convo/listConvos.d.ts +38 -0
  106. package/dist/lexicon/types/chat/bsky/convo/listConvos.d.ts.map +1 -0
  107. package/dist/lexicon/types/chat/bsky/convo/listConvos.js +3 -0
  108. package/dist/lexicon/types/chat/bsky/convo/listConvos.js.map +1 -0
  109. package/dist/lexicon/types/chat/bsky/convo/muteConvo.d.ts +41 -0
  110. package/dist/lexicon/types/chat/bsky/convo/muteConvo.d.ts.map +1 -0
  111. package/dist/lexicon/types/chat/bsky/convo/muteConvo.js +3 -0
  112. package/dist/lexicon/types/chat/bsky/convo/muteConvo.js.map +1 -0
  113. package/dist/lexicon/types/chat/bsky/convo/sendMessage.d.ts +39 -0
  114. package/dist/lexicon/types/chat/bsky/convo/sendMessage.d.ts.map +1 -0
  115. package/dist/lexicon/types/chat/bsky/convo/sendMessage.js +3 -0
  116. package/dist/lexicon/types/chat/bsky/convo/sendMessage.js.map +1 -0
  117. package/dist/lexicon/types/chat/bsky/convo/sendMessageBatch.d.ts +49 -0
  118. package/dist/lexicon/types/chat/bsky/convo/sendMessageBatch.d.ts.map +1 -0
  119. package/dist/lexicon/types/chat/bsky/convo/sendMessageBatch.js +16 -0
  120. package/dist/lexicon/types/chat/bsky/convo/sendMessageBatch.js.map +1 -0
  121. package/dist/lexicon/types/chat/bsky/convo/unmuteConvo.d.ts +41 -0
  122. package/dist/lexicon/types/chat/bsky/convo/unmuteConvo.d.ts.map +1 -0
  123. package/dist/lexicon/types/chat/bsky/convo/unmuteConvo.js +3 -0
  124. package/dist/lexicon/types/chat/bsky/convo/unmuteConvo.js.map +1 -0
  125. package/dist/lexicon/types/chat/bsky/convo/updateRead.d.ts +42 -0
  126. package/dist/lexicon/types/chat/bsky/convo/updateRead.d.ts.map +1 -0
  127. package/dist/lexicon/types/chat/bsky/convo/updateRead.js +3 -0
  128. package/dist/lexicon/types/chat/bsky/convo/updateRead.js.map +1 -0
  129. package/dist/lexicon/types/chat/bsky/moderation/getActorMetadata.d.ts +47 -0
  130. package/dist/lexicon/types/chat/bsky/moderation/getActorMetadata.d.ts.map +1 -0
  131. package/dist/lexicon/types/chat/bsky/moderation/getActorMetadata.js +16 -0
  132. package/dist/lexicon/types/chat/bsky/moderation/getActorMetadata.js.map +1 -0
  133. package/dist/lexicon/types/chat/bsky/moderation/getMessageContext.d.ts +43 -0
  134. package/dist/lexicon/types/chat/bsky/moderation/getMessageContext.d.ts.map +1 -0
  135. package/dist/lexicon/types/chat/bsky/moderation/getMessageContext.js +3 -0
  136. package/dist/lexicon/types/chat/bsky/moderation/getMessageContext.js.map +1 -0
  137. package/dist/lexicon/types/chat/bsky/moderation/updateActorAccess.d.ts +31 -0
  138. package/dist/lexicon/types/chat/bsky/moderation/updateActorAccess.d.ts.map +1 -0
  139. package/dist/lexicon/types/chat/bsky/moderation/updateActorAccess.js +3 -0
  140. package/dist/lexicon/types/chat/bsky/moderation/updateActorAccess.js.map +1 -0
  141. package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts +2 -1
  142. package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts.map +1 -1
  143. package/dist/lexicon/types/tools/ozone/moderation/defs.js.map +1 -1
  144. package/dist/mod-service/index.d.ts +2 -1
  145. package/dist/mod-service/index.d.ts.map +1 -1
  146. package/dist/mod-service/index.js +10 -2
  147. package/dist/mod-service/index.js.map +1 -1
  148. package/dist/mod-service/subject.d.ts +35 -2
  149. package/dist/mod-service/subject.d.ts.map +1 -1
  150. package/dist/mod-service/subject.js +85 -1
  151. package/dist/mod-service/subject.js.map +1 -1
  152. package/dist/mod-service/views.d.ts +5 -2
  153. package/dist/mod-service/views.d.ts.map +1 -1
  154. package/dist/mod-service/views.js +17 -6
  155. package/dist/mod-service/views.js.map +1 -1
  156. package/dist/util.d.ts +8 -0
  157. package/dist/util.d.ts.map +1 -1
  158. package/dist/util.js +41 -1
  159. package/dist/util.js.map +1 -1
  160. package/package.json +5 -4
  161. package/src/api/chat/getActorMetadata.ts +22 -0
  162. package/src/api/chat/getMessageContext.ts +39 -0
  163. package/src/api/chat/index.ts +10 -0
  164. package/src/api/index.ts +2 -0
  165. package/src/api/moderation/emitEvent.ts +31 -0
  166. package/src/api/moderation/getRecord.ts +3 -2
  167. package/src/api/moderation/getRepo.ts +3 -2
  168. package/src/api/proxied.ts +14 -0
  169. package/src/api/util.ts +1 -0
  170. package/src/config/config.ts +16 -0
  171. package/src/config/env.ts +4 -0
  172. package/src/context.ts +36 -1
  173. package/src/db/migrations/20240506T225055595Z-message-subject.ts +21 -0
  174. package/src/db/migrations/index.ts +1 -0
  175. package/src/db/schema/moderation_event.ts +5 -1
  176. package/src/lexicon/index.ts +254 -0
  177. package/src/lexicon/lexicons.ts +926 -0
  178. package/src/lexicon/types/chat/bsky/actor/declaration.ts +25 -0
  179. package/src/lexicon/types/chat/bsky/actor/defs.ts +34 -0
  180. package/src/lexicon/types/chat/bsky/actor/deleteAccount.ts +42 -0
  181. package/src/lexicon/types/chat/bsky/actor/exportAccountData.ts +38 -0
  182. package/src/lexicon/types/chat/bsky/convo/defs.ts +215 -0
  183. package/src/lexicon/types/chat/bsky/convo/deleteMessageForSelf.ts +48 -0
  184. package/src/lexicon/types/chat/bsky/convo/getConvo.ts +46 -0
  185. package/src/lexicon/types/chat/bsky/convo/getConvoForMembers.ts +46 -0
  186. package/src/lexicon/types/chat/bsky/convo/getLog.ts +53 -0
  187. package/src/lexicon/types/chat/bsky/convo/getMessages.ts +53 -0
  188. package/src/lexicon/types/chat/bsky/convo/leaveConvo.ts +50 -0
  189. package/src/lexicon/types/chat/bsky/convo/listConvos.ts +48 -0
  190. package/src/lexicon/types/chat/bsky/convo/muteConvo.ts +50 -0
  191. package/src/lexicon/types/chat/bsky/convo/sendMessage.ts +48 -0
  192. package/src/lexicon/types/chat/bsky/convo/sendMessageBatch.ts +68 -0
  193. package/src/lexicon/types/chat/bsky/convo/unmuteConvo.ts +50 -0
  194. package/src/lexicon/types/chat/bsky/convo/updateRead.ts +51 -0
  195. package/src/lexicon/types/chat/bsky/moderation/getActorMetadata.ts +67 -0
  196. package/src/lexicon/types/chat/bsky/moderation/getMessageContext.ts +54 -0
  197. package/src/lexicon/types/chat/bsky/moderation/updateActorAccess.ts +40 -0
  198. package/src/lexicon/types/tools/ozone/moderation/defs.ts +2 -0
  199. package/src/mod-service/index.ts +10 -3
  200. package/src/mod-service/subject.ts +73 -2
  201. package/src/mod-service/views.ts +30 -5
  202. package/src/util.ts +50 -0
  203. package/tests/3p-labeler.test.ts +271 -0
  204. package/tests/__snapshots__/moderation.test.ts.snap +30 -0
  205. package/tests/get-lists.test.ts +109 -0
  206. package/tests/moderation.test.ts +39 -0
@@ -0,0 +1,48 @@
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, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as ChatBskyConvoDefs from './defs'
11
+
12
+ export interface QueryParams {
13
+ limit: number
14
+ cursor?: string
15
+ }
16
+
17
+ export type InputSchema = undefined
18
+
19
+ export interface OutputSchema {
20
+ cursor?: string
21
+ convos: ChatBskyConvoDefs.ConvoView[]
22
+ [k: string]: unknown
23
+ }
24
+
25
+ export type HandlerInput = undefined
26
+
27
+ export interface HandlerSuccess {
28
+ encoding: 'application/json'
29
+ body: OutputSchema
30
+ headers?: { [key: string]: string }
31
+ }
32
+
33
+ export interface HandlerError {
34
+ status: number
35
+ message?: string
36
+ }
37
+
38
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
39
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
40
+ auth: HA
41
+ params: QueryParams
42
+ input: HandlerInput
43
+ req: express.Request
44
+ res: express.Response
45
+ }
46
+ export type Handler<HA extends HandlerAuth = never> = (
47
+ ctx: HandlerReqCtx<HA>,
48
+ ) => Promise<HandlerOutput> | HandlerOutput
@@ -0,0 +1,50 @@
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, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as ChatBskyConvoDefs from './defs'
11
+
12
+ export interface QueryParams {}
13
+
14
+ export interface InputSchema {
15
+ convoId: string
16
+ [k: string]: unknown
17
+ }
18
+
19
+ export interface OutputSchema {
20
+ convo: ChatBskyConvoDefs.ConvoView
21
+ [k: string]: unknown
22
+ }
23
+
24
+ export interface HandlerInput {
25
+ encoding: 'application/json'
26
+ body: InputSchema
27
+ }
28
+
29
+ export interface HandlerSuccess {
30
+ encoding: 'application/json'
31
+ body: OutputSchema
32
+ headers?: { [key: string]: string }
33
+ }
34
+
35
+ export interface HandlerError {
36
+ status: number
37
+ message?: string
38
+ }
39
+
40
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
41
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
42
+ auth: HA
43
+ params: QueryParams
44
+ input: HandlerInput
45
+ req: express.Request
46
+ res: express.Response
47
+ }
48
+ export type Handler<HA extends HandlerAuth = never> = (
49
+ ctx: HandlerReqCtx<HA>,
50
+ ) => Promise<HandlerOutput> | HandlerOutput
@@ -0,0 +1,48 @@
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, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as ChatBskyConvoDefs from './defs'
11
+
12
+ export interface QueryParams {}
13
+
14
+ export interface InputSchema {
15
+ convoId: string
16
+ message: ChatBskyConvoDefs.MessageInput
17
+ [k: string]: unknown
18
+ }
19
+
20
+ export type OutputSchema = ChatBskyConvoDefs.MessageView
21
+
22
+ export interface HandlerInput {
23
+ encoding: 'application/json'
24
+ body: InputSchema
25
+ }
26
+
27
+ export interface HandlerSuccess {
28
+ encoding: 'application/json'
29
+ body: OutputSchema
30
+ headers?: { [key: string]: string }
31
+ }
32
+
33
+ export interface HandlerError {
34
+ status: number
35
+ message?: string
36
+ }
37
+
38
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
39
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
40
+ auth: HA
41
+ params: QueryParams
42
+ input: HandlerInput
43
+ req: express.Request
44
+ res: express.Response
45
+ }
46
+ export type Handler<HA extends HandlerAuth = never> = (
47
+ ctx: HandlerReqCtx<HA>,
48
+ ) => Promise<HandlerOutput> | HandlerOutput
@@ -0,0 +1,68 @@
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, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as ChatBskyConvoDefs from './defs'
11
+
12
+ export interface QueryParams {}
13
+
14
+ export interface InputSchema {
15
+ items: BatchItem[]
16
+ [k: string]: unknown
17
+ }
18
+
19
+ export interface OutputSchema {
20
+ items: ChatBskyConvoDefs.MessageView[]
21
+ [k: string]: unknown
22
+ }
23
+
24
+ export interface HandlerInput {
25
+ encoding: 'application/json'
26
+ body: InputSchema
27
+ }
28
+
29
+ export interface HandlerSuccess {
30
+ encoding: 'application/json'
31
+ body: OutputSchema
32
+ headers?: { [key: string]: string }
33
+ }
34
+
35
+ export interface HandlerError {
36
+ status: number
37
+ message?: string
38
+ }
39
+
40
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
41
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
42
+ auth: HA
43
+ params: QueryParams
44
+ input: HandlerInput
45
+ req: express.Request
46
+ res: express.Response
47
+ }
48
+ export type Handler<HA extends HandlerAuth = never> = (
49
+ ctx: HandlerReqCtx<HA>,
50
+ ) => Promise<HandlerOutput> | HandlerOutput
51
+
52
+ export interface BatchItem {
53
+ convoId: string
54
+ message: ChatBskyConvoDefs.MessageInput
55
+ [k: string]: unknown
56
+ }
57
+
58
+ export function isBatchItem(v: unknown): v is BatchItem {
59
+ return (
60
+ isObj(v) &&
61
+ hasProp(v, '$type') &&
62
+ v.$type === 'chat.bsky.convo.sendMessageBatch#batchItem'
63
+ )
64
+ }
65
+
66
+ export function validateBatchItem(v: unknown): ValidationResult {
67
+ return lexicons.validate('chat.bsky.convo.sendMessageBatch#batchItem', v)
68
+ }
@@ -0,0 +1,50 @@
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, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as ChatBskyConvoDefs from './defs'
11
+
12
+ export interface QueryParams {}
13
+
14
+ export interface InputSchema {
15
+ convoId: string
16
+ [k: string]: unknown
17
+ }
18
+
19
+ export interface OutputSchema {
20
+ convo: ChatBskyConvoDefs.ConvoView
21
+ [k: string]: unknown
22
+ }
23
+
24
+ export interface HandlerInput {
25
+ encoding: 'application/json'
26
+ body: InputSchema
27
+ }
28
+
29
+ export interface HandlerSuccess {
30
+ encoding: 'application/json'
31
+ body: OutputSchema
32
+ headers?: { [key: string]: string }
33
+ }
34
+
35
+ export interface HandlerError {
36
+ status: number
37
+ message?: string
38
+ }
39
+
40
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
41
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
42
+ auth: HA
43
+ params: QueryParams
44
+ input: HandlerInput
45
+ req: express.Request
46
+ res: express.Response
47
+ }
48
+ export type Handler<HA extends HandlerAuth = never> = (
49
+ ctx: HandlerReqCtx<HA>,
50
+ ) => Promise<HandlerOutput> | HandlerOutput
@@ -0,0 +1,51 @@
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, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as ChatBskyConvoDefs from './defs'
11
+
12
+ export interface QueryParams {}
13
+
14
+ export interface InputSchema {
15
+ convoId: string
16
+ messageId?: string
17
+ [k: string]: unknown
18
+ }
19
+
20
+ export interface OutputSchema {
21
+ convo: ChatBskyConvoDefs.ConvoView
22
+ [k: string]: unknown
23
+ }
24
+
25
+ export interface HandlerInput {
26
+ encoding: 'application/json'
27
+ body: InputSchema
28
+ }
29
+
30
+ export interface HandlerSuccess {
31
+ encoding: 'application/json'
32
+ body: OutputSchema
33
+ headers?: { [key: string]: string }
34
+ }
35
+
36
+ export interface HandlerError {
37
+ status: number
38
+ message?: string
39
+ }
40
+
41
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
42
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
43
+ auth: HA
44
+ params: QueryParams
45
+ input: HandlerInput
46
+ req: express.Request
47
+ res: express.Response
48
+ }
49
+ export type Handler<HA extends HandlerAuth = never> = (
50
+ ctx: HandlerReqCtx<HA>,
51
+ ) => Promise<HandlerOutput> | HandlerOutput
@@ -0,0 +1,67 @@
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, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+
11
+ export interface QueryParams {
12
+ actor: string
13
+ }
14
+
15
+ export type InputSchema = undefined
16
+
17
+ export interface OutputSchema {
18
+ day: Metadata
19
+ month: Metadata
20
+ all: Metadata
21
+ [k: string]: unknown
22
+ }
23
+
24
+ export type HandlerInput = undefined
25
+
26
+ export interface HandlerSuccess {
27
+ encoding: 'application/json'
28
+ body: OutputSchema
29
+ headers?: { [key: string]: string }
30
+ }
31
+
32
+ export interface HandlerError {
33
+ status: number
34
+ message?: string
35
+ }
36
+
37
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
38
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
39
+ auth: HA
40
+ params: QueryParams
41
+ input: HandlerInput
42
+ req: express.Request
43
+ res: express.Response
44
+ }
45
+ export type Handler<HA extends HandlerAuth = never> = (
46
+ ctx: HandlerReqCtx<HA>,
47
+ ) => Promise<HandlerOutput> | HandlerOutput
48
+
49
+ export interface Metadata {
50
+ messagesSent: number
51
+ messagesReceived: number
52
+ convos: number
53
+ convosStarted: number
54
+ [k: string]: unknown
55
+ }
56
+
57
+ export function isMetadata(v: unknown): v is Metadata {
58
+ return (
59
+ isObj(v) &&
60
+ hasProp(v, '$type') &&
61
+ v.$type === 'chat.bsky.moderation.getActorMetadata#metadata'
62
+ )
63
+ }
64
+
65
+ export function validateMetadata(v: unknown): ValidationResult {
66
+ return lexicons.validate('chat.bsky.moderation.getActorMetadata#metadata', v)
67
+ }
@@ -0,0 +1,54 @@
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, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as ChatBskyConvoDefs from '../convo/defs'
11
+
12
+ export interface QueryParams {
13
+ /** Conversation that the message is from. NOTE: this field will eventually be required. */
14
+ convoId?: string
15
+ messageId: string
16
+ before: number
17
+ after: number
18
+ }
19
+
20
+ export type InputSchema = undefined
21
+
22
+ export interface OutputSchema {
23
+ messages: (
24
+ | ChatBskyConvoDefs.MessageView
25
+ | ChatBskyConvoDefs.DeletedMessageView
26
+ | { $type: string; [k: string]: unknown }
27
+ )[]
28
+ [k: string]: unknown
29
+ }
30
+
31
+ export type HandlerInput = undefined
32
+
33
+ export interface HandlerSuccess {
34
+ encoding: 'application/json'
35
+ body: OutputSchema
36
+ headers?: { [key: string]: string }
37
+ }
38
+
39
+ export interface HandlerError {
40
+ status: number
41
+ message?: string
42
+ }
43
+
44
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
45
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
46
+ auth: HA
47
+ params: QueryParams
48
+ input: HandlerInput
49
+ req: express.Request
50
+ res: express.Response
51
+ }
52
+ export type Handler<HA extends HandlerAuth = never> = (
53
+ ctx: HandlerReqCtx<HA>,
54
+ ) => Promise<HandlerOutput> | HandlerOutput
@@ -0,0 +1,40 @@
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, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+
11
+ export interface QueryParams {}
12
+
13
+ export interface InputSchema {
14
+ actor: string
15
+ allowAccess: boolean
16
+ ref?: string
17
+ [k: string]: unknown
18
+ }
19
+
20
+ export interface HandlerInput {
21
+ encoding: 'application/json'
22
+ body: InputSchema
23
+ }
24
+
25
+ export interface HandlerError {
26
+ status: number
27
+ message?: string
28
+ }
29
+
30
+ export type HandlerOutput = HandlerError | void
31
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
32
+ auth: HA
33
+ params: QueryParams
34
+ input: HandlerInput
35
+ req: express.Request
36
+ res: express.Response
37
+ }
38
+ export type Handler<HA extends HandlerAuth = never> = (
39
+ ctx: HandlerReqCtx<HA>,
40
+ ) => Promise<HandlerOutput> | HandlerOutput
@@ -7,6 +7,7 @@ import { isObj, hasProp } from '../../../../util'
7
7
  import { CID } from 'multiformats/cid'
8
8
  import * as ComAtprotoAdminDefs from '../../../com/atproto/admin/defs'
9
9
  import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef'
10
+ import * as ChatBskyConvoDefs from '../../../chat/bsky/convo/defs'
10
11
  import * as ComAtprotoModerationDefs from '../../../com/atproto/moderation/defs'
11
12
  import * as ComAtprotoServerDefs from '../../../com/atproto/server/defs'
12
13
  import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs'
@@ -32,6 +33,7 @@ export interface ModEventView {
32
33
  subject:
33
34
  | ComAtprotoAdminDefs.RepoRef
34
35
  | ComAtprotoRepoStrongRef.Main
36
+ | ChatBskyConvoDefs.MessageRef
35
37
  | { $type: string; [k: string]: unknown }
36
38
  subjectBlobCids: string[]
37
39
  createdBy: string
@@ -18,7 +18,6 @@ import {
18
18
  isModEventTakedown,
19
19
  isModEventEmail,
20
20
  isModEventTag,
21
- isModEventUnmute,
22
21
  } from '../lexicon/types/tools/ozone/moderation/defs'
23
22
  import { RepoRef, RepoBlobRef } from '../lexicon/types/com/atproto/admin/defs'
24
23
  import {
@@ -49,6 +48,7 @@ import { formatLabel, formatLabelRow, signLabel } from './util'
49
48
  import { ImageInvalidator } from '../image-invalidator'
50
49
  import { httpLogger as log } from '../logger'
51
50
  import { OzoneConfig } from '../config'
51
+ import { LABELER_HEADER_NAME, ParsedLabelers } from '../util'
52
52
 
53
53
  export type ModerationServiceCreator = (db: Database) => ModerationService
54
54
 
@@ -97,7 +97,13 @@ export class ModerationService {
97
97
  this.signingKey,
98
98
  this.signingKeyId,
99
99
  this.appviewAgent,
100
- () => this.createAuthHeaders(this.cfg.appview.did),
100
+ async (labelers?: ParsedLabelers) => {
101
+ const authHeaders = await this.createAuthHeaders(this.cfg.appview.did)
102
+ if (labelers?.dids?.length) {
103
+ authHeaders.headers[LABELER_HEADER_NAME] = labelers.dids.join(', ')
104
+ }
105
+ return authHeaders
106
+ },
101
107
  )
102
108
 
103
109
  async getEvent(id: number): Promise<ModerationEventRow | undefined> {
@@ -335,7 +341,7 @@ export class ModerationService {
335
341
  durationInHours: event.durationInHours
336
342
  ? Number(event.durationInHours)
337
343
  : null,
338
- meta,
344
+ meta: Object.assign(meta, subjectInfo.meta),
339
345
  expiresAt:
340
346
  (isModEventTakedown(event) || isModEventMute(event)) &&
341
347
  event.durationInHours
@@ -346,6 +352,7 @@ export class ModerationService {
346
352
  subjectUri: subjectInfo.subjectUri,
347
353
  subjectCid: subjectInfo.subjectCid,
348
354
  subjectBlobCids: jsonb(subjectInfo.subjectBlobCids),
355
+ subjectMessageId: subjectInfo.subjectMessageId,
349
356
  })
350
357
  .returningAll()
351
358
  .executeTakeFirstOrThrow()
@@ -5,6 +5,7 @@ import { InvalidRequestError } from '@atproto/xrpc-server'
5
5
  import { ModerationEventRow, ModerationSubjectStatusRow } from './types'
6
6
  import { RepoRef } from '../lexicon/types/com/atproto/admin/defs'
7
7
  import { Main as StrongRef } from '../lexicon/types/com/atproto/repo/strongRef'
8
+ import { MessageRef } from '../lexicon/types/chat/bsky/convo/defs'
8
9
 
9
10
  type SubjectInput = ReportInput['subject'] | ActionInput['subject']
10
11
 
@@ -28,6 +29,15 @@ export const subjectFromInput = (
28
29
  ) {
29
30
  return new RecordSubject(subject.uri, subject.cid, blobs)
30
31
  }
32
+ if (
33
+ subject.$type === 'chat.bsky.convo.defs#messageRef' &&
34
+ typeof subject.did === 'string' &&
35
+ typeof subject.convoId === 'string' &&
36
+ typeof subject.messageId === 'string'
37
+ ) {
38
+ return new MessageSubject(subject.did, subject.convoId, subject.messageId)
39
+ }
40
+
31
41
  throw new InvalidRequestError('Invalid subject')
32
42
  }
33
43
 
@@ -42,6 +52,13 @@ export const subjectFromEventRow = (row: ModerationEventRow): ModSubject => {
42
52
  row.subjectCid,
43
53
  row.subjectBlobCids ?? [],
44
54
  )
55
+ } else if (
56
+ row.subjectType === 'chat.bsky.convo.defs#messageRef' &&
57
+ row.subjectMessageId
58
+ ) {
59
+ const convoId =
60
+ typeof row.meta?.['convoId'] === 'string' ? row.meta['convoId'] : ''
61
+ return new MessageSubject(row.subjectDid, convoId, row.subjectMessageId)
45
62
  } else {
46
63
  return new RepoSubject(row.subjectDid)
47
64
  }
@@ -61,11 +78,16 @@ export const subjectFromStatusRow = (
61
78
  }
62
79
 
63
80
  type SubjectInfo = {
64
- subjectType: 'com.atproto.admin.defs#repoRef' | 'com.atproto.repo.strongRef'
81
+ subjectType:
82
+ | 'com.atproto.admin.defs#repoRef'
83
+ | 'com.atproto.repo.strongRef'
84
+ | 'chat.bsky.convo.defs#messageRef'
65
85
  subjectDid: string
66
86
  subjectUri: string | null
67
87
  subjectCid: string | null
68
88
  subjectBlobCids: string[] | null
89
+ subjectMessageId: string | null
90
+ meta: Record<string, string> | null
69
91
  }
70
92
 
71
93
  export interface ModSubject {
@@ -74,8 +96,9 @@ export interface ModSubject {
74
96
  blobCids?: string[]
75
97
  isRepo(): this is RepoSubject
76
98
  isRecord(): this is RecordSubject
99
+ isMessage(): this is MessageSubject
77
100
  info(): SubjectInfo
78
- lex(): RepoRef | StrongRef
101
+ lex(): RepoRef | StrongRef | MessageRef
79
102
  }
80
103
 
81
104
  export class RepoSubject implements ModSubject {
@@ -88,6 +111,9 @@ export class RepoSubject implements ModSubject {
88
111
  isRecord() {
89
112
  return false
90
113
  }
114
+ isMessage() {
115
+ return false
116
+ }
91
117
  info() {
92
118
  return {
93
119
  subjectType: 'com.atproto.admin.defs#repoRef' as const,
@@ -95,6 +121,8 @@ export class RepoSubject implements ModSubject {
95
121
  subjectUri: null,
96
122
  subjectCid: null,
97
123
  subjectBlobCids: null,
124
+ subjectMessageId: null,
125
+ meta: null,
98
126
  }
99
127
  }
100
128
  lex(): RepoRef {
@@ -124,6 +152,9 @@ export class RecordSubject implements ModSubject {
124
152
  isRecord() {
125
153
  return true
126
154
  }
155
+ isMessage() {
156
+ return false
157
+ }
127
158
  info() {
128
159
  return {
129
160
  subjectType: 'com.atproto.repo.strongRef' as const,
@@ -131,6 +162,8 @@ export class RecordSubject implements ModSubject {
131
162
  subjectUri: this.uri,
132
163
  subjectCid: this.cid,
133
164
  subjectBlobCids: this.blobCids ?? [],
165
+ subjectMessageId: null,
166
+ meta: null,
134
167
  }
135
168
  }
136
169
  lex(): StrongRef {
@@ -141,3 +174,41 @@ export class RecordSubject implements ModSubject {
141
174
  }
142
175
  }
143
176
  }
177
+
178
+ export class MessageSubject implements ModSubject {
179
+ blobCids = undefined
180
+ recordPath = undefined
181
+ constructor(
182
+ public did: string,
183
+ public convoId: string,
184
+ public messageId: string,
185
+ ) {}
186
+ isRepo() {
187
+ return false
188
+ }
189
+ isRecord() {
190
+ return false
191
+ }
192
+ isMessage() {
193
+ return true
194
+ }
195
+ info() {
196
+ return {
197
+ subjectType: 'chat.bsky.convo.defs#messageRef' as const,
198
+ subjectDid: this.did,
199
+ subjectUri: null,
200
+ subjectCid: null,
201
+ subjectBlobCids: null,
202
+ subjectMessageId: this.messageId,
203
+ meta: { convoId: this.convoId },
204
+ }
205
+ }
206
+ lex(): MessageRef {
207
+ return {
208
+ $type: 'chat.bsky.convo.defs#messageRef',
209
+ did: this.did,
210
+ convoId: this.convoId,
211
+ messageId: this.messageId,
212
+ }
213
+ }
214
+ }