@atproto/pds 0.4.17 → 0.4.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/api/app/bsky/actor/getSuggestions.d.ts.map +1 -1
  3. package/dist/api/app/bsky/actor/getSuggestions.js +3 -1
  4. package/dist/api/app/bsky/actor/getSuggestions.js.map +1 -1
  5. package/dist/api/app/bsky/feed/getFeed.d.ts.map +1 -1
  6. package/dist/api/app/bsky/feed/getFeed.js +3 -1
  7. package/dist/api/app/bsky/feed/getFeed.js.map +1 -1
  8. package/dist/api/app/bsky/feed/index.d.ts.map +1 -1
  9. package/dist/api/app/bsky/feed/index.js +2 -0
  10. package/dist/api/app/bsky/feed/index.js.map +1 -1
  11. package/dist/api/app/bsky/feed/sendInteractions.d.ts +4 -0
  12. package/dist/api/app/bsky/feed/sendInteractions.d.ts.map +1 -0
  13. package/dist/api/app/bsky/feed/sendInteractions.js +14 -0
  14. package/dist/api/app/bsky/feed/sendInteractions.js.map +1 -0
  15. package/dist/db/tables/moderation.d.ts +1 -1
  16. package/dist/db/tables/moderation.d.ts.map +1 -1
  17. package/dist/lexicon/lexicons.d.ts +41 -0
  18. package/dist/lexicon/lexicons.d.ts.map +1 -1
  19. package/dist/lexicon/lexicons.js +50 -1
  20. package/dist/lexicon/lexicons.js.map +1 -1
  21. package/dist/lexicon/types/app/bsky/feed/defs.d.ts +1 -0
  22. package/dist/lexicon/types/app/bsky/feed/defs.d.ts.map +1 -1
  23. package/dist/lexicon/types/app/bsky/feed/defs.js.map +1 -1
  24. package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts +22 -2
  25. package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts.map +1 -1
  26. package/dist/lexicon/types/tools/ozone/moderation/defs.js +22 -2
  27. package/dist/lexicon/types/tools/ozone/moderation/defs.js.map +1 -1
  28. package/dist/lexicon/types/tools/ozone/moderation/emitEvent.d.ts +1 -1
  29. package/dist/lexicon/types/tools/ozone/moderation/emitEvent.d.ts.map +1 -1
  30. package/dist/lexicon/types/tools/ozone/moderation/queryStatuses.d.ts +2 -0
  31. package/dist/lexicon/types/tools/ozone/moderation/queryStatuses.d.ts.map +1 -1
  32. package/dist/pipethrough.d.ts +10 -2
  33. package/dist/pipethrough.d.ts.map +1 -1
  34. package/dist/pipethrough.js +5 -4
  35. package/dist/pipethrough.js.map +1 -1
  36. package/package.json +4 -4
  37. package/src/api/app/bsky/actor/getSuggestions.ts +3 -1
  38. package/src/api/app/bsky/feed/getFeed.ts +3 -1
  39. package/src/api/app/bsky/feed/index.ts +2 -0
  40. package/src/api/app/bsky/feed/sendInteractions.ts +13 -0
  41. package/src/db/tables/moderation.ts +6 -0
  42. package/src/lexicon/lexicons.ts +53 -1
  43. package/src/lexicon/types/app/bsky/feed/defs.ts +1 -0
  44. package/src/lexicon/types/tools/ozone/moderation/defs.ts +56 -0
  45. package/src/lexicon/types/tools/ozone/moderation/emitEvent.ts +3 -1
  46. package/src/lexicon/types/tools/ozone/moderation/queryStatuses.ts +2 -0
  47. package/src/pipethrough.ts +15 -1
  48. package/tests/proxied/__snapshots__/admin.test.ts.snap +4 -0
  49. package/tests/proxied/__snapshots__/views.test.ts.snap +106 -0
@@ -4833,6 +4833,12 @@ export const schemaDict = {
4833
4833
  'lex:app.bsky.feed.defs#blockedPost',
4834
4834
  ],
