@atproto/api 0.20.23 → 0.20.26

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 (74) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/agent.d.ts +4 -0
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js +17 -0
  5. package/dist/agent.js.map +1 -1
  6. package/dist/client/lexicons.d.ts +8 -0
  7. package/dist/client/lexicons.d.ts.map +1 -1
  8. package/dist/client/lexicons.js +4 -0
  9. package/dist/client/lexicons.js.map +1 -1
  10. package/dist/client/types/app/bsky/actor/defs.d.ts +2 -0
  11. package/dist/client/types/app/bsky/actor/defs.d.ts.map +1 -1
  12. package/dist/client/types/app/bsky/actor/defs.js.map +1 -1
  13. package/dist/rich-text/detection.d.ts.map +1 -1
  14. package/dist/rich-text/detection.js +4 -1
  15. package/dist/rich-text/detection.js.map +1 -1
  16. package/dist/types.d.ts +1 -0
  17. package/dist/types.d.ts.map +1 -1
  18. package/dist/types.js.map +1 -1
  19. package/package.json +22 -16
  20. package/definitions/labels.json +0 -170
  21. package/docs/moderation.md +0 -260
  22. package/jest.config.cjs +0 -23
  23. package/jest.d.ts +0 -20
  24. package/jest.setup.ts +0 -97
  25. package/scripts/code/labels.mjs +0 -77
  26. package/scripts/generate-code.mjs +0 -4
  27. package/src/age-assurance.test.ts +0 -218
  28. package/src/age-assurance.ts +0 -137
  29. package/src/agent.ts +0 -1645
  30. package/src/atp-agent.ts +0 -570
  31. package/src/bsky-agent.ts +0 -14
  32. package/src/const.ts +0 -1
  33. package/src/index.ts +0 -44
  34. package/src/mocker.ts +0 -220
  35. package/src/moderation/decision.ts +0 -389
  36. package/src/moderation/index.ts +0 -69
  37. package/src/moderation/mutewords.ts +0 -170
  38. package/src/moderation/subjects/account.ts +0 -44
  39. package/src/moderation/subjects/feed-generator.ts +0 -24
  40. package/src/moderation/subjects/notification.ts +0 -25
  41. package/src/moderation/subjects/post.ts +0 -433
  42. package/src/moderation/subjects/profile.ts +0 -26
  43. package/src/moderation/subjects/status.ts +0 -27
  44. package/src/moderation/subjects/user-list.ts +0 -48
  45. package/src/moderation/types.ts +0 -191
  46. package/src/moderation/ui.ts +0 -21
  47. package/src/moderation/util.ts +0 -111
  48. package/src/predicate.ts +0 -52
  49. package/src/rich-text/detection.ts +0 -146
  50. package/src/rich-text/rich-text.ts +0 -418
  51. package/src/rich-text/sanitization.ts +0 -42
  52. package/src/rich-text/unicode.ts +0 -47
  53. package/src/rich-text/util.ts +0 -15
  54. package/src/session-manager.ts +0 -5
  55. package/src/types.ts +0 -165
  56. package/src/util.ts +0 -96
  57. package/tests/atp-agent.test.ts +0 -3863
  58. package/tests/dispatcher.test.ts +0 -527
  59. package/tests/errors.test.ts +0 -29
  60. package/tests/moderation-behaviors.test.ts +0 -951
  61. package/tests/moderation-custom-labels.test.ts +0 -334
  62. package/tests/moderation-mutewords.test.ts +0 -1299
  63. package/tests/moderation-prefs.test.ts +0 -402
  64. package/tests/moderation-quoteposts.test.ts +0 -277
  65. package/tests/moderation.test.ts +0 -739
  66. package/tests/rich-text-detection.test.ts +0 -456
  67. package/tests/rich-text-sanitization.test.ts +0 -216
  68. package/tests/rich-text.test.ts +0 -705
  69. package/tests/util/echo-server.ts +0 -37
  70. package/tests/util/moderation-behavior.ts +0 -268
  71. package/tsconfig.build.json +0 -9
  72. package/tsconfig.build.tsbuildinfo +0 -1
  73. package/tsconfig.json +0 -7
  74. package/tsconfig.tests.json +0 -10
