@atproto/api 0.12.25 → 0.12.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.
- package/CHANGELOG.md +6 -0
- package/dist/bsky-agent.d.ts +23 -1
- package/dist/bsky-agent.d.ts.map +1 -1
- package/dist/bsky-agent.js +106 -42
- package/dist/bsky-agent.js.map +1 -1
- package/dist/client/lexicons.d.ts +14 -0
- package/dist/client/lexicons.d.ts.map +1 -1
- package/dist/client/lexicons.js +14 -0
- package/dist/client/lexicons.js.map +1 -1
- package/dist/client/types/app/bsky/actor/defs.d.ts +5 -0
- package/dist/client/types/app/bsky/actor/defs.d.ts.map +1 -1
- package/dist/client/types/app/bsky/actor/defs.js.map +1 -1
- package/dist/moderation/mutewords.d.ts +2 -1
- package/dist/moderation/mutewords.d.ts.map +1 -1
- package/dist/moderation/mutewords.js +7 -1
- package/dist/moderation/mutewords.js.map +1 -1
- package/dist/moderation/subjects/post.js +13 -0
- package/dist/moderation/subjects/post.js.map +1 -1
- package/package.json +1 -1
- package/src/bsky-agent.ts +139 -45
- package/src/client/lexicons.ts +16 -0
- package/src/client/types/app/bsky/actor/defs.ts +5 -0
- package/src/moderation/mutewords.ts +11 -0
- package/src/moderation/subjects/post.ts +15 -0
- package/tests/bsky-agent.test.ts +525 -156
- package/tests/moderation-mutewords.test.ts +308 -50
|
@@ -11,7 +11,9 @@ describe(`hasMutedWord`, () => {
|
|
|
11
11
|
rt.detectFacetsWithoutResolution()
|
|
12
12
|
|
|
13
13
|
const match = hasMutedWord({
|
|
14
|
-
mutedWords: [
|
|
14
|
+
mutedWords: [
|
|
15
|
+
{ value: 'outlineTag', targets: ['tag'], actorTarget: 'all' },
|
|
16
|
+
],
|
|
15
17
|
text: rt.text,
|
|
16
18
|
facets: rt.facets,
|
|
17
19
|
outlineTags: ['outlineTag'],
|
|
@@ -27,7 +29,9 @@ describe(`hasMutedWord`, () => {
|
|
|
27
29
|
rt.detectFacetsWithoutResolution()
|
|
28
30
|
|
|
29
31
|
const match = hasMutedWord({
|
|
30
|
-
mutedWords: [
|
|
32
|
+
mutedWords: [
|
|
33
|
+
{ value: 'inlineTag', targets: ['tag'], actorTarget: 'all' },
|
|
34
|
+
],
|
|
31
35
|
text: rt.text,
|
|
32
36
|
facets: rt.facets,
|
|
33
37
|
outlineTags: ['outlineTag'],
|
|
@@ -43,7 +47,9 @@ describe(`hasMutedWord`, () => {
|
|
|
43
47
|
rt.detectFacetsWithoutResolution()
|
|
44
48
|
|
|
45
49
|
const match = hasMutedWord({
|
|
46
|
-
mutedWords: [
|
|
50
|
+
mutedWords: [
|
|
51
|
+
{ value: 'inlineTag', targets: ['content'], actorTarget: 'all' },
|
|
52
|
+
],
|
|
47
53
|
text: rt.text,
|
|
48
54
|
facets: rt.facets,
|
|
49
55
|
outlineTags: ['outlineTag'],
|
|
@@ -59,7 +65,9 @@ describe(`hasMutedWord`, () => {
|
|
|
59
65
|
rt.detectFacetsWithoutResolution()
|
|
60
66
|
|
|
61
67
|
const match = hasMutedWord({
|
|
62
|
-
mutedWords: [
|
|
68
|
+
mutedWords: [
|
|
69
|
+
{ value: 'inlineTag', targets: ['tag'], actorTarget: 'all' },
|
|
70
|
+
],
|
|
63
71
|
text: rt.text,
|
|
64
72
|
facets: rt.facets,
|
|
65
73
|
outlineTags: [],
|
|
@@ -80,7 +88,7 @@ describe(`hasMutedWord`, () => {
|
|
|
80
88
|
rt.detectFacetsWithoutResolution()
|
|
81
89
|
|
|
82
90
|
const match = hasMutedWord({
|
|
83
|
-
mutedWords: [{ value: '希', targets: ['content'] }],
|
|
91
|
+
mutedWords: [{ value: '希', targets: ['content'], actorTarget: 'all' }],
|
|
84
92
|
text: rt.text,
|
|
85
93
|
facets: rt.facets,
|
|
86
94
|
outlineTags: [],
|
|
@@ -96,7 +104,9 @@ describe(`hasMutedWord`, () => {
|
|
|
96
104
|
rt.detectFacetsWithoutResolution()
|
|
97
105
|
|
|
98
106
|
const match = hasMutedWord({
|
|
99
|
-
mutedWords: [
|
|
107
|
+
mutedWords: [
|
|
108
|
+
{ value: '☠︎', targets: ['content'], actorTarget: 'all' },
|
|
109
|
+
],
|
|
100
110
|
text: rt.text,
|
|
101
111
|
facets: rt.facets,
|
|
102
112
|
outlineTags: [],
|
|
@@ -112,7 +122,9 @@ describe(`hasMutedWord`, () => {
|
|
|
112
122
|
rt.detectFacetsWithoutResolution()
|
|
113
123
|
|
|
114
124
|
const match = hasMutedWord({
|
|
115
|
-
mutedWords: [
|
|
125
|
+
mutedWords: [
|
|
126
|
+
{ value: 'politics', targets: ['content'], actorTarget: 'all' },
|
|
127
|
+
],
|
|
116
128
|
text: rt.text,
|
|
117
129
|
facets: rt.facets,
|
|
118
130
|
outlineTags: [],
|
|
@@ -128,7 +140,9 @@ describe(`hasMutedWord`, () => {
|
|
|
128
140
|
rt.detectFacetsWithoutResolution()
|
|
129
141
|
|
|
130
142
|
const match = hasMutedWord({
|
|
131
|
-
mutedWords: [
|
|
143
|
+
mutedWords: [
|
|
144
|
+
{ value: 'javascript', targets: ['content'], actorTarget: 'all' },
|
|
145
|
+
],
|
|
132
146
|
text: rt.text,
|
|
133
147
|
facets: rt.facets,
|
|
134
148
|
outlineTags: [],
|
|
@@ -146,7 +160,9 @@ describe(`hasMutedWord`, () => {
|
|
|
146
160
|
rt.detectFacetsWithoutResolution()
|
|
147
161
|
|
|
148
162
|
const match = hasMutedWord({
|
|
149
|
-
mutedWords: [
|
|
163
|
+
mutedWords: [
|
|
164
|
+
{ value: 'javascript', targets: ['content'], actorTarget: 'all' },
|
|
165
|
+
],
|
|
150
166
|
text: rt.text,
|
|
151
167
|
facets: rt.facets,
|
|
152
168
|
outlineTags: [],
|
|
@@ -162,7 +178,7 @@ describe(`hasMutedWord`, () => {
|
|
|
162
178
|
rt.detectFacetsWithoutResolution()
|
|
163
179
|
|
|
164
180
|
const match = hasMutedWord({
|
|
165
|
-
mutedWords: [{ value: 'ai', targets: ['content'] }],
|
|
181
|
+
mutedWords: [{ value: 'ai', targets: ['content'], actorTarget: 'all' }],
|
|
166
182
|
text: rt.text,
|
|
167
183
|
facets: rt.facets,
|
|
168
184
|
outlineTags: [],
|
|
@@ -178,7 +194,9 @@ describe(`hasMutedWord`, () => {
|
|
|
178
194
|
rt.detectFacetsWithoutResolution()
|
|
179
195
|
|
|
180
196
|
const match = hasMutedWord({
|
|
181
|
-
mutedWords: [
|
|
197
|
+
mutedWords: [
|
|
198
|
+
{ value: 'brain', targets: ['content'], actorTarget: 'all' },
|
|
199
|
+
],
|
|
182
200
|
text: rt.text,
|
|
183
201
|
facets: rt.facets,
|
|
184
202
|
outlineTags: [],
|
|
@@ -194,7 +212,7 @@ describe(`hasMutedWord`, () => {
|
|
|
194
212
|
rt.detectFacetsWithoutResolution()
|
|
195
213
|
|
|
196
214
|
const match = hasMutedWord({
|
|
197
|
-
mutedWords: [{ value: `:)`, targets: ['content'] }],
|
|
215
|
+
mutedWords: [{ value: `:)`, targets: ['content'], actorTarget: 'all' }],
|
|
198
216
|
text: rt.text,
|
|
199
217
|
facets: rt.facets,
|
|
200
218
|
outlineTags: [],
|
|
@@ -213,7 +231,9 @@ describe(`hasMutedWord`, () => {
|
|
|
213
231
|
|
|
214
232
|
it(`match: yay!`, () => {
|
|
215
233
|
const match = hasMutedWord({
|
|
216
|
-
mutedWords: [
|
|
234
|
+
mutedWords: [
|
|
235
|
+
{ value: 'yay!', targets: ['content'], actorTarget: 'all' },
|
|
236
|
+
],
|
|
217
237
|
text: rt.text,
|
|
218
238
|
facets: rt.facets,
|
|
219
239
|
outlineTags: [],
|
|
@@ -224,7 +244,9 @@ describe(`hasMutedWord`, () => {
|
|
|
224
244
|
|
|
225
245
|
it(`match: yay`, () => {
|
|
226
246
|
const match = hasMutedWord({
|
|
227
|
-
mutedWords: [
|
|
247
|
+
mutedWords: [
|
|
248
|
+
{ value: 'yay', targets: ['content'], actorTarget: 'all' },
|
|
249
|
+
],
|
|
228
250
|
text: rt.text,
|
|
229
251
|
facets: rt.facets,
|
|
230
252
|
outlineTags: [],
|
|
@@ -242,7 +264,9 @@ describe(`hasMutedWord`, () => {
|
|
|
242
264
|
|
|
243
265
|
it(`match: y!ppee`, () => {
|
|
244
266
|
const match = hasMutedWord({
|
|
245
|
-
mutedWords: [
|
|
267
|
+
mutedWords: [
|
|
268
|
+
{ value: 'y!ppee', targets: ['content'], actorTarget: 'all' },
|
|
269
|
+
],
|
|
246
270
|
text: rt.text,
|
|
247
271
|
facets: rt.facets,
|
|
248
272
|
outlineTags: [],
|
|
@@ -254,7 +278,9 @@ describe(`hasMutedWord`, () => {
|
|
|
254
278
|
// single exclamation point, source has double
|
|
255
279
|
it(`no match: y!ppee!`, () => {
|
|
256
280
|
const match = hasMutedWord({
|
|
257
|
-
mutedWords: [
|
|
281
|
+
mutedWords: [
|
|
282
|
+
{ value: 'y!ppee!', targets: ['content'], actorTarget: 'all' },
|
|
283
|
+
],
|
|
258
284
|
text: rt.text,
|
|
259
285
|
facets: rt.facets,
|
|
260
286
|
outlineTags: [],
|
|
@@ -272,7 +298,9 @@ describe(`hasMutedWord`, () => {
|
|
|
272
298
|
|
|
273
299
|
it(`match: Bluesky's`, () => {
|
|
274
300
|
const match = hasMutedWord({
|
|
275
|
-
mutedWords: [
|
|
301
|
+
mutedWords: [
|
|
302
|
+
{ value: `Bluesky's`, targets: ['content'], actorTarget: 'all' },
|
|
303
|
+
],
|
|
276
304
|
text: rt.text,
|
|
277
305
|
facets: rt.facets,
|
|
278
306
|
outlineTags: [],
|
|
@@ -283,7 +311,9 @@ describe(`hasMutedWord`, () => {
|
|
|
283
311
|
|
|
284
312
|
it(`match: Bluesky`, () => {
|
|
285
313
|
const match = hasMutedWord({
|
|
286
|
-
mutedWords: [
|
|
314
|
+
mutedWords: [
|
|
315
|
+
{ value: 'Bluesky', targets: ['content'], actorTarget: 'all' },
|
|
316
|
+
],
|
|
287
317
|
text: rt.text,
|
|
288
318
|
facets: rt.facets,
|
|
289
319
|
outlineTags: [],
|
|
@@ -294,7 +324,9 @@ describe(`hasMutedWord`, () => {
|
|
|
294
324
|
|
|
295
325
|
it(`match: bluesky`, () => {
|
|
296
326
|
const match = hasMutedWord({
|
|
297
|
-
mutedWords: [
|
|
327
|
+
mutedWords: [
|
|
328
|
+
{ value: 'bluesky', targets: ['content'], actorTarget: 'all' },
|
|
329
|
+
],
|
|
298
330
|
text: rt.text,
|
|
299
331
|
facets: rt.facets,
|
|
300
332
|
outlineTags: [],
|
|
@@ -305,7 +337,9 @@ describe(`hasMutedWord`, () => {
|
|
|
305
337
|
|
|
306
338
|
it(`match: blueskys`, () => {
|
|
307
339
|
const match = hasMutedWord({
|
|
308
|
-
mutedWords: [
|
|
340
|
+
mutedWords: [
|
|
341
|
+
{ value: 'blueskys', targets: ['content'], actorTarget: 'all' },
|
|
342
|
+
],
|
|
309
343
|
text: rt.text,
|
|
310
344
|
facets: rt.facets,
|
|
311
345
|
outlineTags: [],
|
|
@@ -323,7 +357,9 @@ describe(`hasMutedWord`, () => {
|
|
|
323
357
|
|
|
324
358
|
it(`match: S@assy`, () => {
|
|
325
359
|
const match = hasMutedWord({
|
|
326
|
-
mutedWords: [
|
|
360
|
+
mutedWords: [
|
|
361
|
+
{ value: 'S@assy', targets: ['content'], actorTarget: 'all' },
|
|
362
|
+
],
|
|
327
363
|
text: rt.text,
|
|
328
364
|
facets: rt.facets,
|
|
329
365
|
outlineTags: [],
|
|
@@ -334,7 +370,9 @@ describe(`hasMutedWord`, () => {
|
|
|
334
370
|
|
|
335
371
|
it(`match: s@assy`, () => {
|
|
336
372
|
const match = hasMutedWord({
|
|
337
|
-
mutedWords: [
|
|
373
|
+
mutedWords: [
|
|
374
|
+
{ value: 's@assy', targets: ['content'], actorTarget: 'all' },
|
|
375
|
+
],
|
|
338
376
|
text: rt.text,
|
|
339
377
|
facets: rt.facets,
|
|
340
378
|
outlineTags: [],
|
|
@@ -353,7 +391,13 @@ describe(`hasMutedWord`, () => {
|
|
|
353
391
|
// case insensitive
|
|
354
392
|
it(`match: new york times`, () => {
|
|
355
393
|
const match = hasMutedWord({
|
|
356
|
-
mutedWords: [
|
|
394
|
+
mutedWords: [
|
|
395
|
+
{
|
|
396
|
+
value: 'new york times',
|
|
397
|
+
targets: ['content'],
|
|
398
|
+
actorTarget: 'all',
|
|
399
|
+
},
|
|
400
|
+
],
|
|
357
401
|
text: rt.text,
|
|
358
402
|
facets: rt.facets,
|
|
359
403
|
outlineTags: [],
|
|
@@ -371,7 +415,9 @@ describe(`hasMutedWord`, () => {
|
|
|
371
415
|
|
|
372
416
|
it(`match: !command`, () => {
|
|
373
417
|
const match = hasMutedWord({
|
|
374
|
-
mutedWords: [
|
|
418
|
+
mutedWords: [
|
|
419
|
+
{ value: `!command`, targets: ['content'], actorTarget: 'all' },
|
|
420
|
+
],
|
|
375
421
|
text: rt.text,
|
|
376
422
|
facets: rt.facets,
|
|
377
423
|
outlineTags: [],
|
|
@@ -382,7 +428,9 @@ describe(`hasMutedWord`, () => {
|
|
|
382
428
|
|
|
383
429
|
it(`match: command`, () => {
|
|
384
430
|
const match = hasMutedWord({
|
|
385
|
-
mutedWords: [
|
|
431
|
+
mutedWords: [
|
|
432
|
+
{ value: `command`, targets: ['content'], actorTarget: 'all' },
|
|
433
|
+
],
|
|
386
434
|
text: rt.text,
|
|
387
435
|
facets: rt.facets,
|
|
388
436
|
outlineTags: [],
|
|
@@ -398,7 +446,9 @@ describe(`hasMutedWord`, () => {
|
|
|
398
446
|
rt.detectFacetsWithoutResolution()
|
|
399
447
|
|
|
400
448
|
const match = hasMutedWord({
|
|
401
|
-
mutedWords: [
|
|
449
|
+
mutedWords: [
|
|
450
|
+
{ value: `!command`, targets: ['content'], actorTarget: 'all' },
|
|
451
|
+
],
|
|
402
452
|
text: rt.text,
|
|
403
453
|
facets: rt.facets,
|
|
404
454
|
outlineTags: [],
|
|
@@ -416,7 +466,9 @@ describe(`hasMutedWord`, () => {
|
|
|
416
466
|
|
|
417
467
|
it(`match: e/acc`, () => {
|
|
418
468
|
const match = hasMutedWord({
|
|
419
|
-
mutedWords: [
|
|
469
|
+
mutedWords: [
|
|
470
|
+
{ value: `e/acc`, targets: ['content'], actorTarget: 'all' },
|
|
471
|
+
],
|
|
420
472
|
text: rt.text,
|
|
421
473
|
facets: rt.facets,
|
|
422
474
|
outlineTags: [],
|
|
@@ -427,7 +479,9 @@ describe(`hasMutedWord`, () => {
|
|
|
427
479
|
|
|
428
480
|
it(`match: acc`, () => {
|
|
429
481
|
const match = hasMutedWord({
|
|
430
|
-
mutedWords: [
|
|
482
|
+
mutedWords: [
|
|
483
|
+
{ value: `acc`, targets: ['content'], actorTarget: 'all' },
|
|
484
|
+
],
|
|
431
485
|
text: rt.text,
|
|
432
486
|
facets: rt.facets,
|
|
433
487
|
outlineTags: [],
|
|
@@ -445,7 +499,9 @@ describe(`hasMutedWord`, () => {
|
|
|
445
499
|
|
|
446
500
|
it(`match: super-bad`, () => {
|
|
447
501
|
const match = hasMutedWord({
|
|
448
|
-
mutedWords: [
|
|
502
|
+
mutedWords: [
|
|
503
|
+
{ value: `super-bad`, targets: ['content'], actorTarget: 'all' },
|
|
504
|
+
],
|
|
449
505
|
text: rt.text,
|
|
450
506
|
facets: rt.facets,
|
|
451
507
|
outlineTags: [],
|
|
@@ -456,7 +512,9 @@ describe(`hasMutedWord`, () => {
|
|
|
456
512
|
|
|
457
513
|
it(`match: super`, () => {
|
|
458
514
|
const match = hasMutedWord({
|
|
459
|
-
mutedWords: [
|
|
515
|
+
mutedWords: [
|
|
516
|
+
{ value: `super`, targets: ['content'], actorTarget: 'all' },
|
|
517
|
+
],
|
|
460
518
|
text: rt.text,
|
|
461
519
|
facets: rt.facets,
|
|
462
520
|
outlineTags: [],
|
|
@@ -467,7 +525,9 @@ describe(`hasMutedWord`, () => {
|
|
|
467
525
|
|
|
468
526
|
it(`match: bad`, () => {
|
|
469
527
|
const match = hasMutedWord({
|
|
470
|
-
mutedWords: [
|
|
528
|
+
mutedWords: [
|
|
529
|
+
{ value: `bad`, targets: ['content'], actorTarget: 'all' },
|
|
530
|
+
],
|
|
471
531
|
text: rt.text,
|
|
472
532
|
facets: rt.facets,
|
|
473
533
|
outlineTags: [],
|
|
@@ -478,7 +538,9 @@ describe(`hasMutedWord`, () => {
|
|
|
478
538
|
|
|
479
539
|
it(`match: super bad`, () => {
|
|
480
540
|
const match = hasMutedWord({
|
|
481
|
-
mutedWords: [
|
|
541
|
+
mutedWords: [
|
|
542
|
+
{ value: `super bad`, targets: ['content'], actorTarget: 'all' },
|
|
543
|
+
],
|
|
482
544
|
text: rt.text,
|
|
483
545
|
facets: rt.facets,
|
|
484
546
|
outlineTags: [],
|
|
@@ -489,7 +551,9 @@ describe(`hasMutedWord`, () => {
|
|
|
489
551
|
|
|
490
552
|
it(`match: superbad`, () => {
|
|
491
553
|
const match = hasMutedWord({
|
|
492
|
-
mutedWords: [
|
|
554
|
+
mutedWords: [
|
|
555
|
+
{ value: `superbad`, targets: ['content'], actorTarget: 'all' },
|
|
556
|
+
],
|
|
493
557
|
text: rt.text,
|
|
494
558
|
facets: rt.facets,
|
|
495
559
|
outlineTags: [],
|
|
@@ -508,7 +572,11 @@ describe(`hasMutedWord`, () => {
|
|
|
508
572
|
it(`match: idk what this would be`, () => {
|
|
509
573
|
const match = hasMutedWord({
|
|
510
574
|
mutedWords: [
|
|
511
|
-
{
|
|
575
|
+
{
|
|
576
|
+
value: `idk what this would be`,
|
|
577
|
+
targets: ['content'],
|
|
578
|
+
actorTarget: 'all',
|
|
579
|
+
},
|
|
512
580
|
],
|
|
513
581
|
text: rt.text,
|
|
514
582
|
facets: rt.facets,
|
|
@@ -522,7 +590,11 @@ describe(`hasMutedWord`, () => {
|
|
|
522
590
|
// extra word
|
|
523
591
|
const match = hasMutedWord({
|
|
524
592
|
mutedWords: [
|
|
525
|
-
{
|
|
593
|
+
{
|
|
594
|
+
value: `idk what this would be for`,
|
|
595
|
+
targets: ['content'],
|
|
596
|
+
actorTarget: 'all',
|
|
597
|
+
},
|
|
526
598
|
],
|
|
527
599
|
text: rt.text,
|
|
528
600
|
facets: rt.facets,
|
|
@@ -535,7 +607,9 @@ describe(`hasMutedWord`, () => {
|
|
|
535
607
|
it(`match: idk`, () => {
|
|
536
608
|
// extra word
|
|
537
609
|
const match = hasMutedWord({
|
|
538
|
-
mutedWords: [
|
|
610
|
+
mutedWords: [
|
|
611
|
+
{ value: `idk`, targets: ['content'], actorTarget: 'all' },
|
|
612
|
+
],
|
|
539
613
|
text: rt.text,
|
|
540
614
|
facets: rt.facets,
|
|
541
615
|
outlineTags: [],
|
|
@@ -546,7 +620,13 @@ describe(`hasMutedWord`, () => {
|
|
|
546
620
|
|
|
547
621
|
it(`match: idkwhatthiswouldbe`, () => {
|
|
548
622
|
const match = hasMutedWord({
|
|
549
|
-
mutedWords: [
|
|
623
|
+
mutedWords: [
|
|
624
|
+
{
|
|
625
|
+
value: `idkwhatthiswouldbe`,
|
|
626
|
+
targets: ['content'],
|
|
627
|
+
actorTarget: 'all',
|
|
628
|
+
},
|
|
629
|
+
],
|
|
550
630
|
text: rt.text,
|
|
551
631
|
facets: rt.facets,
|
|
552
632
|
outlineTags: [],
|
|
@@ -564,7 +644,13 @@ describe(`hasMutedWord`, () => {
|
|
|
564
644
|
|
|
565
645
|
it(`match: context(iykyk)`, () => {
|
|
566
646
|
const match = hasMutedWord({
|
|
567
|
-
mutedWords: [
|
|
647
|
+
mutedWords: [
|
|
648
|
+
{
|
|
649
|
+
value: `context(iykyk)`,
|
|
650
|
+
targets: ['content'],
|
|
651
|
+
actorTarget: 'all',
|
|
652
|
+
},
|
|
653
|
+
],
|
|
568
654
|
text: rt.text,
|
|
569
655
|
facets: rt.facets,
|
|
570
656
|
outlineTags: [],
|
|
@@ -575,7 +661,9 @@ describe(`hasMutedWord`, () => {
|
|
|
575
661
|
|
|
576
662
|
it(`match: context`, () => {
|
|
577
663
|
const match = hasMutedWord({
|
|
578
|
-
mutedWords: [
|
|
664
|
+
mutedWords: [
|
|
665
|
+
{ value: `context`, targets: ['content'], actorTarget: 'all' },
|
|
666
|
+
],
|
|
579
667
|
text: rt.text,
|
|
580
668
|
facets: rt.facets,
|
|
581
669
|
outlineTags: [],
|
|
@@ -586,7 +674,9 @@ describe(`hasMutedWord`, () => {
|
|
|
586
674
|
|
|
587
675
|
it(`match: iykyk`, () => {
|
|
588
676
|
const match = hasMutedWord({
|
|
589
|
-
mutedWords: [
|
|
677
|
+
mutedWords: [
|
|
678
|
+
{ value: `iykyk`, targets: ['content'], actorTarget: 'all' },
|
|
679
|
+
],
|
|
590
680
|
text: rt.text,
|
|
591
681
|
facets: rt.facets,
|
|
592
682
|
outlineTags: [],
|
|
@@ -597,7 +687,9 @@ describe(`hasMutedWord`, () => {
|
|
|
597
687
|
|
|
598
688
|
it(`match: (iykyk)`, () => {
|
|
599
689
|
const match = hasMutedWord({
|
|
600
|
-
mutedWords: [
|
|
690
|
+
mutedWords: [
|
|
691
|
+
{ value: `(iykyk)`, targets: ['content'], actorTarget: 'all' },
|
|
692
|
+
],
|
|
601
693
|
text: rt.text,
|
|
602
694
|
facets: rt.facets,
|
|
603
695
|
outlineTags: [],
|
|
@@ -615,7 +707,9 @@ describe(`hasMutedWord`, () => {
|
|
|
615
707
|
|
|
616
708
|
it(`match: 🦋`, () => {
|
|
617
709
|
const match = hasMutedWord({
|
|
618
|
-
mutedWords: [
|
|
710
|
+
mutedWords: [
|
|
711
|
+
{ value: `🦋`, targets: ['content'], actorTarget: 'all' },
|
|
712
|
+
],
|
|
619
713
|
text: rt.text,
|
|
620
714
|
facets: rt.facets,
|
|
621
715
|
outlineTags: [],
|
|
@@ -635,7 +729,13 @@ describe(`hasMutedWord`, () => {
|
|
|
635
729
|
|
|
636
730
|
it(`match: stop worrying`, () => {
|
|
637
731
|
const match = hasMutedWord({
|
|
638
|
-
mutedWords: [
|
|
732
|
+
mutedWords: [
|
|
733
|
+
{
|
|
734
|
+
value: 'stop worrying',
|
|
735
|
+
targets: ['content'],
|
|
736
|
+
actorTarget: 'all',
|
|
737
|
+
},
|
|
738
|
+
],
|
|
639
739
|
text: rt.text,
|
|
640
740
|
facets: rt.facets,
|
|
641
741
|
outlineTags: [],
|
|
@@ -646,7 +746,13 @@ describe(`hasMutedWord`, () => {
|
|
|
646
746
|
|
|
647
747
|
it(`match: turtles, or how`, () => {
|
|
648
748
|
const match = hasMutedWord({
|
|
649
|
-
mutedWords: [
|
|
749
|
+
mutedWords: [
|
|
750
|
+
{
|
|
751
|
+
value: 'turtles, or how',
|
|
752
|
+
targets: ['content'],
|
|
753
|
+
actorTarget: 'all',
|
|
754
|
+
},
|
|
755
|
+
],
|
|
650
756
|
text: rt.text,
|
|
651
757
|
facets: rt.facets,
|
|
652
758
|
outlineTags: [],
|
|
@@ -668,7 +774,13 @@ describe(`hasMutedWord`, () => {
|
|
|
668
774
|
// internet
|
|
669
775
|
it(`match: インターネット`, () => {
|
|
670
776
|
const match = hasMutedWord({
|
|
671
|
-
mutedWords: [
|
|
777
|
+
mutedWords: [
|
|
778
|
+
{
|
|
779
|
+
value: 'インターネット',
|
|
780
|
+
targets: ['content'],
|
|
781
|
+
actorTarget: 'all',
|
|
782
|
+
},
|
|
783
|
+
],
|
|
672
784
|
text: rt.text,
|
|
673
785
|
facets: rt.facets,
|
|
674
786
|
outlineTags: [],
|
|
@@ -683,7 +795,9 @@ describe(`hasMutedWord`, () => {
|
|
|
683
795
|
describe(`facet with multiple features`, () => {
|
|
684
796
|
it(`multiple tags`, () => {
|
|
685
797
|
const match = hasMutedWord({
|
|
686
|
-
mutedWords: [
|
|
798
|
+
mutedWords: [
|
|
799
|
+
{ value: 'bad', targets: ['content'], actorTarget: 'all' },
|
|
800
|
+
],
|
|
687
801
|
text: 'tags',
|
|
688
802
|
facets: [
|
|
689
803
|
{
|
|
@@ -709,7 +823,9 @@ describe(`hasMutedWord`, () => {
|
|
|
709
823
|
|
|
710
824
|
it(`other features`, () => {
|
|
711
825
|
const match = hasMutedWord({
|
|
712
|
-
mutedWords: [
|
|
826
|
+
mutedWords: [
|
|
827
|
+
{ value: 'bad', targets: ['content'], actorTarget: 'all' },
|
|
828
|
+
],
|
|
713
829
|
text: 'test',
|
|
714
830
|
facets: [
|
|
715
831
|
{
|
|
@@ -753,7 +869,9 @@ describe(`hasMutedWord`, () => {
|
|
|
753
869
|
adultContentEnabled: false,
|
|
754
870
|
labels: {},
|
|
755
871
|
labelers: [],
|
|
756
|
-
mutedWords: [
|
|
872
|
+
mutedWords: [
|
|
873
|
+
{ value: 'words', targets: ['content'], actorTarget: 'all' },
|
|
874
|
+
],
|
|
757
875
|
hiddenPosts: [],
|
|
758
876
|
},
|
|
759
877
|
labelDefs: {},
|
|
@@ -780,7 +898,9 @@ describe(`hasMutedWord`, () => {
|
|
|
780
898
|
adultContentEnabled: false,
|
|
781
899
|
labels: {},
|
|
782
900
|
labelers: [],
|
|
783
|
-
mutedWords: [
|
|
901
|
+
mutedWords: [
|
|
902
|
+
{ value: 'words', targets: ['content'], actorTarget: 'all' },
|
|
903
|
+
],
|
|
784
904
|
hiddenPosts: [],
|
|
785
905
|
},
|
|
786
906
|
labelDefs: {},
|
|
@@ -811,13 +931,151 @@ describe(`hasMutedWord`, () => {
|
|
|
811
931
|
adultContentEnabled: false,
|
|
812
932
|
labels: {},
|
|
813
933
|
labelers: [],
|
|
814
|
-
mutedWords: [
|
|
934
|
+
mutedWords: [
|
|
935
|
+
{ value: 'words', targets: ['tags'], actorTarget: 'all' },
|
|
936
|
+
],
|
|
937
|
+
hiddenPosts: [],
|
|
938
|
+
},
|
|
939
|
+
labelDefs: {},
|
|
940
|
+
},
|
|
941
|
+
)
|
|
942
|
+
expect(res.causes.length).toBe(0)
|
|
943
|
+
})
|
|
944
|
+
})
|
|
945
|
+
|
|
946
|
+
describe(`timed mute words`, () => {
|
|
947
|
+
it(`non-expired word`, () => {
|
|
948
|
+
const now = Date.now()
|
|
949
|
+
|
|
950
|
+
const res = moderatePost(
|
|
951
|
+
mock.postView({
|
|
952
|
+
record: mock.post({
|
|
953
|
+
text: 'Mute words!',
|
|
954
|
+
}),
|
|
955
|
+
author: mock.profileViewBasic({
|
|
956
|
+
handle: 'bob.test',
|
|
957
|
+
displayName: 'Bob',
|
|
958
|
+
}),
|
|
959
|
+
labels: [],
|
|
960
|
+
}),
|
|
961
|
+
{
|
|
962
|
+
userDid: 'did:web:alice.test',
|
|
963
|
+
prefs: {
|
|
964
|
+
adultContentEnabled: false,
|
|
965
|
+
labels: {},
|
|
966
|
+
labelers: [],
|
|
967
|
+
mutedWords: [
|
|
968
|
+
{
|
|
969
|
+
value: 'words',
|
|
970
|
+
targets: ['content'],
|
|
971
|
+
expiresAt: new Date(now + 1e3).toISOString(),
|
|
972
|
+
actorTarget: 'all',
|
|
973
|
+
},
|
|
974
|
+
],
|
|
975
|
+
hiddenPosts: [],
|
|
976
|
+
},
|
|
977
|
+
labelDefs: {},
|
|
978
|
+
},
|
|
979
|
+
)
|
|
980
|
+
|
|
981
|
+
expect(res.causes[0].type).toBe('mute-word')
|
|
982
|
+
})
|
|
983
|
+
|
|
984
|
+
it(`expired word`, () => {
|
|
985
|
+
const now = Date.now()
|
|
986
|
+
|
|
987
|
+
const res = moderatePost(
|
|
988
|
+
mock.postView({
|
|
989
|
+
record: mock.post({
|
|
990
|
+
text: 'Mute words!',
|
|
991
|
+
}),
|
|
992
|
+
author: mock.profileViewBasic({
|
|
993
|
+
handle: 'bob.test',
|
|
994
|
+
displayName: 'Bob',
|
|
995
|
+
}),
|
|
996
|
+
labels: [],
|
|
997
|
+
}),
|
|
998
|
+
{
|
|
999
|
+
userDid: 'did:web:alice.test',
|
|
1000
|
+
prefs: {
|
|
1001
|
+
adultContentEnabled: false,
|
|
1002
|
+
labels: {},
|
|
1003
|
+
labelers: [],
|
|
1004
|
+
mutedWords: [
|
|
1005
|
+
{
|
|
1006
|
+
value: 'words',
|
|
1007
|
+
targets: ['content'],
|
|
1008
|
+
expiresAt: new Date(now - 1e3).toISOString(),
|
|
1009
|
+
actorTarget: 'all',
|
|
1010
|
+
},
|
|
1011
|
+
],
|
|
815
1012
|
hiddenPosts: [],
|
|
816
1013
|
},
|
|
817
1014
|
labelDefs: {},
|
|
818
1015
|
},
|
|
819
1016
|
)
|
|
1017
|
+
|
|
820
1018
|
expect(res.causes.length).toBe(0)
|
|
821
1019
|
})
|
|
822
1020
|
})
|
|
1021
|
+
|
|
1022
|
+
describe(`actor-based mute words`, () => {
|
|
1023
|
+
const viewer = {
|
|
1024
|
+
userDid: 'did:web:alice.test',
|
|
1025
|
+
prefs: {
|
|
1026
|
+
adultContentEnabled: false,
|
|
1027
|
+
labels: {},
|
|
1028
|
+
labelers: [],
|
|
1029
|
+
mutedWords: [
|
|
1030
|
+
{
|
|
1031
|
+
value: 'words',
|
|
1032
|
+
targets: ['content'],
|
|
1033
|
+
actorTarget: 'exclude-following',
|
|
1034
|
+
},
|
|
1035
|
+
],
|
|
1036
|
+
hiddenPosts: [],
|
|
1037
|
+
},
|
|
1038
|
+
labelDefs: {},
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
it(`followed actor`, () => {
|
|
1042
|
+
const res = moderatePost(
|
|
1043
|
+
mock.postView({
|
|
1044
|
+
record: mock.post({
|
|
1045
|
+
text: 'Mute words!',
|
|
1046
|
+
}),
|
|
1047
|
+
author: mock.profileViewBasic({
|
|
1048
|
+
handle: 'bob.test',
|
|
1049
|
+
displayName: 'Bob',
|
|
1050
|
+
viewer: {
|
|
1051
|
+
following: 'true',
|
|
1052
|
+
},
|
|
1053
|
+
}),
|
|
1054
|
+
labels: [],
|
|
1055
|
+
}),
|
|
1056
|
+
viewer,
|
|
1057
|
+
)
|
|
1058
|
+
expect(res.causes.length).toBe(0)
|
|
1059
|
+
})
|
|
1060
|
+
|
|
1061
|
+
it(`non-followed actor`, () => {
|
|
1062
|
+
const res = moderatePost(
|
|
1063
|
+
mock.postView({
|
|
1064
|
+
record: mock.post({
|
|
1065
|
+
text: 'Mute words!',
|
|
1066
|
+
}),
|
|
1067
|
+
author: mock.profileViewBasic({
|
|
1068
|
+
handle: 'carla.test',
|
|
1069
|
+
displayName: 'Carla',
|
|
1070
|
+
viewer: {
|
|
1071
|
+
following: undefined,
|
|
1072
|
+
},
|
|
1073
|
+
}),
|
|
1074
|
+
labels: [],
|
|
1075
|
+
}),
|
|
1076
|
+
viewer,
|
|
1077
|
+
)
|
|
1078
|
+
expect(res.causes[0].type).toBe('mute-word')
|
|
1079
|
+
})
|
|
1080
|
+
})
|
|
823
1081
|
})
|