4835
4835
  },
4836
+ grandparentAuthor: {
4837
+ type: 'ref',
4838
+ ref: 'lex:app.bsky.actor.defs#profileViewBasic',
4839
+ description:
4840
+ 'When parent is a reply to another post, this is the author of that post.',
4841
+ },
4836
4842
  },
4837
4843
  },
4838
4844
  reasonRepost: {
@@ -8408,6 +8414,9 @@ export const schemaDict = {
8408
8414
  'lex:tools.ozone.moderation.defs#modEventAcknowledge',
8409
8415
  'lex:tools.ozone.moderation.defs#modEventEscalate',
8410
8416
  'lex:tools.ozone.moderation.defs#modEventMute',
8417
+ 'lex:tools.ozone.moderation.defs#modEventUnmute',
8418
+ 'lex:tools.ozone.moderation.defs#modEventMuteReporter',
8419
+ 'lex:tools.ozone.moderation.defs#modEventUnmuteReporter',
8411
8420
  'lex:tools.ozone.moderation.defs#modEventEmail',
8412
8421
  'lex:tools.ozone.moderation.defs#modEventResolveAppeal',
8413
8422
  'lex:tools.ozone.moderation.defs#modEventDivert',
@@ -8467,6 +8476,9 @@ export const schemaDict = {
8467
8476
  'lex:tools.ozone.moderation.defs#modEventAcknowledge',
8468
8477
  'lex:tools.ozone.moderation.defs#modEventEscalate',
8469
8478
  'lex:tools.ozone.moderation.defs#modEventMute',
8479
+ 'lex:tools.ozone.moderation.defs#modEventUnmute',
8480
+ 'lex:tools.ozone.moderation.defs#modEventMuteReporter',
8481
+ 'lex:tools.ozone.moderation.defs#modEventUnmuteReporter',
8470
8482
  'lex:tools.ozone.moderation.defs#modEventEmail',
8471
8483
  'lex:tools.ozone.moderation.defs#modEventResolveAppeal',
8472
8484
  'lex:tools.ozone.moderation.defs#modEventDivert',
@@ -8546,6 +8558,10 @@ export const schemaDict = {
8546
8558
  type: 'string',
8547
8559
  format: 'datetime',
8548
8560
  },
8561
+ muteReportingUntil: {
8562
+ type: 'string',
8563
+ format: 'datetime',
8564
+ },
8549
8565
  lastReviewedBy: {
8550
8566
  type: 'string',
8551
8567
  format: 'did',
@@ -8669,6 +8685,11 @@ export const schemaDict = {
8669
8685
  comment: {
8670
8686
  type: 'string',
8671
8687
  },
8688
+ isReporterMuted: {
8689
+ type: 'boolean',
8690
+ description:
8691
+ "Set to true if the reporter was muted from reporting at the time of the event. These reports won't impact the reviewState of the subject.",
8692
+ },
8672
8693
  reportType: {
8673
8694
  type: 'ref',
8674
8695
  ref: 'lex:com.atproto.moderation.defs#reasonType',
@@ -8737,6 +8758,30 @@ export const schemaDict = {
8737
8758
  },
8738
8759
  },
8739
8760
  },
8761
+ modEventMuteReporter: {
8762
+ type: 'object',
8763
+ description: 'Mute incoming reports from an account',
8764
+ required: ['durationInHours'],
8765
+ properties: {
8766
+ comment: {
8767
+ type: 'string',
8768
+ },
8769
+ durationInHours: {
8770
+ type: 'integer',
8771
+ description: 'Indicates how long the account should remain muted.',
8772
+ },
8773
+ },
8774
+ },
8775
+ modEventUnmuteReporter: {
8776
+ type: 'object',
8777
+ description: 'Unmute incoming reports from an account',
8778
+ properties: {
8779
+ comment: {
8780
+ type: 'string',
8781
+ description: 'Describe reasoning behind the reversal.',
8782
+ },
8783
+ },
8784
+ },
8740
8785
  modEventEmail: {
8741
8786
  type: 'object',
8742
8787
  description: 'Keep a log of outgoing email to a user',
@@ -9121,8 +9166,10 @@ export const schemaDict = {
9121
9166
  'lex:tools.ozone.moderation.defs#modEventLabel',
9122
9167
  'lex:tools.ozone.moderation.defs#modEventReport',
9123
9168
  'lex:tools.ozone.moderation.defs#modEventMute',
9124
- 'lex:tools.ozone.moderation.defs#modEventReverseTakedown',
9125
9169
  'lex:tools.ozone.moderation.defs#modEventUnmute',
9170
+ 'lex:tools.ozone.moderation.defs#modEventMuteReporter',
9171
+ 'lex:tools.ozone.moderation.defs#modEventUnmuteReporter',
9172
+ 'lex:tools.ozone.moderation.defs#modEventReverseTakedown',
9126
9173
  'lex:tools.ozone.moderation.defs#modEventEmail',
9127
9174
  'lex:tools.ozone.moderation.defs#modEventTag',
9128
9175
  ],
@@ -9429,6 +9476,11 @@ export const schemaDict = {
9429
9476
  description:
9430
9477
  "By default, we don't include muted subjects in the results. Set this to true to include them.",
9431
9478
  },
9479
+ onlyMuted: {
9480
+ type: 'boolean',
9481
+ description:
9482
+ 'When set to true, only muted subjects and reporters will be returned.',
9483
+ },
9432
9484
  reviewState: {
9433
9485
  type: 'string',
9434
9486
  description: 'Specify when fetching subjects in a certain state',
@@ -97,6 +97,7 @@ export interface ReplyRef {
97
97
  | NotFoundPost
98
98
  | BlockedPost
99
99
  | { $type: string; [k: string]: unknown }
100
+ grandparentAuthor?: AppBskyActorDefs.ProfileViewBasic
100
101
  [k: string]: unknown
101
102
  }
102
103
 
@@ -22,6 +22,9 @@ export interface ModEventView {
22
22
  | ModEventAcknowledge
23
23
  | ModEventEscalate
24
24
  | ModEventMute
25
+ | ModEventUnmute
26
+ | ModEventMuteReporter
27
+ | ModEventUnmuteReporter
25
28
  | ModEventEmail
26
29
  | ModEventResolveAppeal
27
30
  | ModEventDivert
@@ -61,6 +64,9 @@ export interface ModEventViewDetail {
61
64
  | ModEventAcknowledge
62
65
  | ModEventEscalate
63
66
  | ModEventMute
67
+ | ModEventUnmute
68
+ | ModEventMuteReporter
69
+ | ModEventUnmuteReporter
64
70
  | ModEventEmail
65
71
  | ModEventResolveAppeal
66
72
  | ModEventDivert
@@ -105,6 +111,7 @@ export interface SubjectStatusView {
105
111
  /** Sticky comment on the subject. */
106
112
  comment?: string
107
113
  muteUntil?: string
114
+ muteReportingUntil?: string
108
115
  lastReviewedBy?: string
109
116
  lastReviewedAt?: string
110
117
  lastReportedAt?: string
@@ -237,6 +244,8 @@ export function validateModEventComment(v: unknown): ValidationResult {
237
244
  /** Report a subject */
238
245
  export interface ModEventReport {
239
246
  comment?: string
247
+ /** Set to true if the reporter was muted from reporting at the time of the event. These reports won't impact the reviewState of the subject. */
248
+ isReporterMuted?: boolean
240
249
  reportType: ComAtprotoModerationDefs.ReasonType
241
250
  [k: string]: unknown
242
251
  }
@@ -346,6 +355,53 @@ export function validateModEventUnmute(v: unknown): ValidationResult {
346
355
  return lexicons.validate('tools.ozone.moderation.defs#modEventUnmute', v)
347
356
  }
348
357
 
358
+ /** Mute incoming reports from an account */
359
+ export interface ModEventMuteReporter {
360
+ comment?: string
361
+ /** Indicates how long the account should remain muted. */
362
+ durationInHours: number
363
+ [k: string]: unknown
364
+ }
365
+
366
+ export function isModEventMuteReporter(v: unknown): v is ModEventMuteReporter {
367
+ return (
368
+ isObj(v) &&
369
+ hasProp(v, '$type') &&
370
+ v.$type === 'tools.ozone.moderation.defs#modEventMuteReporter'
371
+ )
372
+ }
373
+
374
+ export function validateModEventMuteReporter(v: unknown): ValidationResult {
375
+ return lexicons.validate(
376
+ 'tools.ozone.moderation.defs#modEventMuteReporter',
377
+ v,
378
+ )
379
+ }
380
+
381
+ /** Unmute incoming reports from an account */
382
+ export interface ModEventUnmuteReporter {
383
+ /** Describe reasoning behind the reversal. */
384
+ comment?: string
385
+ [k: string]: unknown
386
+ }
387
+
388
+ export function isModEventUnmuteReporter(
389
+ v: unknown,
390
+ ): v is ModEventUnmuteReporter {
391
+ return (
392
+ isObj(v) &&
393
+ hasProp(v, '$type') &&
394
+ v.$type === 'tools.ozone.moderation.defs#modEventUnmuteReporter'
395
+ )
396
+ }
397
+
398
+ export function validateModEventUnmuteReporter(v: unknown): ValidationResult {
399
+ return lexicons.validate(
400
+ 'tools.ozone.moderation.defs#modEventUnmuteReporter',
401
+ v,
402
+ )
403
+ }
404
+
349
405
  /** Keep a log of outgoing email to a user */
350
406
  export interface ModEventEmail {
351
407
  /** The subject line of the email sent to the user. */
@@ -22,8 +22,10 @@ export interface InputSchema {
22
22
  | ToolsOzoneModerationDefs.ModEventLabel
23
23
  | ToolsOzoneModerationDefs.ModEventReport
24
24
  | ToolsOzoneModerationDefs.ModEventMute
25
- | ToolsOzoneModerationDefs.ModEventReverseTakedown
26
25
  | ToolsOzoneModerationDefs.ModEventUnmute
26
+ | ToolsOzoneModerationDefs.ModEventMuteReporter
27
+ | ToolsOzoneModerationDefs.ModEventUnmuteReporter
28
+ | ToolsOzoneModerationDefs.ModEventReverseTakedown
27
29
  | ToolsOzoneModerationDefs.ModEventEmail
28
30
  | ToolsOzoneModerationDefs.ModEventTag
29
31
  | { $type: string; [k: string]: unknown }
@@ -23,6 +23,8 @@ export interface QueryParams {
23
23
  reviewedBefore?: string
24
24
  /** By default, we don't include muted subjects in the results. Set this to true to include them. */
25
25
  includeMuted?: boolean
26
+ /** When set to true, only muted subjects and reporters will be returned. */
27
+ onlyMuted?: boolean
26
28
  /** Specify when fetching subjects in a certain state */
27
29
  reviewState?: string
28
30
  ignoreSubjects?: string[]
@@ -9,6 +9,14 @@ import { httpLogger } from './logger'
9
9
  import { getServiceEndpoint, noUndefinedVals } from '@atproto/common'
10
10
  import AppContext from './context'
11
11
 
12
+ type PipethroughOptions = {
13
+ /**
14
+ * Request headers to pass-through, in addition to those defined in
15
+ * {@link REQ_HEADERS_TO_FORWARD}
16
+ */
17
+ reqHeadersToForward?: string[]
18
+ }
19
+
12
20
  const defaultService = (
13
21
  ctx: AppContext,
14
22
  path: string,
@@ -39,12 +47,14 @@ export const pipethrough = async (
39
47
  req: express.Request,
40
48
  requester?: string,
41
49
  audOverride?: string,
50
+ options?: PipethroughOptions,
42
51
  ): Promise<HandlerPipeThrough> => {
43
52
  const { url, headers } = await createUrlAndHeaders(
44
53
  ctx,
45
54
  req,
46
55
  requester,
47
56
  audOverride,
57
+ options,
48
58
  )
49
59
  const reqInit: RequestInit = {
50
60
  headers,
@@ -106,6 +116,7 @@ export const createUrlAndHeaders = async (
106
116
  req: express.Request,
107
117
  requester?: string,
108
118
  audOverride?: string,
119
+ options?: PipethroughOptions,
109
120
  ): Promise<{ url: URL; headers: { authorization?: string } }> => {
110
121
  const proxyTo = await parseProxyHeader(ctx, req)
111
122
  const defaultProxy = defaultService(ctx, req.path)
@@ -121,8 +132,11 @@ export const createUrlAndHeaders = async (
121
132
  const headers = requester
122
133
  ? (await ctx.serviceAuthHeaders(requester, aud)).headers
123
134
  : {}
135
+ const allowedHeaders = REQ_HEADERS_TO_FORWARD.concat(
136
+ options?.reqHeadersToForward ?? [],
137
+ )
124
138
  // forward select headers to upstream services
125
- for (const header of REQ_HEADERS_TO_FORWARD) {
139
+ for (const header of allowedHeaders) {
126
140
  const val = req.headers[header]
127
141
  if (val) {
128
142
  headers[header] = val
@@ -50,6 +50,7 @@ Array [
50
50
  "event": Object {
51
51
  "$type": "tools.ozone.moderation.defs#modEventReport",
52
52
  "comment": "impersonation",
53
+ "isReporterMuted": false,
53
54
  "reportType": "com.atproto.moderation.defs#reasonOther",
54
55
  },
55
56
  "id": 3,
@@ -63,6 +64,7 @@ Array [
63
64
  Object {
64
65
  "createdAt": "1970-01-01T00:00:00.000Z",
65
66
  "createdBy": "user(3)",
67
+ "creatorHandle": "mod-authority.test",
66
68
  "event": Object {
67
69
  "$type": "tools.ozone.moderation.defs#modEventTag",
68
70
  "add": Array [
@@ -85,6 +87,7 @@ Array [
85
87
  "creatorHandle": "alice.test",
86
88
  "event": Object {
87
89
  "$type": "tools.ozone.moderation.defs#modEventReport",
90
+ "isReporterMuted": false,
88
91
  "reportType": "com.atproto.moderation.defs#reasonSpam",
89
92
  },
90
93
  "id": 1,
@@ -164,6 +167,7 @@ Array [
164
167
  Object {
165
168
  "createdAt": "1970-01-01T00:00:00.000Z",
166
169
  "createdBy": "user(0)",
170
+ "creatorHandle": "mod-authority.test",
167
171
  "event": Object {
168
172
  "$type": "tools.ozone.moderation.defs#modEventTag",
169
173
  "add": Array [
@@ -203,6 +203,21 @@ Array [
203
203
  "muted": false,
204
204
  },
205
205
  },
206
+ Object {
207
+ "associated": Object {
208
+ "labeler": true,
209
+ },
210
+ "description": "The pretend version of mod.bsky.app",
211
+ "did": "user(6)",
212
+ "displayName": "Dev-env Moderation",
213
+ "handle": "mod-authority.test",
214
+ "indexedAt": "1970-01-01T00:00:00.000Z",
215
+ "labels": Array [],
216
+ "viewer": Object {
217
+ "blockedBy": false,
218
+ "muted": false,
219
+ },
220
+ },
206
221
  ]
207
222
  `;
208
223
 
@@ -275,6 +290,19 @@ Array [
275
290
  "muted": false,
276
291
  },
277
292
  },
293
+ Object {
294
+ "associated": Object {
295
+ "labeler": true,
296
+ },
297
+ "did": "user(6)",
298
+ "displayName": "Dev-env Moderation",
299
+ "handle": "mod-authority.test",
300
+ "labels": Array [],
301
+ "viewer": Object {
302
+ "blockedBy": false,
303
+ "muted": false,
304
+ },
305
+ },
278
306
  ]
279
307
  `;
280
308
 
@@ -709,6 +737,32 @@ Object {
709
737
  "viewer": Object {},
710
738
  },
711
739
  "reply": Object {
740
+ "grandparentAuthor": Object {
741
+ "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg",
742
+ "did": "user(0)",
743
+ "displayName": "ali",
744
+ "handle": "alice.test",
745
+ "labels": Array [
746
+ Object {
747
+ "cid": "cids(2)",
748
+ "cts": "1970-01-01T00:00:00.000Z",
749
+ "src": "user(0)",
750
+ "uri": "record(1)",
751
+ "val": "self-label-a",
752
+ },
753
+ Object {
754
+ "cid": "cids(2)",
755
+ "cts": "1970-01-01T00:00:00.000Z",
756
+ "src": "user(0)",
757
+ "uri": "record(1)",
758
+ "val": "self-label-b",
759
+ },
760
+ ],
761
+ "viewer": Object {
762
+ "blockedBy": false,
763
+ "muted": false,
764
+ },
765
+ },
712
766
  "parent": Object {
713
767
  "$type": "app.bsky.feed.defs#postView",
714
768
  "author": Object {
@@ -1567,6 +1621,32 @@ Object {
1567
1621
  "indexedAt": "1970-01-01T00:00:00.000Z",
1568
1622
  },
1569
1623
  "reply": Object {
1624
+ "grandparentAuthor": Object {
1625
+ "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg",
1626
+ "did": "user(0)",
1627
+ "displayName": "ali",
1628
+ "handle": "alice.test",
1629
+ "labels": Array [
1630
+ Object {
1631
+ "cid": "cids(2)",
1632
+ "cts": "1970-01-01T00:00:00.000Z",
1633
+ "src": "user(0)",
1634
+ "uri": "record(1)",
1635
+ "val": "self-label-a",
1636
+ },
1637
+ Object {
1638
+ "cid": "cids(2)",
1639
+ "cts": "1970-01-01T00:00:00.000Z",
1640
+ "src": "user(0)",
1641
+ "uri": "record(1)",
1642
+ "val": "self-label-b",
1643
+ },
1644
+ ],
1645
+ "viewer": Object {
1646
+ "blockedBy": false,
1647
+ "muted": false,
1648
+ },
1649
+ },
1570
1650
  "parent": Object {
1571
1651
  "$type": "app.bsky.feed.defs#postView",
1572
1652
  "author": Object {
@@ -1982,6 +2062,32 @@ Object {
1982
2062
  "viewer": Object {},
1983
2063
  },
1984
2064
  "reply": Object {
2065
+ "grandparentAuthor": Object {
2066
+ "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg",
2067
+ "did": "user(0)",
2068
+ "displayName": "ali",
2069
+ "handle": "alice.test",
2070
+ "labels": Array [
2071
+ Object {
2072
+ "cid": "cids(2)",
2073
+ "cts": "1970-01-01T00:00:00.000Z",
2074
+ "src": "user(0)",
2075
+ "uri": "record(1)",
2076
+ "val": "self-label-a",
2077
+ },
2078
+ Object {
2079
+ "cid": "cids(2)",
2080
+ "cts": "1970-01-01T00:00:00.000Z",
2081
+ "src": "user(0)",
2082
+ "uri": "record(1)",
2083
+ "val": "self-label-b",
2084
+ },
2085
+ ],
2086
+ "viewer": Object {
2087
+ "blockedBy": false,
2088
+ "muted": false,
2089
+ },
2090
+ },
1985
2091
  "parent": Object {
1986
2092
  "$type": "app.bsky.feed.defs#postView",
1987
2093
  "author": Object {