@@ -1,951 +0,0 @@
1
- import { moderatePost, moderateProfile } from '../src/index.js'
2
- import {
3
- ModerationBehaviorSuiteRunner,
4
- ModerationTestSuiteScenario,
5
- SuiteConfigurations,
6
- SuiteScenarios,
7
- SuiteUsers,
8
- } from './util/moderation-behavior.js'
9
-
10
- const USERS: SuiteUsers = {
11
- self: {
12
- blocking: false,
13
- blockingByList: false,
14
- blockedBy: false,
15
- muted: false,
16
- mutedByList: false,
17
- },
18
- alice: {
19
- blocking: false,
20
- blockingByList: false,
21
- blockedBy: false,
22
- muted: false,
23
- mutedByList: false,
24
- },
25
- bob: {
26
- blocking: true,
27
- blockingByList: false,
28
- blockedBy: false,
29
- muted: false,
30
- mutedByList: false,
31
- },
32
- carla: {
33
- blocking: false,
34
- blockingByList: false,
35
- blockedBy: true,
36
- muted: false,
37
- mutedByList: false,
38
- },
39
- dan: {
40
- blocking: false,
41
- blockingByList: false,
42
- blockedBy: false,
43
- muted: true,
44
- mutedByList: false,
45
- },
46
- elise: {
47
- blocking: false,
48
- blockingByList: false,
49
- blockedBy: false,
50
- muted: false,
51
- mutedByList: true,
52
- },
53
- fern: {
54
- blocking: true,
55
- blockingByList: false,
56
- blockedBy: true,
57
- muted: false,
58
- mutedByList: false,
59
- },
60
- georgia: {
61
- blocking: false,
62
- blockingByList: true,
63
- blockedBy: false,
64
- muted: false,
65
- mutedByList: false,
66
- },
67
- }
68
- const CONFIGURATIONS: SuiteConfigurations = {
69
- none: {},
70
- 'adult-disabled': {
71
- adultContentEnabled: false,
72
- },
73
- 'intolerant-hide': {
74
- settings: { intolerance: 'hide' },
75
- },
76
- 'intolerant-warn': {
77
- settings: { intolerance: 'warn' },
78
- },
79
- 'intolerant-ignore': {
80
- settings: { intolerance: 'ignore' },
81
- },
82
- 'porn-hide': {
83
- adultContentEnabled: true,
84
- settings: { porn: 'hide' },
85
- },
86
- 'porn-warn': {
87
- adultContentEnabled: true,
88
- settings: { porn: 'warn' },
89
- },
90
- 'porn-ignore': {
91
- adultContentEnabled: true,
92
- settings: { porn: 'ignore' },
93
- },
94
- 'scam-hide': {
95
- settings: { misrepresentation: 'hide' },
96
- },
97
- 'scam-warn': {
98
- settings: { misrepresentation: 'warn' },
99
- },
100
- 'scam-ignore': {
101
- settings: { misrepresentation: 'ignore' },
102
- },
103
- 'intolerant-hide-scam-warn': {
104
- settings: { intolerance: 'hide', misrepresentation: 'hide' },
105
- },
106
- 'logged-out': {
107
- authed: false,
108
- },
109
- }
110
- const SCENARIOS: SuiteScenarios = {
111
- "Imperative label ('!hide') on account": {
112
- cfg: 'none',
113
- subject: 'profile',
114
- author: 'alice',
115
- labels: { account: ['!hide'] },
116
- behaviors: {
117
- profileList: ['filter', 'blur', 'noOverride'],
118
- profileView: ['blur', 'noOverride'],
119
- avatar: ['blur', 'noOverride'],
120
- banner: ['blur', 'noOverride'],
121
- displayName: ['blur', 'noOverride'],
122
- contentList: ['filter', 'blur', 'noOverride'],
123
- contentView: ['blur', 'noOverride'],
124
- },
125
- },
126
- "Imperative label ('!hide') on profile": {
127
- cfg: 'none',
128
- subject: 'profile',
129
- author: 'alice',
130
- labels: { profile: ['!hide'] },
131
- behaviors: {
132
- avatar: ['blur', 'noOverride'],
133
- banner: ['blur', 'noOverride'],
134
- displayName: ['blur', 'noOverride'],
135
- },
136
- },
137
- "Imperative label ('!hide') on post": {
138
- cfg: 'none',
139
- subject: 'post',
140
- author: 'alice',
141
- labels: { post: ['!hide'] },
142
- behaviors: {
143
- contentList: ['filter', 'blur', 'noOverride'],
144
- contentView: ['blur', 'noOverride'],
145
- },
146
- },
147
- "Imperative label ('!hide') on author profile": {
148
- cfg: 'none',
149
- subject: 'post',
150
- author: 'alice',
151
- labels: { profile: ['!hide'] },
152
- behaviors: {
153
- avatar: ['blur', 'noOverride'],
154
- banner: ['blur', 'noOverride'],
155
- displayName: ['blur', 'noOverride'],
156
- },
157
- },
158
- "Imperative label ('!hide') on author account": {
159
- cfg: 'none',
160
- subject: 'post',
161
- author: 'alice',
162
- labels: { account: ['!hide'] },
163
- behaviors: {
164
- avatar: ['blur', 'noOverride'],
165
- banner: ['blur', 'noOverride'],
166
- displayName: ['blur', 'noOverride'],
167
- contentList: ['filter', 'blur', 'noOverride'],
168
- contentView: ['blur', 'noOverride'],
169
- },
170
- },
171
-
172
- "Imperative label ('!warn') on account": {
173
- cfg: 'none',
174
- subject: 'profile',
175
- author: 'alice',
176
- labels: { account: ['!warn'] },
177
- behaviors: {
178
- profileList: ['blur'],
179
- profileView: ['blur'],
180
- avatar: ['blur'],
181
- banner: ['blur'],
182
- contentList: ['blur'],
183
- contentView: ['blur'],
184
- },
185
- },
186
- "Imperative label ('!warn') on profile": {
187
- cfg: 'none',
188
- subject: 'profile',
189
- author: 'alice',
190
- labels: { profile: ['!warn'] },
191
- behaviors: {
192
- avatar: ['blur'],
193
- banner: ['blur'],
194
- displayName: ['blur'],
195
- },
196
- },
197
- "Imperative label ('!warn') on post": {
198
- cfg: 'none',
199
- subject: 'post',
200
- author: 'alice',
201
- labels: { post: ['!warn'] },
202
- behaviors: {
203
- contentList: ['blur'],
204
- contentView: ['blur'],
205
- },
206
- },
207
- "Imperative label ('!warn') on author profile": {
208
- cfg: 'none',
209
- subject: 'post',
210
- author: 'alice',
211
- labels: { profile: ['!warn'] },
212
- behaviors: {
213
- avatar: ['blur'],
214
- banner: ['blur'],
215
- displayName: ['blur'],
216
- },
217
- },
218
- "Imperative label ('!warn') on author account": {
219
- cfg: 'none',
220
- subject: 'post',
221
- author: 'alice',
222
- labels: { account: ['!warn'] },
223
- behaviors: {
224
- avatar: ['blur'],
225
- banner: ['blur'],
226
- contentList: ['blur'],
227
- contentView: ['blur'],
228
- },
229
- },
230
-
231
- "Imperative label ('!no-unauthenticated') on account when logged out": {
232
- cfg: 'logged-out',
233
- subject: 'profile',
234
- author: 'alice',
235
- labels: { account: ['!no-unauthenticated'] },
236
- behaviors: {
237
- profileList: ['filter', 'blur', 'noOverride'],
238
- profileView: ['blur', 'noOverride'],
239
- avatar: ['blur', 'noOverride'],
240
- banner: ['blur', 'noOverride'],
241
- displayName: ['blur', 'noOverride'],
242
- contentList: ['filter', 'blur', 'noOverride'],
243
- contentView: ['blur', 'noOverride'],
244
- },
245
- },
246
- "Imperative label ('!no-unauthenticated') on profile when logged out": {
247
- cfg: 'logged-out',
248
- subject: 'profile',
249
- author: 'alice',
250
- labels: { profile: ['!no-unauthenticated'] },
251
- behaviors: {
252
- profileList: ['filter', 'blur', 'noOverride'],
253
- profileView: ['blur', 'noOverride'],
254
- avatar: ['blur', 'noOverride'],
255
- banner: ['blur', 'noOverride'],
256
- displayName: ['blur', 'noOverride'],
257
- contentList: ['filter', 'blur', 'noOverride'],
258
- contentView: ['blur', 'noOverride'],
259
- },
260
- },
261
- "Imperative label ('!no-unauthenticated') on post when logged out": {
262
- cfg: 'logged-out',
263
- subject: 'post',
264
- author: 'alice',
265
- labels: { post: ['!no-unauthenticated'] },
266
- behaviors: {
267
- contentList: ['filter', 'blur', 'noOverride'],
268
- contentView: ['blur', 'noOverride'],
269
- },
270
- },
271
- "Imperative label ('!no-unauthenticated') on author profile when logged out":
272
- {
273
- cfg: 'logged-out',
274
- subject: 'post',
275
- author: 'alice',
276
- labels: { profile: ['!no-unauthenticated'] },
277
- behaviors: {
278
- avatar: ['blur', 'noOverride'],
279
- banner: ['blur', 'noOverride'],
280
- displayName: ['blur', 'noOverride'],
281
- contentList: ['filter', 'blur', 'noOverride'],
282
- contentView: ['blur', 'noOverride'],
283
- },
284
- },
285
- "Imperative label ('!no-unauthenticated') on author account when logged out":
286
- {
287
- cfg: 'logged-out',
288
- subject: 'post',
289
- author: 'alice',
290
- labels: { account: ['!no-unauthenticated'] },
291
- behaviors: {
292
- avatar: ['blur', 'noOverride'],
293
- banner: ['blur', 'noOverride'],
294
- displayName: ['blur', 'noOverride'],
295
- contentList: ['filter', 'blur', 'noOverride'],
296
- contentView: ['blur', 'noOverride'],
297
- },
298
- },
299
-
300
- "Imperative label ('!no-unauthenticated') on account when logged in": {
301
- cfg: 'none',
302
- subject: 'profile',
303
- author: 'alice',
304
- labels: { account: ['!no-unauthenticated'] },
305
- behaviors: {},
306
- },
307
- "Imperative label ('!no-unauthenticated') on profile when logged in": {
308
- cfg: 'none',
309
- subject: 'profile',
310
- author: 'alice',
311
- labels: { profile: ['!no-unauthenticated'] },
312
- behaviors: {},
313
- },
314
- "Imperative label ('!no-unauthenticated') on post when logged in": {
315
- cfg: 'none',
316
- subject: 'post',
317
- author: 'alice',
318
- labels: { post: ['!no-unauthenticated'] },
319
- behaviors: {},
320
- },
321
- "Imperative label ('!no-unauthenticated') on author profile when logged in": {
322
- cfg: 'none',
323
- subject: 'post',
324
- author: 'alice',
325
- labels: { profile: ['!no-unauthenticated'] },
326
- behaviors: {},
327
- },
328
- "Imperative label ('!no-unauthenticated') on author account when logged in": {
329
- cfg: 'none',
330
- subject: 'post',
331
- author: 'alice',
332
- labels: { account: ['!no-unauthenticated'] },
333
- behaviors: {},
334
- },
335
-
336
- "Blur-media label ('porn') on account (hide)": {
337
- cfg: 'porn-hide',
338
- subject: 'profile',
339
- author: 'alice',
340
- labels: { account: ['porn'] },
341
- behaviors: {
342
- profileList: ['filter'],
343
- avatar: ['blur'],
344
- banner: ['blur'],
345
- contentList: ['filter'],
346
- },
347
- },
348
- "Blur-media label ('porn') on profile (hide)": {
349
- cfg: 'porn-hide',
350
- subject: 'profile',
351
- author: 'alice',
352
- labels: { profile: ['porn'] },
353
- behaviors: {
354
- avatar: ['blur'],
355
- banner: ['blur'],
356
- },
357
- },
358
- "Blur-media label ('porn') on post (hide)": {
359
- cfg: 'porn-hide',
360
- subject: 'post',
361
- author: 'alice',
362
- labels: { post: ['porn'] },
363
- behaviors: {
364
- contentList: ['filter'],
365
- contentMedia: ['blur'],
366
- },
367
- },
368
- "Blur-media label ('porn') on author profile (hide)": {
369
- cfg: 'porn-hide',
370
- subject: 'post',
371
- author: 'alice',
372
- labels: { profile: ['porn'] },
373
- behaviors: {
374
- avatar: ['blur'],
375
- banner: ['blur'],
376
- },
377
- },
378
- "Blur-media label ('porn') on author account (hide)": {
379
- cfg: 'porn-hide',
380
- subject: 'post',
381
- author: 'alice',
382
- labels: { account: ['porn'] },
383
- behaviors: {
384
- profileList: ['filter'],
385
- avatar: ['blur'],
386
- banner: ['blur'],
387
- contentList: ['filter'],
388
- },
389
- },
390
-
391
- "Blur-media label ('porn') on account (warn)": {
392
- cfg: 'porn-warn',
393
- subject: 'profile',
394
- author: 'alice',
395
- labels: { account: ['porn'] },
396
- behaviors: {
397
- avatar: ['blur'],
398
- banner: ['blur'],
399
- },
400
- },
401
- "Blur-media label ('porn') on profile (warn)": {
402
- cfg: 'porn-warn',
403
- subject: 'profile',
404
- author: 'alice',
405
- labels: { profile: ['porn'] },
406
- behaviors: {
407
- avatar: ['blur'],
408
- banner: ['blur'],
409
- },
410
- },
411
- "Blur-media label ('porn') on post (warn)": {
412
- cfg: 'porn-warn',
413
- subject: 'post',
414
- author: 'alice',
415
- labels: { post: ['porn'] },
416
- behaviors: {
417
- contentMedia: ['blur'],
418
- },
419
- },
420
- "Blur-media label ('porn') on author profile (warn)": {
421
- cfg: 'porn-warn',
422
- subject: 'post',
423
- author: 'alice',
424
- labels: { profile: ['porn'] },
425
- behaviors: {
426
- avatar: ['blur'],
427
- banner: ['blur'],
428
- },
429
- },
430
- "Blur-media label ('porn') on author account (warn)": {
431
- cfg: 'porn-warn',
432
- subject: 'post',
433
- author: 'alice',
434
- labels: { account: ['porn'] },
435
- behaviors: {
436
- avatar: ['blur'],
437
- banner: ['blur'],
438
- },
439
- },
440
-
441
- "Blur-media label ('porn') on account (ignore)": {
442
- cfg: 'porn-ignore',
443
- subject: 'profile',
444
- author: 'alice',
445
- labels: { account: ['porn'] },
446
- behaviors: {},
447
- },
448
- "Blur-media label ('porn') on profile (ignore)": {
449
- cfg: 'porn-ignore',
450
- subject: 'profile',
451
- author: 'alice',
452
- labels: { profile: ['porn'] },
453
- behaviors: {},
454
- },
455
- "Blur-media label ('porn') on post (ignore)": {
456
- cfg: 'porn-ignore',
457
- subject: 'post',
458
- author: 'alice',
459
- labels: { post: ['porn'] },
460
- behaviors: {},
461
- },
462
- "Blur-media label ('porn') on author profile (ignore)": {
463
- cfg: 'porn-ignore',
464
- subject: 'post',
465
- author: 'alice',
466
- labels: { profile: ['porn'] },
467
- behaviors: {},
468
- },
469
- "Blur-media label ('porn') on author account (ignore)": {
470
- cfg: 'porn-ignore',
471
- subject: 'post',
472
- author: 'alice',
473
- labels: { account: ['porn'] },
474
- behaviors: {},
475
- },
476
-
477
- 'Adult-only label on account when adult content is disabled': {
478
- cfg: 'adult-disabled',
479
- subject: 'profile',
480
- author: 'alice',
481
- labels: { account: ['porn'] },
482
- behaviors: {
483
- profileList: ['filter'],
484
- avatar: ['blur', 'noOverride'],
485
- banner: ['blur', 'noOverride'],
486
- contentList: ['filter'],
487
- },
488
- },
489
- 'Adult-only label on profile when adult content is disabled': {
490
- cfg: 'adult-disabled',
491
- subject: 'profile',
492
- author: 'alice',
493
- labels: { profile: ['porn'] },
494
- behaviors: {
495
- profileList: [],
496
- avatar: ['blur', 'noOverride'],
497
- banner: ['blur', 'noOverride'],
498
- contentList: [],
499
- },
500
- },
501
- 'Adult-only label on post when adult content is disabled': {
502
- cfg: 'adult-disabled',
503
- subject: 'post',
504
- author: 'alice',
505
- labels: { post: ['porn'] },
506
- behaviors: {
507
- contentList: ['filter'],
508
- contentMedia: ['blur', 'noOverride'],
509
- },
510
- },
511
- 'Adult-only label on author profile when adult content is disabled': {
512
- cfg: 'adult-disabled',
513
- subject: 'post',
514
- author: 'alice',
515
- labels: { profile: ['porn'] },
516
- behaviors: {
517
- avatar: ['blur', 'noOverride'],
518
- banner: ['blur', 'noOverride'],
519
- contentList: [],
520
- },
521
- },
522
- 'Adult-only label on author account when adult content is disabled': {
523
- cfg: 'adult-disabled',
524
- subject: 'post',
525
- author: 'alice',
526
- labels: { account: ['porn'] },
527
- behaviors: {
528
- avatar: ['blur', 'noOverride'],
529
- banner: ['blur', 'noOverride'],
530
- contentList: ['filter'],
531
- },
532
- },
533
-
534
- 'Self-profile: !hide on account': {
535
- cfg: 'none',
536
- subject: 'profile',
537
- author: 'self',
538
- labels: { account: ['!hide'] },
539
- behaviors: {
540
- avatar: ['blur'],
541
- banner: ['blur'],
542
- displayName: ['blur'],
543
- profileList: ['blur'],
544
- profileView: ['blur'],
545
- contentList: ['blur'],
546
- contentView: ['blur'],
547
- },
548
- },
549
- 'Self-profile: !hide on profile': {
550
- cfg: 'none',
551
- subject: 'profile',
552
- author: 'self',
553
- labels: { profile: ['!hide'] },
554
- behaviors: {
555
- avatar: ['blur'],
556
- banner: ['blur'],
557
- displayName: ['blur'],
558
- },
559
- },
560
-
561
- "Self-post: Imperative label ('!hide') on post": {
562
- cfg: 'none',
563
- subject: 'post',
564
- author: 'self',
565
- labels: { post: ['!hide'] },
566
- behaviors: {
567
- contentView: ['blur'],
568
- contentList: ['blur'],
569
- },
570
- },
571
- "Self-post: Imperative label ('!hide') on author profile": {
572
- cfg: 'none',
573
- subject: 'post',
574
- author: 'self',
575
- labels: { profile: ['!hide'] },
576
- behaviors: {
577
- avatar: ['blur'],
578
- banner: ['blur'],
579
- displayName: ['blur'],
580
- },
581
- },
582
- "Self-post: Imperative label ('!hide') on author account": {
583
- cfg: 'none',
584
- subject: 'post',
585
- author: 'self',
586
- labels: { account: ['!hide'] },
587
- behaviors: {
588
- avatar: ['blur'],
589
- banner: ['blur'],
590
- displayName: ['blur'],
591
- contentList: ['blur'],
592
- contentView: ['blur'],
593
- },
594
- },
595
-
596
- "Self-post: Imperative label ('!warn') on post": {
597
- cfg: 'none',
598
- subject: 'post',
599
- author: 'self',
600
- labels: { post: ['!warn'] },
601
- behaviors: {
602
- contentView: ['blur'],
603
- contentList: ['blur'],
604
- },
605
- },
606
- "Self-post: Imperative label ('!warn') on author profile": {
607
- cfg: 'none',
608
- subject: 'post',
609
- author: 'self',
610
- labels: { profile: ['!warn'] },
611
- behaviors: {
612
- avatar: ['blur'],
613
- banner: ['blur'],
614
- displayName: ['blur'],
615
- },
616
- },
617
- "Self-post: Imperative label ('!warn') on author account": {
618
- cfg: 'none',
619
- subject: 'post',
620
- author: 'self',
621
- labels: { account: ['!warn'] },
622
- behaviors: {
623
- avatar: ['blur'],
624
- banner: ['blur'],
625
- contentList: ['blur'],
626
- contentView: ['blur'],
627
- },
628
- },
629
-
630
- 'Mute/block: Blocking user': {
631
- cfg: 'none',
632
- subject: 'profile',
633
- author: 'bob',
634
- labels: {},
635
- behaviors: {
636
- profileList: ['filter', 'blur', 'noOverride'],
637
- profileView: ['alert'],
638
- avatar: ['blur', 'noOverride'],
639
- banner: ['blur', 'noOverride'],
640
- contentList: ['filter', 'blur', 'noOverride'],
641
- contentView: ['blur', 'noOverride'],
642
- },
643
- },
644
- 'Post with blocked author': {
645
- cfg: 'none',
646
- subject: 'post',
647
- author: 'bob',
648
- labels: {},
649
- behaviors: {
650
- avatar: ['blur', 'noOverride'],
651
- banner: ['blur', 'noOverride'],
652
- contentList: ['filter', 'blur', 'noOverride'],
653
- contentView: ['blur', 'noOverride'],
654
- },
655
- },
656
- 'Post with author blocking user': {
657
- cfg: 'none',
658
- subject: 'post',
659
- author: 'carla',
660
- labels: {},
661
- behaviors: {
662
- avatar: ['blur', 'noOverride'],
663
- banner: ['blur', 'noOverride'],
664
- contentList: ['filter', 'blur', 'noOverride'],
665
- contentView: ['blur', 'noOverride'],
666
- },
667
- },
668
-
669
- 'Mute/block: Blocking-by-list user': {
670
- cfg: 'none',
671
- subject: 'profile',
672
- author: 'georgia',
673
- labels: {},
674
- behaviors: {
675
- profileList: ['filter', 'blur', 'noOverride'],
676
- profileView: ['alert'],
677
- avatar: ['blur', 'noOverride'],
678
- banner: ['blur', 'noOverride'],
679
- contentList: ['filter', 'blur', 'noOverride'],
680
- contentView: ['blur', 'noOverride'],
681
- },
682
- },
683
-
684
- 'Mute/block: Blocked by user': {
685
- cfg: 'none',
686
- subject: 'profile',
687
- author: 'carla',
688
- labels: {},
689
- behaviors: {
690
- profileList: ['filter', 'blur', 'noOverride'],
691
- profileView: ['alert'],
692
- avatar: ['blur', 'noOverride'],
693
- banner: ['blur', 'noOverride'],
694
- contentList: ['filter', 'blur', 'noOverride'],
695
- contentView: ['blur', 'noOverride'],
696
- },
697
- },
698
-
699
- 'Mute/block: Muted user': {
700
- cfg: 'none',
701
- subject: 'profile',
702
- author: 'dan',
703
- labels: {},
704
- behaviors: {
705
- profileList: ['filter', 'inform'],
706
- profileView: ['alert'],
707
- contentList: ['filter', 'blur'],
708
- contentView: ['inform'],
709
- },
710
- },
711
-
712
- 'Mute/block: Muted-by-list user': {
713
- cfg: 'none',
714
- subject: 'profile',
715
- author: 'elise',
716
- labels: {},
717
- behaviors: {
718
- profileList: ['filter', 'inform'],
719
- profileView: ['alert'],
720
- contentList: ['filter', 'blur'],
721
- contentView: ['inform'],
722
- },
723
- },
724
-
725
- 'Merging: blocking & blocked-by user': {
726
- cfg: 'none',
727
- subject: 'profile',
728
- author: 'fern',
729
- labels: {},
730
- behaviors: {
731
- profileList: ['filter', 'blur', 'noOverride'],
732
- profileView: ['alert'],
733
- avatar: ['blur', 'noOverride'],
734
- banner: ['blur', 'noOverride'],
735
- contentList: ['filter', 'blur', 'noOverride'],
736
- contentView: ['blur', 'noOverride'],
737
- },
738
- },
739
-
740
- 'Post with muted author': {
741
- cfg: 'none',
742
- subject: 'post',
743
- author: 'dan',
744
- labels: {},
745
- behaviors: {
746
- contentList: ['filter', 'blur'],
747
- contentView: ['inform'],
748
- },
749
- },
750
-
751
- 'Post with muted-by-list author': {
752
- cfg: 'none',
753
- subject: 'post',
754
- author: 'elise',
755
- labels: {},
756
- behaviors: {
757
- contentList: ['filter', 'blur'],
758
- contentView: ['inform'],
759
- },
760
- },
761
-
762
- "Merging: '!hide' label on account of blocked user": {
763
- cfg: 'none',
764
- subject: 'profile',
765
- author: 'bob',
766
- labels: { account: ['!hide'] },
767
- behaviors: {
768
- profileList: ['filter', 'blur', 'noOverride'],
769
- profileView: ['blur', 'alert', 'noOverride'],
770
- avatar: ['blur', 'noOverride'],
771
- banner: ['blur', 'noOverride'],
772
- displayName: ['blur', 'noOverride'],
773
- contentList: ['filter', 'blur', 'noOverride'],
774
- contentView: ['blur', 'noOverride'],
775
- },
776
- },
777
- "Merging: '!hide' and 'porn' labels on account (hide)": {
778
- cfg: 'porn-hide',
779
- subject: 'profile',
780
- author: 'alice',
781
- labels: { account: ['!hide', 'porn'] },
782
- behaviors: {
783
- profileList: ['filter', 'blur', 'noOverride'],
784
- profileView: ['blur', 'noOverride'],
785
- avatar: ['blur', 'noOverride'],
786
- banner: ['blur', 'noOverride'],
787
- displayName: ['blur', 'noOverride'],
788
- contentList: ['filter', 'blur', 'noOverride'],
789
- contentView: ['blur', 'noOverride'],
790
- },
791
- },
792
- "Merging: '!warn' and 'porn' labels on account (hide)": {
793
- cfg: 'porn-hide',
794
- subject: 'profile',
795
- author: 'alice',
796
- labels: { account: ['!warn', 'porn'] },
797
- behaviors: {
798
- profileList: ['filter', 'blur'],
799
- profileView: ['blur'],
800
- avatar: ['blur'],
801
- banner: ['blur'],
802
- contentList: ['filter', 'blur'],
803
- contentView: ['blur'],
804
- },
805
- },
806
- 'Merging: !hide on account, !warn on profile': {
807
- cfg: 'none',
808
- subject: 'profile',
809
- author: 'alice',
810
- labels: { account: ['!hide'], profile: ['!warn'] },
811
- behaviors: {
812
- profileList: ['filter', 'blur', 'noOverride'],
813
- profileView: ['blur', 'noOverride'],
814
- avatar: ['blur', 'noOverride'],
815
- banner: ['blur', 'noOverride'],
816
- displayName: ['blur', 'noOverride'],
817
- contentList: ['filter', 'blur', 'noOverride'],
818
- contentView: ['blur', 'noOverride'],
819
- },
820
- },
821
- 'Merging: !warn on account, !hide on profile': {
822
- cfg: 'none',
823
- subject: 'profile',
824
- author: 'alice',
825
- labels: { account: ['!warn'], profile: ['!hide'] },
826
- behaviors: {
827
- profileList: ['blur'],
828
- profileView: ['blur'],
829
- avatar: ['blur', 'noOverride'],
830
- banner: ['blur', 'noOverride'],
831
- displayName: ['blur', 'noOverride'],
832
- contentList: ['blur'],
833
- contentView: ['blur'],
834
- },
835
- },
836
- 'Merging: post with blocking & blocked-by author': {
837
- cfg: 'none',
838
- subject: 'post',
839
- author: 'fern',
840
- labels: {},
841
- behaviors: {
842
- avatar: ['blur', 'noOverride'],
843
- banner: ['blur', 'noOverride'],
844
- contentList: ['filter', 'blur', 'noOverride'],
845
- contentView: ['blur', 'noOverride'],
846
- },
847
- },
848
- "Merging: '!hide' label on post by blocked user": {
849
- cfg: 'none',
850
- subject: 'post',
851
- author: 'bob',
852
- labels: { post: ['!hide'] },
853
- behaviors: {
854
- avatar: ['blur', 'noOverride'],
855
- banner: ['blur', 'noOverride'],
856
- contentList: ['filter', 'blur', 'noOverride'],
857
- contentView: ['blur', 'noOverride'],
858
- },
859
- },
860
- "Merging: '!hide' and 'porn' labels on post (hide)": {
861
- cfg: 'porn-hide',
862
- subject: 'post',
863
- author: 'alice',
864
- labels: { post: ['!hide', 'porn'] },
865
- behaviors: {
866
- contentList: ['filter', 'blur', 'noOverride'],
867
- contentView: ['blur', 'noOverride'],
868
- contentMedia: ['blur'],
869
- },
870
- },
871
- "Merging: '!warn' and 'porn' labels on post (hide)": {
872
- cfg: 'porn-hide',
873
- subject: 'post',
874
- author: 'alice',
875
- labels: { post: ['!warn', 'porn'] },
876
- behaviors: {
877
- contentList: ['filter', 'blur'],
878
- contentView: ['blur'],
879
- contentMedia: ['blur'],
880
- },
881
- },
882
- }
883
-
884
- const suite = new ModerationBehaviorSuiteRunner(
885
- USERS,
886
- CONFIGURATIONS,
887
- SCENARIOS,
888
- )
889
-
890
- describe('Post moderation behaviors', () => {
891
- const scenarios = Array.from(Object.entries(suite.scenarios)).filter(
892
- ([name]) => !name.startsWith('//'),
893
- )
894
- it.each(scenarios)(
895
- '%s',
896
- (_name: string, scenario: ModerationTestSuiteScenario) => {
897
- const res =
898
- scenario.subject === 'profile'
899
- ? moderateProfile(
900
- suite.profileScenario(scenario),
901
- suite.moderationOpts(scenario),
902
- )
903
- : moderatePost(
904
- suite.postScenario(scenario),
905
- suite.moderationOpts(scenario),
906
- )
907
- if (scenario.subject === 'profile') {
908
- expect(res.ui('profileList')).toBeModerationResult(
909
- scenario.behaviors.profileList,
910
- 'profileList',
911
- JSON.stringify(res, null, 2),
912
- )
913
- expect(res.ui('profileView')).toBeModerationResult(
914
- scenario.behaviors.profileView,
915
- 'profileView',
916
- JSON.stringify(res, null, 2),
917
- )
918
- }
919
- expect(res.ui('avatar')).toBeModerationResult(
920
- scenario.behaviors.avatar,
921
- 'avatar',
922
- JSON.stringify(res, null, 2),
923
- )
924
- expect(res.ui('banner')).toBeModerationResult(
925
- scenario.behaviors.banner,
926
- 'banner',
927
- JSON.stringify(res, null, 2),
928
- )
929
- expect(res.ui('displayName')).toBeModerationResult(
930
- scenario.behaviors.displayName,
931
- 'displayName',
932
- JSON.stringify(res, null, 2),
933
- )
934
- expect(res.ui('contentList')).toBeModerationResult(
935
- scenario.behaviors.contentList,
936
- 'contentList',
937
- JSON.stringify(res, null, 2),
938
- )
939
- expect(res.ui('contentView')).toBeModerationResult(
940
- scenario.behaviors.contentView,
941
- 'contentView',
942
- JSON.stringify(res, null, 2),
943
- )
944
- expect(res.ui('contentMedia')).toBeModerationResult(
945
- scenario.behaviors.contentMedia,
946
- 'contentMedia',
947
- JSON.stringify(res, null, 2),
948
- )
949
- },
950
- )
951
- })