@atproto/api 0.13.32 → 0.13.33
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 +14 -0
- package/README.md +1 -1
- package/dist/agent.d.ts +1 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +43 -1
- package/dist/agent.js.map +1 -1
- package/dist/client/lexicons.d.ts +56 -2
- package/dist/client/lexicons.d.ts.map +1 -1
- package/dist/client/lexicons.js +32 -0
- package/dist/client/lexicons.js.map +1 -1
- package/dist/client/types/app/bsky/actor/defs.d.ts +19 -1
- package/dist/client/types/app/bsky/actor/defs.d.ts.map +1 -1
- package/dist/client/types/app/bsky/actor/defs.js +10 -0
- package/dist/client/types/app/bsky/actor/defs.js.map +1 -1
- package/dist/client/types/app/bsky/feed/postgate.d.ts +1 -0
- package/dist/client/types/app/bsky/feed/postgate.d.ts.map +1 -1
- package/dist/client/types/app/bsky/feed/postgate.js.map +1 -1
- package/dist/client/types/app/bsky/feed/threadgate.d.ts +1 -0
- package/dist/client/types/app/bsky/feed/threadgate.d.ts.map +1 -1
- package/dist/client/types/app/bsky/feed/threadgate.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/mocker.d.ts +1 -1
- package/dist/mocker.d.ts.map +1 -1
- package/dist/moderation/decision.d.ts +1 -1
- package/dist/moderation/decision.d.ts.map +1 -1
- package/dist/moderation/decision.js +1 -1
- package/dist/moderation/decision.js.map +1 -1
- package/dist/moderation/index.d.ts +1 -1
- package/dist/moderation/index.d.ts.map +1 -1
- package/dist/moderation/index.js +3 -3
- package/dist/moderation/index.js.map +1 -1
- package/dist/moderation/subjects/account.d.ts +1 -1
- package/dist/moderation/subjects/account.d.ts.map +1 -1
- package/dist/moderation/subjects/feed-generator.d.ts +1 -1
- package/dist/moderation/subjects/feed-generator.d.ts.map +1 -1
- package/dist/moderation/subjects/notification.d.ts +1 -1
- package/dist/moderation/subjects/notification.d.ts.map +1 -1
- package/dist/moderation/subjects/post.d.ts +1 -1
- package/dist/moderation/subjects/post.d.ts.map +1 -1
- package/dist/moderation/subjects/post.js +1 -1
- package/dist/moderation/subjects/post.js.map +1 -1
- package/dist/moderation/subjects/profile.d.ts +1 -1
- package/dist/moderation/subjects/profile.d.ts.map +1 -1
- package/dist/moderation/subjects/user-list.d.ts +1 -1
- package/dist/moderation/subjects/user-list.d.ts.map +1 -1
- package/dist/moderation/types.d.ts +1 -1
- package/dist/moderation/types.d.ts.map +1 -1
- package/dist/rich-text/rich-text.d.ts.map +1 -1
- package/dist/rich-text/rich-text.js +2 -2
- package/dist/rich-text/rich-text.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/util.d.ts +8 -8
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +7 -10
- package/dist/util.js.map +1 -1
- package/package.json +6 -6
- package/src/agent.ts +59 -9
- package/src/client/lexicons.ts +37 -0
- package/src/client/types/app/bsky/actor/defs.ts +36 -0
- package/src/client/types/app/bsky/feed/postgate.ts +1 -0
- package/src/client/types/app/bsky/feed/threadgate.ts +1 -0
- package/src/index.ts +3 -3
- package/src/mocker.ts +3 -3
- package/src/moderation/decision.ts +7 -7
- package/src/moderation/index.ts +11 -11
- package/src/moderation/subjects/account.ts +1 -1
- package/src/moderation/subjects/feed-generator.ts +1 -1
- package/src/moderation/subjects/notification.ts +1 -1
- package/src/moderation/subjects/post.ts +5 -5
- package/src/moderation/subjects/profile.ts +1 -1
- package/src/moderation/subjects/user-list.ts +1 -1
- package/src/moderation/types.ts +1 -1
- package/src/moderation/util.ts +1 -1
- package/src/rich-text/detection.ts +1 -1
- package/src/rich-text/rich-text.ts +2 -2
- package/src/types.ts +1 -0
- package/src/util.ts +8 -9
- package/tests/atp-agent.test.ts +179 -1
- package/tests/dispatcher.test.ts +4 -4
- package/tests/errors.test.ts +1 -1
- package/tests/moderation-behaviors.test.ts +3 -3
- package/tests/moderation-custom-labels.test.ts +4 -4
- package/tests/moderation-mutewords.test.ts +0 -1
- package/tests/moderation-prefs.test.ts +16 -0
- package/tests/moderation-quoteposts.test.ts +3 -3
- package/tests/moderation.test.ts +4 -4
- package/tests/rich-text-sanitization.test.ts +1 -1
- package/tests/util/moderation-behavior.ts +2 -2
- package/bench/agent.bench.ts +0 -9
|
@@ -2,10 +2,10 @@ import TLDs from 'tlds'
|
|
|
2
2
|
import { AppBskyRichtextFacet } from '../client'
|
|
3
3
|
import { UnicodeString } from './unicode'
|
|
4
4
|
import {
|
|
5
|
-
URL_REGEX,
|
|
6
5
|
MENTION_REGEX,
|
|
7
6
|
TAG_REGEX,
|
|
8
7
|
TRAILING_PUNCTUATION_REGEX,
|
|
8
|
+
URL_REGEX,
|
|
9
9
|
} from './util'
|
|
10
10
|
|
|
11
11
|
export type Facet = AppBskyRichtextFacet.Main
|
|
@@ -92,9 +92,9 @@ F: 0 1 2 3 4 5 6 7 8 910 // string indices
|
|
|
92
92
|
*/
|
|
93
93
|
|
|
94
94
|
import { AppBskyFeedPost, AppBskyRichtextFacet, AtpBaseClient } from '../client'
|
|
95
|
-
import { UnicodeString } from './unicode'
|
|
96
|
-
import { sanitizeRichText } from './sanitization'
|
|
97
95
|
import { detectFacets } from './detection'
|
|
96
|
+
import { sanitizeRichText } from './sanitization'
|
|
97
|
+
import { UnicodeString } from './unicode'
|
|
98
98
|
|
|
99
99
|
export type Facet = AppBskyRichtextFacet.Main
|
|
100
100
|
export type FacetLink = AppBskyRichtextFacet.Link
|
package/src/types.ts
CHANGED
package/src/util.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
import { TID } from '@atproto/common-web'
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { Nux } from './client/types/app/bsky/actor/defs'
|
|
3
|
+
import { AtUri } from '@atproto/syntax'
|
|
6
4
|
import { AppBskyActorDefs } from './client'
|
|
5
|
+
import { Nux } from './client/types/app/bsky/actor/defs'
|
|
7
6
|
|
|
8
7
|
export function sanitizeMutedWordValue(value: string) {
|
|
9
8
|
return (
|
|
@@ -97,12 +96,12 @@ export const asDid = (value: string): Did => {
|
|
|
97
96
|
throw new TypeError(`Invalid DID: ${value}`)
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
export const nuxSchema =
|
|
99
|
+
export const nuxSchema = z
|
|
101
100
|
.object({
|
|
102
|
-
id:
|
|
103
|
-
completed:
|
|
104
|
-
data:
|
|
105
|
-
expiresAt:
|
|
101
|
+
id: z.string().max(64),
|
|
102
|
+
completed: z.boolean(),
|
|
103
|
+
data: z.string().max(300).optional(),
|
|
104
|
+
expiresAt: z.string().datetime().optional(),
|
|
106
105
|
})
|
|
107
106
|
.strict()
|
|
108
107
|
|
package/tests/atp-agent.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TestNetworkNoAppView } from '@atproto/dev-env'
|
|
2
1
|
import { TID } from '@atproto/common-web'
|
|
2
|
+
import { TestNetworkNoAppView } from '@atproto/dev-env'
|
|
3
3
|
import {
|
|
4
4
|
AppBskyActorDefs,
|
|
5
5
|
AppBskyActorProfile,
|
|
@@ -278,6 +278,10 @@ describe('agent', () => {
|
|
|
278
278
|
queuedNudges: [],
|
|
279
279
|
nuxs: [],
|
|
280
280
|
},
|
|
281
|
+
postInteractionSettings: {
|
|
282
|
+
threadgateAllowRules: undefined,
|
|
283
|
+
postgateEmbeddingRules: undefined,
|
|
284
|
+
},
|
|
281
285
|
})
|
|
282
286
|
|
|
283
287
|
await agent.setAdultContentEnabled(true)
|
|
@@ -320,6 +324,10 @@ describe('agent', () => {
|
|
|
320
324
|
queuedNudges: [],
|
|
321
325
|
nuxs: [],
|
|
322
326
|
},
|
|
327
|
+
postInteractionSettings: {
|
|
328
|
+
threadgateAllowRules: undefined,
|
|
329
|
+
postgateEmbeddingRules: undefined,
|
|
330
|
+
},
|
|
323
331
|
})
|
|
324
332
|
|
|
325
333
|
await agent.setAdultContentEnabled(false)
|
|
@@ -362,6 +370,10 @@ describe('agent', () => {
|
|
|
362
370
|
queuedNudges: [],
|
|
363
371
|
nuxs: [],
|
|
364
372
|
},
|
|
373
|
+
postInteractionSettings: {
|
|
374
|
+
threadgateAllowRules: undefined,
|
|
375
|
+
postgateEmbeddingRules: undefined,
|
|
376
|
+
},
|
|
365
377
|
})
|
|
366
378
|
|
|
367
379
|
await agent.setContentLabelPref('misinfo', 'hide')
|
|
@@ -404,6 +416,10 @@ describe('agent', () => {
|
|
|
404
416
|
queuedNudges: [],
|
|
405
417
|
nuxs: [],
|
|
406
418
|
},
|
|
419
|
+
postInteractionSettings: {
|
|
420
|
+
threadgateAllowRules: undefined,
|
|
421
|
+
postgateEmbeddingRules: undefined,
|
|
422
|
+
},
|
|
407
423
|
})
|
|
408
424
|
|
|
409
425
|
await agent.setContentLabelPref('spam', 'ignore')
|
|
@@ -450,6 +466,10 @@ describe('agent', () => {
|
|
|
450
466
|
queuedNudges: [],
|
|
451
467
|
nuxs: [],
|
|
452
468
|
},
|
|
469
|
+
postInteractionSettings: {
|
|
470
|
+
threadgateAllowRules: undefined,
|
|
471
|
+
postgateEmbeddingRules: undefined,
|
|
472
|
+
},
|
|
453
473
|
})
|
|
454
474
|
|
|
455
475
|
await agent.addSavedFeed('at://bob.com/app.bsky.feed.generator/fake')
|
|
@@ -499,6 +519,10 @@ describe('agent', () => {
|
|
|
499
519
|
queuedNudges: [],
|
|
500
520
|
nuxs: [],
|
|
501
521
|
},
|
|
522
|
+
postInteractionSettings: {
|
|
523
|
+
threadgateAllowRules: undefined,
|
|
524
|
+
postgateEmbeddingRules: undefined,
|
|
525
|
+
},
|
|
502
526
|
})
|
|
503
527
|
|
|
504
528
|
await agent.addPinnedFeed('at://bob.com/app.bsky.feed.generator/fake')
|
|
@@ -548,6 +572,10 @@ describe('agent', () => {
|
|
|
548
572
|
queuedNudges: [],
|
|
549
573
|
nuxs: [],
|
|
550
574
|
},
|
|
575
|
+
postInteractionSettings: {
|
|
576
|
+
threadgateAllowRules: undefined,
|
|
577
|
+
postgateEmbeddingRules: undefined,
|
|
578
|
+
},
|
|
551
579
|
})
|
|
552
580
|
|
|
553
581
|
await agent.removePinnedFeed('at://bob.com/app.bsky.feed.generator/fake')
|
|
@@ -597,6 +625,10 @@ describe('agent', () => {
|
|
|
597
625
|
queuedNudges: [],
|
|
598
626
|
nuxs: [],
|
|
599
627
|
},
|
|
628
|
+
postInteractionSettings: {
|
|
629
|
+
threadgateAllowRules: undefined,
|
|
630
|
+
postgateEmbeddingRules: undefined,
|
|
631
|
+
},
|
|
600
632
|
})
|
|
601
633
|
|
|
602
634
|
await agent.removeSavedFeed('at://bob.com/app.bsky.feed.generator/fake')
|
|
@@ -646,6 +678,10 @@ describe('agent', () => {
|
|
|
646
678
|
queuedNudges: [],
|
|
647
679
|
nuxs: [],
|
|
648
680
|
},
|
|
681
|
+
postInteractionSettings: {
|
|
682
|
+
threadgateAllowRules: undefined,
|
|
683
|
+
postgateEmbeddingRules: undefined,
|
|
684
|
+
},
|
|
649
685
|
})
|
|
650
686
|
|
|
651
687
|
await agent.addPinnedFeed('at://bob.com/app.bsky.feed.generator/fake')
|
|
@@ -695,6 +731,10 @@ describe('agent', () => {
|
|
|
695
731
|
queuedNudges: [],
|
|
696
732
|
nuxs: [],
|
|
697
733
|
},
|
|
734
|
+
postInteractionSettings: {
|
|
735
|
+
threadgateAllowRules: undefined,
|
|
736
|
+
postgateEmbeddingRules: undefined,
|
|
737
|
+
},
|
|
698
738
|
})
|
|
699
739
|
|
|
700
740
|
await agent.addPinnedFeed('at://bob.com/app.bsky.feed.generator/fake2')
|
|
@@ -750,6 +790,10 @@ describe('agent', () => {
|
|
|
750
790
|
queuedNudges: [],
|
|
751
791
|
nuxs: [],
|
|
752
792
|
},
|
|
793
|
+
postInteractionSettings: {
|
|
794
|
+
threadgateAllowRules: undefined,
|
|
795
|
+
postgateEmbeddingRules: undefined,
|
|
796
|
+
},
|
|
753
797
|
})
|
|
754
798
|
|
|
755
799
|
await agent.removeSavedFeed('at://bob.com/app.bsky.feed.generator/fake')
|
|
@@ -799,6 +843,10 @@ describe('agent', () => {
|
|
|
799
843
|
queuedNudges: [],
|
|
800
844
|
nuxs: [],
|
|
801
845
|
},
|
|
846
|
+
postInteractionSettings: {
|
|
847
|
+
threadgateAllowRules: undefined,
|
|
848
|
+
postgateEmbeddingRules: undefined,
|
|
849
|
+
},
|
|
802
850
|
})
|
|
803
851
|
|
|
804
852
|
await agent.setPersonalDetails({ birthDate: '2023-09-11T18:05:42.556Z' })
|
|
@@ -848,6 +896,10 @@ describe('agent', () => {
|
|
|
848
896
|
queuedNudges: [],
|
|
849
897
|
nuxs: [],
|
|
850
898
|
},
|
|
899
|
+
postInteractionSettings: {
|
|
900
|
+
threadgateAllowRules: undefined,
|
|
901
|
+
postgateEmbeddingRules: undefined,
|
|
902
|
+
},
|
|
851
903
|
})
|
|
852
904
|
|
|
853
905
|
await agent.setFeedViewPrefs('home', { hideReplies: true })
|
|
@@ -897,6 +949,10 @@ describe('agent', () => {
|
|
|
897
949
|
queuedNudges: [],
|
|
898
950
|
nuxs: [],
|
|
899
951
|
},
|
|
952
|
+
postInteractionSettings: {
|
|
953
|
+
threadgateAllowRules: undefined,
|
|
954
|
+
postgateEmbeddingRules: undefined,
|
|
955
|
+
},
|
|
900
956
|
})
|
|
901
957
|
|
|
902
958
|
await agent.setFeedViewPrefs('home', { hideReplies: false })
|
|
@@ -946,6 +1002,10 @@ describe('agent', () => {
|
|
|
946
1002
|
queuedNudges: [],
|
|
947
1003
|
nuxs: [],
|
|
948
1004
|
},
|
|
1005
|
+
postInteractionSettings: {
|
|
1006
|
+
threadgateAllowRules: undefined,
|
|
1007
|
+
postgateEmbeddingRules: undefined,
|
|
1008
|
+
},
|
|
949
1009
|
})
|
|
950
1010
|
|
|
951
1011
|
await agent.setFeedViewPrefs('other', { hideReplies: true })
|
|
@@ -1002,6 +1062,10 @@ describe('agent', () => {
|
|
|
1002
1062
|
queuedNudges: [],
|
|
1003
1063
|
nuxs: [],
|
|
1004
1064
|
},
|
|
1065
|
+
postInteractionSettings: {
|
|
1066
|
+
threadgateAllowRules: undefined,
|
|
1067
|
+
postgateEmbeddingRules: undefined,
|
|
1068
|
+
},
|
|
1005
1069
|
})
|
|
1006
1070
|
|
|
1007
1071
|
await agent.setThreadViewPrefs({ sort: 'random' })
|
|
@@ -1058,6 +1122,10 @@ describe('agent', () => {
|
|
|
1058
1122
|
queuedNudges: [],
|
|
1059
1123
|
nuxs: [],
|
|
1060
1124
|
},
|
|
1125
|
+
postInteractionSettings: {
|
|
1126
|
+
threadgateAllowRules: undefined,
|
|
1127
|
+
postgateEmbeddingRules: undefined,
|
|
1128
|
+
},
|
|
1061
1129
|
})
|
|
1062
1130
|
|
|
1063
1131
|
await agent.setThreadViewPrefs({ sort: 'oldest' })
|
|
@@ -1114,6 +1182,10 @@ describe('agent', () => {
|
|
|
1114
1182
|
queuedNudges: [],
|
|
1115
1183
|
nuxs: [],
|
|
1116
1184
|
},
|
|
1185
|
+
postInteractionSettings: {
|
|
1186
|
+
threadgateAllowRules: undefined,
|
|
1187
|
+
postgateEmbeddingRules: undefined,
|
|
1188
|
+
},
|
|
1117
1189
|
})
|
|
1118
1190
|
|
|
1119
1191
|
await agent.setInterestsPref({ tags: ['foo', 'bar'] })
|
|
@@ -1170,6 +1242,10 @@ describe('agent', () => {
|
|
|
1170
1242
|
queuedNudges: [],
|
|
1171
1243
|
nuxs: [],
|
|
1172
1244
|
},
|
|
1245
|
+
postInteractionSettings: {
|
|
1246
|
+
threadgateAllowRules: undefined,
|
|
1247
|
+
postgateEmbeddingRules: undefined,
|
|
1248
|
+
},
|
|
1173
1249
|
})
|
|
1174
1250
|
})
|
|
1175
1251
|
|
|
@@ -1353,6 +1429,10 @@ describe('agent', () => {
|
|
|
1353
1429
|
queuedNudges: ['two'],
|
|
1354
1430
|
nuxs: [],
|
|
1355
1431
|
},
|
|
1432
|
+
postInteractionSettings: {
|
|
1433
|
+
threadgateAllowRules: undefined,
|
|
1434
|
+
postgateEmbeddingRules: undefined,
|
|
1435
|
+
},
|
|
1356
1436
|
})
|
|
1357
1437
|
|
|
1358
1438
|
await agent.setAdultContentEnabled(false)
|
|
@@ -1411,6 +1491,10 @@ describe('agent', () => {
|
|
|
1411
1491
|
queuedNudges: ['two'],
|
|
1412
1492
|
nuxs: [],
|
|
1413
1493
|
},
|
|
1494
|
+
postInteractionSettings: {
|
|
1495
|
+
threadgateAllowRules: undefined,
|
|
1496
|
+
postgateEmbeddingRules: undefined,
|
|
1497
|
+
},
|
|
1414
1498
|
})
|
|
1415
1499
|
|
|
1416
1500
|
await agent.setContentLabelPref('porn', 'ignore')
|
|
@@ -1470,6 +1554,10 @@ describe('agent', () => {
|
|
|
1470
1554
|
queuedNudges: ['two'],
|
|
1471
1555
|
nuxs: [],
|
|
1472
1556
|
},
|
|
1557
|
+
postInteractionSettings: {
|
|
1558
|
+
threadgateAllowRules: undefined,
|
|
1559
|
+
postgateEmbeddingRules: undefined,
|
|
1560
|
+
},
|
|
1473
1561
|
})
|
|
1474
1562
|
|
|
1475
1563
|
await agent.removeLabeler('did:plc:other')
|
|
@@ -1525,6 +1613,10 @@ describe('agent', () => {
|
|
|
1525
1613
|
queuedNudges: ['two'],
|
|
1526
1614
|
nuxs: [],
|
|
1527
1615
|
},
|
|
1616
|
+
postInteractionSettings: {
|
|
1617
|
+
threadgateAllowRules: undefined,
|
|
1618
|
+
postgateEmbeddingRules: undefined,
|
|
1619
|
+
},
|
|
1528
1620
|
})
|
|
1529
1621
|
|
|
1530
1622
|
await agent.addPinnedFeed('at://bob.com/app.bsky.feed.generator/fake')
|
|
@@ -1580,6 +1672,10 @@ describe('agent', () => {
|
|
|
1580
1672
|
queuedNudges: ['two'],
|
|
1581
1673
|
nuxs: [],
|
|
1582
1674
|
},
|
|
1675
|
+
postInteractionSettings: {
|
|
1676
|
+
threadgateAllowRules: undefined,
|
|
1677
|
+
postgateEmbeddingRules: undefined,
|
|
1678
|
+
},
|
|
1583
1679
|
})
|
|
1584
1680
|
|
|
1585
1681
|
await agent.setPersonalDetails({ birthDate: '2023-09-11T18:05:42.556Z' })
|
|
@@ -1635,6 +1731,10 @@ describe('agent', () => {
|
|
|
1635
1731
|
queuedNudges: ['two'],
|
|
1636
1732
|
nuxs: [],
|
|
1637
1733
|
},
|
|
1734
|
+
postInteractionSettings: {
|
|
1735
|
+
threadgateAllowRules: undefined,
|
|
1736
|
+
postgateEmbeddingRules: undefined,
|
|
1737
|
+
},
|
|
1638
1738
|
})
|
|
1639
1739
|
|
|
1640
1740
|
await agent.setFeedViewPrefs('home', {
|
|
@@ -1702,6 +1802,10 @@ describe('agent', () => {
|
|
|
1702
1802
|
queuedNudges: ['two', 'three'],
|
|
1703
1803
|
nuxs: [],
|
|
1704
1804
|
},
|
|
1805
|
+
postInteractionSettings: {
|
|
1806
|
+
threadgateAllowRules: undefined,
|
|
1807
|
+
postgateEmbeddingRules: undefined,
|
|
1808
|
+
},
|
|
1705
1809
|
})
|
|
1706
1810
|
|
|
1707
1811
|
const res = await agent.app.bsky.actor.getPreferences()
|
|
@@ -3337,6 +3441,80 @@ describe('agent', () => {
|
|
|
3337
3441
|
})
|
|
3338
3442
|
})
|
|
3339
3443
|
|
|
3444
|
+
describe('setPostInteractionSettings', () => {
|
|
3445
|
+
let agent: AtpAgent
|
|
3446
|
+
|
|
3447
|
+
beforeAll(async () => {
|
|
3448
|
+
agent = new AtpAgent({ service: network.pds.url })
|
|
3449
|
+
|
|
3450
|
+
await agent.createAccount({
|
|
3451
|
+
handle: 'pints.test',
|
|
3452
|
+
email: 'pints@test.com',
|
|
3453
|
+
password: 'password',
|
|
3454
|
+
})
|
|
3455
|
+
})
|
|
3456
|
+
|
|
3457
|
+
it('works', async () => {
|
|
3458
|
+
const next: AppBskyActorDefs.PostInteractionSettingsPref = {
|
|
3459
|
+
threadgateAllowRules: [
|
|
3460
|
+
{ $type: 'app.bsky.feed.threadgate#mentionRule' },
|
|
3461
|
+
],
|
|
3462
|
+
postgateEmbeddingRules: [],
|
|
3463
|
+
}
|
|
3464
|
+
|
|
3465
|
+
await agent.setPostInteractionSettings(next)
|
|
3466
|
+
|
|
3467
|
+
const prefs = await agent.getPreferences()
|
|
3468
|
+
|
|
3469
|
+
expect(prefs.postInteractionSettings).toEqual(next)
|
|
3470
|
+
})
|
|
3471
|
+
|
|
3472
|
+
it('clears', async () => {
|
|
3473
|
+
const next: AppBskyActorDefs.PostInteractionSettingsPref = {
|
|
3474
|
+
threadgateAllowRules: [],
|
|
3475
|
+
postgateEmbeddingRules: [],
|
|
3476
|
+
}
|
|
3477
|
+
|
|
3478
|
+
await agent.setPostInteractionSettings(next)
|
|
3479
|
+
|
|
3480
|
+
const prefs = await agent.getPreferences()
|
|
3481
|
+
|
|
3482
|
+
expect(prefs.postInteractionSettings).toEqual(next)
|
|
3483
|
+
})
|
|
3484
|
+
|
|
3485
|
+
/**
|
|
3486
|
+
* Logic matches threadgate `allow` logic, where `undefined` means "anyone
|
|
3487
|
+
* can reply" and an empty array means "no one can reply".
|
|
3488
|
+
*
|
|
3489
|
+
* Postgate `embeddingRules` behaves differently, where `undefined` and
|
|
3490
|
+
* an empty array both mean "no particular rules applied".
|
|
3491
|
+
*
|
|
3492
|
+
* Both props are optional though, so for easier sharing of types, we
|
|
3493
|
+
* allow `undefined`.
|
|
3494
|
+
*/
|
|
3495
|
+
it('clears using undefined', async () => {
|
|
3496
|
+
const next: AppBskyActorDefs.PostInteractionSettingsPref = {
|
|
3497
|
+
threadgateAllowRules: undefined,
|
|
3498
|
+
postgateEmbeddingRules: undefined,
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3501
|
+
await agent.setPostInteractionSettings(next)
|
|
3502
|
+
|
|
3503
|
+
const prefs = await agent.getPreferences()
|
|
3504
|
+
|
|
3505
|
+
expect(prefs.postInteractionSettings).toEqual(next)
|
|
3506
|
+
})
|
|
3507
|
+
|
|
3508
|
+
it('validates inputs', async () => {
|
|
3509
|
+
expect(() =>
|
|
3510
|
+
agent.setPostInteractionSettings({
|
|
3511
|
+
threadgateAllowRules: [{ key: 'string' }],
|
|
3512
|
+
postgateEmbeddingRules: [],
|
|
3513
|
+
}),
|
|
3514
|
+
).rejects.toThrow()
|
|
3515
|
+
})
|
|
3516
|
+
})
|
|
3517
|
+
|
|
3340
3518
|
// end
|
|
3341
3519
|
})
|
|
3342
3520
|
})
|
package/tests/dispatcher.test.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import assert from 'node:assert'
|
|
1
2
|
import { AddressInfo } from 'node:net'
|
|
2
|
-
import
|
|
3
|
+
import { getPdsEndpoint, isValidDidDoc } from '@atproto/common-web'
|
|
4
|
+
import { TestNetworkNoAppView } from '@atproto/dev-env'
|
|
3
5
|
import {
|
|
4
6
|
AtpAgent,
|
|
5
|
-
AtpSessionEvent,
|
|
6
7
|
AtpSessionData,
|
|
8
|
+
AtpSessionEvent,
|
|
7
9
|
BSKY_LABELER_DID,
|
|
8
10
|
} from '../src'
|
|
9
|
-
import { TestNetworkNoAppView } from '@atproto/dev-env'
|
|
10
|
-
import { getPdsEndpoint, isValidDidDoc } from '@atproto/common-web'
|
|
11
11
|
import { createHeaderEchoServer } from './util/echo-server'
|
|
12
12
|
|
|
13
13
|
const getPdsEndpointUrl = (...args: Parameters<typeof getPdsEndpoint>) => {
|
package/tests/errors.test.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { moderatePost, moderateProfile } from '../src'
|
|
2
2
|
import {
|
|
3
3
|
ModerationBehaviorSuiteRunner,
|
|
4
|
-
|
|
4
|
+
ModerationTestSuiteScenario,
|
|
5
5
|
SuiteConfigurations,
|
|
6
6
|
SuiteScenarios,
|
|
7
|
-
|
|
7
|
+
SuiteUsers,
|
|
8
8
|
} from './util/moderation-behavior'
|
|
9
9
|
|
|
10
10
|
const USERS: SuiteUsers = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
moderateProfile,
|
|
3
|
-
moderatePost,
|
|
4
|
-
mock,
|
|
5
|
-
ModerationOpts,
|
|
6
2
|
InterpretedLabelValueDefinition,
|
|
3
|
+
ModerationOpts,
|
|
7
4
|
interpretLabelValueDefinition,
|
|
5
|
+
mock,
|
|
6
|
+
moderatePost,
|
|
7
|
+
moderateProfile,
|
|
8
8
|
} from '../src'
|
|
9
9
|
import './util/moderation-behavior'
|
|
10
10
|
|
|
@@ -86,6 +86,10 @@ describe('agent', () => {
|
|
|
86
86
|
queuedNudges: [],
|
|
87
87
|
nuxs: [],
|
|
88
88
|
},
|
|
89
|
+
postInteractionSettings: {
|
|
90
|
+
threadgateAllowRules: undefined,
|
|
91
|
+
postgateEmbeddingRules: undefined,
|
|
92
|
+
},
|
|
89
93
|
})
|
|
90
94
|
})
|
|
91
95
|
|
|
@@ -136,6 +140,10 @@ describe('agent', () => {
|
|
|
136
140
|
queuedNudges: [],
|
|
137
141
|
nuxs: [],
|
|
138
142
|
},
|
|
143
|
+
postInteractionSettings: {
|
|
144
|
+
threadgateAllowRules: undefined,
|
|
145
|
+
postgateEmbeddingRules: undefined,
|
|
146
|
+
},
|
|
139
147
|
})
|
|
140
148
|
expect(agent.labelers).toStrictEqual(['did:plc:other'])
|
|
141
149
|
|
|
@@ -171,6 +179,10 @@ describe('agent', () => {
|
|
|
171
179
|
queuedNudges: [],
|
|
172
180
|
nuxs: [],
|
|
173
181
|
},
|
|
182
|
+
postInteractionSettings: {
|
|
183
|
+
threadgateAllowRules: undefined,
|
|
184
|
+
postgateEmbeddingRules: undefined,
|
|
185
|
+
},
|
|
174
186
|
})
|
|
175
187
|
expect(agent.labelers).toStrictEqual([])
|
|
176
188
|
})
|
|
@@ -228,6 +240,10 @@ describe('agent', () => {
|
|
|
228
240
|
queuedNudges: [],
|
|
229
241
|
nuxs: [],
|
|
230
242
|
},
|
|
243
|
+
postInteractionSettings: {
|
|
244
|
+
threadgateAllowRules: undefined,
|
|
245
|
+
postgateEmbeddingRules: undefined,
|
|
246
|
+
},
|
|
231
247
|
})
|
|
232
248
|
})
|
|
233
249
|
|
package/tests/moderation.test.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { ModerationOpts } from '../dist'
|
|
1
2
|
import {
|
|
2
|
-
moderateProfile,
|
|
3
|
-
moderatePost,
|
|
4
|
-
mock,
|
|
5
3
|
interpretLabelValueDefinition,
|
|
4
|
+
mock,
|
|
5
|
+
moderatePost,
|
|
6
|
+
moderateProfile,
|
|
6
7
|
} from '../src'
|
|
7
8
|
import './util/moderation-behavior'
|
|
8
|
-
import { ModerationOpts } from '../dist'
|
|
9
9
|
|
|
10
10
|
describe('Moderation', () => {
|
|
11
11
|
it('Applies self-labels on profiles according to the global preferences', () => {
|
package/bench/agent.bench.ts
DELETED