@atproto/ozone 0.1.79 → 0.1.81
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 +15 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/moderation/getReporterStats.d.ts +4 -0
- package/dist/api/moderation/getReporterStats.d.ts.map +1 -0
- package/dist/api/moderation/getReporterStats.js +17 -0
- package/dist/api/moderation/getReporterStats.js.map +1 -0
- package/dist/daemon/materialized-view-refresher.d.ts.map +1 -1
- package/dist/daemon/materialized-view-refresher.js +1 -0
- package/dist/daemon/materialized-view-refresher.js.map +1 -1
- package/dist/db/migrations/20250211T003647759Z-add-reporter-stats-index.d.ts +4 -0
- package/dist/db/migrations/20250211T003647759Z-add-reporter-stats-index.d.ts.map +1 -0
- package/dist/db/migrations/20250211T003647759Z-add-reporter-stats-index.js +38 -0
- package/dist/db/migrations/20250211T003647759Z-add-reporter-stats-index.js.map +1 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/db/migrations/index.d.ts.map +1 -1
- package/dist/db/migrations/index.js +2 -1
- package/dist/db/migrations/index.js.map +1 -1
- package/dist/lexicon/index.d.ts +4 -0
- package/dist/lexicon/index.d.ts.map +1 -1
- package/dist/lexicon/index.js +8 -0
- package/dist/lexicon/index.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +300 -0
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +162 -0
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/com/atproto/sync/listReposByCollection.d.ts +46 -0
- package/dist/lexicon/types/com/atproto/sync/listReposByCollection.d.ts.map +1 -0
- package/dist/lexicon/types/com/atproto/sync/listReposByCollection.js +16 -0
- package/dist/lexicon/types/com/atproto/sync/listReposByCollection.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts +22 -0
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/defs.js +9 -0
- package/dist/lexicon/types/tools/ozone/moderation/defs.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/getReporterStats.d.ts +36 -0
- package/dist/lexicon/types/tools/ozone/moderation/getReporterStats.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/moderation/getReporterStats.js +7 -0
- package/dist/lexicon/types/tools/ozone/moderation/getReporterStats.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/team/listMembers.d.ts +2 -0
- package/dist/lexicon/types/tools/ozone/team/listMembers.d.ts.map +1 -1
- package/dist/mod-service/index.d.ts +5 -1
- package/dist/mod-service/index.d.ts.map +1 -1
- package/dist/mod-service/index.js +94 -0
- package/dist/mod-service/index.js.map +1 -1
- package/dist/mod-service/types.d.ts +21 -0
- package/dist/mod-service/types.d.ts.map +1 -1
- package/dist/team/index.d.ts +3 -1
- package/dist/team/index.d.ts.map +1 -1
- package/dist/team/index.js +13 -1
- package/dist/team/index.js.map +1 -1
- package/package.json +3 -3
- package/src/api/index.ts +2 -0
- package/src/api/moderation/getReporterStats.ts +18 -0
- package/src/daemon/materialized-view-refresher.ts +1 -0
- package/src/db/migrations/20250211T003647759Z-add-reporter-stats-index.ts +38 -0
- package/src/db/migrations/index.ts +1 -0
- package/src/lexicon/index.ts +24 -0
- package/src/lexicon/lexicons.ts +171 -0
- package/src/lexicon/types/com/atproto/sync/listReposByCollection.ts +68 -0
- package/src/lexicon/types/tools/ozone/moderation/defs.ts +31 -0
- package/src/lexicon/types/tools/ozone/moderation/getReporterStats.ts +50 -0
- package/src/lexicon/types/tools/ozone/team/listMembers.ts +2 -0
- package/src/mod-service/index.ts +126 -0
- package/src/mod-service/types.ts +23 -0
- package/src/team/index.ts +20 -0
- package/tests/__snapshots__/team.test.ts.snap +0 -338
- package/tests/get-reporter-stats.test.ts +117 -0
- package/tests/team.test.ts +56 -26
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.tests.tsbuildinfo +1 -1
|
@@ -348,341 +348,3 @@ Array [
|
|
|
348
348
|
},
|
|
349
349
|
]
|
|
350
350
|
`;
|
|
351
|
-
|
|
352
|
-
exports[`team management listMembers allows all members to list all members 3`] = `
|
|
353
|
-
Array [
|
|
354
|
-
Object {
|
|
355
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
356
|
-
"did": "user(0)",
|
|
357
|
-
"disabled": false,
|
|
358
|
-
"lastUpdatedBy": "user(1)",
|
|
359
|
-
"role": "tools.ozone.team.defs#roleAdmin",
|
|
360
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
361
|
-
},
|
|
362
|
-
Object {
|
|
363
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
364
|
-
"did": "user(2)",
|
|
365
|
-
"disabled": false,
|
|
366
|
-
"lastUpdatedBy": "user(1)",
|
|
367
|
-
"role": "tools.ozone.team.defs#roleTriage",
|
|
368
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
369
|
-
},
|
|
370
|
-
Object {
|
|
371
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
372
|
-
"did": "user(3)",
|
|
373
|
-
"disabled": false,
|
|
374
|
-
"lastUpdatedBy": "user(1)",
|
|
375
|
-
"role": "tools.ozone.team.defs#roleModerator",
|
|
376
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
377
|
-
},
|
|
378
|
-
Object {
|
|
379
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
380
|
-
"did": "user(4)",
|
|
381
|
-
"disabled": false,
|
|
382
|
-
"lastUpdatedBy": "user(1)",
|
|
383
|
-
"role": "tools.ozone.team.defs#roleModerator",
|
|
384
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
385
|
-
},
|
|
386
|
-
Object {
|
|
387
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
388
|
-
"did": "user(1)",
|
|
389
|
-
"disabled": false,
|
|
390
|
-
"lastUpdatedBy": "user(1)",
|
|
391
|
-
"profile": Object {
|
|
392
|
-
"associated": Object {
|
|
393
|
-
"feedgens": 0,
|
|
394
|
-
"labeler": true,
|
|
395
|
-
"lists": 0,
|
|
396
|
-
"starterPacks": 0,
|
|
397
|
-
},
|
|
398
|
-
"description": "The pretend version of mod.bsky.app",
|
|
399
|
-
"did": "user(1)",
|
|
400
|
-
"displayName": "Dev-env Moderation",
|
|
401
|
-
"followersCount": 0,
|
|
402
|
-
"followsCount": 0,
|
|
403
|
-
"handle": "mod-authority.test",
|
|
404
|
-
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
405
|
-
"labels": Array [],
|
|
406
|
-
"postsCount": 0,
|
|
407
|
-
"viewer": Object {
|
|
408
|
-
"blockedBy": false,
|
|
409
|
-
"muted": false,
|
|
410
|
-
},
|
|
411
|
-
},
|
|
412
|
-
"role": "tools.ozone.team.defs#roleAdmin",
|
|
413
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
414
|
-
},
|
|
415
|
-
Object {
|
|
416
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
417
|
-
"did": "user(5)",
|
|
418
|
-
"disabled": false,
|
|
419
|
-
"lastUpdatedBy": "user(1)",
|
|
420
|
-
"profile": Object {
|
|
421
|
-
"associated": Object {
|
|
422
|
-
"feedgens": 0,
|
|
423
|
-
"labeler": false,
|
|
424
|
-
"lists": 0,
|
|
425
|
-
"starterPacks": 0,
|
|
426
|
-
},
|
|
427
|
-
"avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(0)@jpeg",
|
|
428
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
429
|
-
"description": "its me!",
|
|
430
|
-
"did": "user(5)",
|
|
431
|
-
"displayName": "ali",
|
|
432
|
-
"followersCount": 2,
|
|
433
|
-
"followsCount": 3,
|
|
434
|
-
"handle": "alice.test",
|
|
435
|
-
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
436
|
-
"labels": Array [
|
|
437
|
-
Object {
|
|
438
|
-
"cid": "cids(1)",
|
|
439
|
-
"cts": "1970-01-01T00:00:00.000Z",
|
|
440
|
-
"src": "user(5)",
|
|
441
|
-
"uri": "record(0)",
|
|
442
|
-
"val": "self-label-a",
|
|
443
|
-
},
|
|
444
|
-
Object {
|
|
445
|
-
"cid": "cids(1)",
|
|
446
|
-
"cts": "1970-01-01T00:00:00.000Z",
|
|
447
|
-
"src": "user(5)",
|
|
448
|
-
"uri": "record(0)",
|
|
449
|
-
"val": "self-label-b",
|
|
450
|
-
},
|
|
451
|
-
],
|
|
452
|
-
"postsCount": 4,
|
|
453
|
-
"viewer": Object {
|
|
454
|
-
"blockedBy": false,
|
|
455
|
-
"muted": false,
|
|
456
|
-
},
|
|
457
|
-
},
|
|
458
|
-
"role": "tools.ozone.team.defs#roleAdmin",
|
|
459
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
460
|
-
},
|
|
461
|
-
Object {
|
|
462
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
463
|
-
"did": "user(7)",
|
|
464
|
-
"disabled": false,
|
|
465
|
-
"lastUpdatedBy": "user(1)",
|
|
466
|
-
"profile": Object {
|
|
467
|
-
"associated": Object {
|
|
468
|
-
"feedgens": 0,
|
|
469
|
-
"labeler": false,
|
|
470
|
-
"lists": 0,
|
|
471
|
-
"starterPacks": 0,
|
|
472
|
-
},
|
|
473
|
-
"avatar": "https://bsky.public.url/img/avatar/plain/user(8)/cids(0)@jpeg",
|
|
474
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
475
|
-
"description": "hi im bob label_me",
|
|
476
|
-
"did": "user(7)",
|
|
477
|
-
"displayName": "bobby",
|
|
478
|
-
"followersCount": 2,
|
|
479
|
-
"followsCount": 2,
|
|
480
|
-
"handle": "bob.test",
|
|
481
|
-
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
482
|
-
"labels": Array [],
|
|
483
|
-
"postsCount": 3,
|
|
484
|
-
"viewer": Object {
|
|
485
|
-
"blockedBy": false,
|
|
486
|
-
"muted": false,
|
|
487
|
-
},
|
|
488
|
-
},
|
|
489
|
-
"role": "tools.ozone.team.defs#roleModerator",
|
|
490
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
491
|
-
},
|
|
492
|
-
Object {
|
|
493
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
494
|
-
"did": "user(9)",
|
|
495
|
-
"disabled": false,
|
|
496
|
-
"lastUpdatedBy": "user(1)",
|
|
497
|
-
"profile": Object {
|
|
498
|
-
"associated": Object {
|
|
499
|
-
"feedgens": 0,
|
|
500
|
-
"labeler": false,
|
|
501
|
-
"lists": 0,
|
|
502
|
-
"starterPacks": 0,
|
|
503
|
-
},
|
|
504
|
-
"did": "user(9)",
|
|
505
|
-
"followersCount": 2,
|
|
506
|
-
"followsCount": 1,
|
|
507
|
-
"handle": "carol.test",
|
|
508
|
-
"labels": Array [],
|
|
509
|
-
"postsCount": 2,
|
|
510
|
-
"viewer": Object {
|
|
511
|
-
"blockedBy": false,
|
|
512
|
-
"muted": false,
|
|
513
|
-
},
|
|
514
|
-
},
|
|
515
|
-
"role": "tools.ozone.team.defs#roleTriage",
|
|
516
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
517
|
-
},
|
|
518
|
-
]
|
|
519
|
-
`;
|
|
520
|
-
|
|
521
|
-
exports[`team management listMembers allows all members to list all members 4`] = `
|
|
522
|
-
Array [
|
|
523
|
-
Object {
|
|
524
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
525
|
-
"did": "user(0)",
|
|
526
|
-
"disabled": false,
|
|
527
|
-
"lastUpdatedBy": "user(1)",
|
|
528
|
-
"role": "tools.ozone.team.defs#roleAdmin",
|
|
529
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
530
|
-
},
|
|
531
|
-
Object {
|
|
532
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
533
|
-
"did": "user(2)",
|
|
534
|
-
"disabled": false,
|
|
535
|
-
"lastUpdatedBy": "user(1)",
|
|
536
|
-
"role": "tools.ozone.team.defs#roleTriage",
|
|
537
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
538
|
-
},
|
|
539
|
-
Object {
|
|
540
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
541
|
-
"did": "user(3)",
|
|
542
|
-
"disabled": false,
|
|
543
|
-
"lastUpdatedBy": "user(1)",
|
|
544
|
-
"role": "tools.ozone.team.defs#roleModerator",
|
|
545
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
546
|
-
},
|
|
547
|
-
Object {
|
|
548
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
549
|
-
"did": "user(4)",
|
|
550
|
-
"disabled": false,
|
|
551
|
-
"lastUpdatedBy": "user(1)",
|
|
552
|
-
"role": "tools.ozone.team.defs#roleModerator",
|
|
553
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
554
|
-
},
|
|
555
|
-
Object {
|
|
556
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
557
|
-
"did": "user(1)",
|
|
558
|
-
"disabled": false,
|
|
559
|
-
"lastUpdatedBy": "user(1)",
|
|
560
|
-
"profile": Object {
|
|
561
|
-
"associated": Object {
|
|
562
|
-
"feedgens": 0,
|
|
563
|
-
"labeler": true,
|
|
564
|
-
"lists": 0,
|
|
565
|
-
"starterPacks": 0,
|
|
566
|
-
},
|
|
567
|
-
"description": "The pretend version of mod.bsky.app",
|
|
568
|
-
"did": "user(1)",
|
|
569
|
-
"displayName": "Dev-env Moderation",
|
|
570
|
-
"followersCount": 0,
|
|
571
|
-
"followsCount": 0,
|
|
572
|
-
"handle": "mod-authority.test",
|
|
573
|
-
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
574
|
-
"labels": Array [],
|
|
575
|
-
"postsCount": 0,
|
|
576
|
-
"viewer": Object {
|
|
577
|
-
"blockedBy": false,
|
|
578
|
-
"muted": false,
|
|
579
|
-
},
|
|
580
|
-
},
|
|
581
|
-
"role": "tools.ozone.team.defs#roleAdmin",
|
|
582
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
583
|
-
},
|
|
584
|
-
Object {
|
|
585
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
586
|
-
"did": "user(5)",
|
|
587
|
-
"disabled": false,
|
|
588
|
-
"lastUpdatedBy": "user(1)",
|
|
589
|
-
"profile": Object {
|
|
590
|
-
"associated": Object {
|
|
591
|
-
"feedgens": 0,
|
|
592
|
-
"labeler": false,
|
|
593
|
-
"lists": 0,
|
|
594
|
-
"starterPacks": 0,
|
|
595
|
-
},
|
|
596
|
-
"avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(0)@jpeg",
|
|
597
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
598
|
-
"description": "its me!",
|
|
599
|
-
"did": "user(5)",
|
|
600
|
-
"displayName": "ali",
|
|
601
|
-
"followersCount": 2,
|
|
602
|
-
"followsCount": 3,
|
|
603
|
-
"handle": "alice.test",
|
|
604
|
-
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
605
|
-
"labels": Array [
|
|
606
|
-
Object {
|
|
607
|
-
"cid": "cids(1)",
|
|
608
|
-
"cts": "1970-01-01T00:00:00.000Z",
|
|
609
|
-
"src": "user(5)",
|
|
610
|
-
"uri": "record(0)",
|
|
611
|
-
"val": "self-label-a",
|
|
612
|
-
},
|
|
613
|
-
Object {
|
|
614
|
-
"cid": "cids(1)",
|
|
615
|
-
"cts": "1970-01-01T00:00:00.000Z",
|
|
616
|
-
"src": "user(5)",
|
|
617
|
-
"uri": "record(0)",
|
|
618
|
-
"val": "self-label-b",
|
|
619
|
-
},
|
|
620
|
-
],
|
|
621
|
-
"postsCount": 4,
|
|
622
|
-
"viewer": Object {
|
|
623
|
-
"blockedBy": false,
|
|
624
|
-
"muted": false,
|
|
625
|
-
},
|
|
626
|
-
},
|
|
627
|
-
"role": "tools.ozone.team.defs#roleAdmin",
|
|
628
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
629
|
-
},
|
|
630
|
-
Object {
|
|
631
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
632
|
-
"did": "user(7)",
|
|
633
|
-
"disabled": false,
|
|
634
|
-
"lastUpdatedBy": "user(1)",
|
|
635
|
-
"profile": Object {
|
|
636
|
-
"associated": Object {
|
|
637
|
-
"feedgens": 0,
|
|
638
|
-
"labeler": false,
|
|
639
|
-
"lists": 0,
|
|
640
|
-
"starterPacks": 0,
|
|
641
|
-
},
|
|
642
|
-
"avatar": "https://bsky.public.url/img/avatar/plain/user(8)/cids(0)@jpeg",
|
|
643
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
644
|
-
"description": "hi im bob label_me",
|
|
645
|
-
"did": "user(7)",
|
|
646
|
-
"displayName": "bobby",
|
|
647
|
-
"followersCount": 2,
|
|
648
|
-
"followsCount": 2,
|
|
649
|
-
"handle": "bob.test",
|
|
650
|
-
"indexedAt": "1970-01-01T00:00:00.000Z",
|
|
651
|
-
"labels": Array [],
|
|
652
|
-
"postsCount": 3,
|
|
653
|
-
"viewer": Object {
|
|
654
|
-
"blockedBy": false,
|
|
655
|
-
"muted": false,
|
|
656
|
-
},
|
|
657
|
-
},
|
|
658
|
-
"role": "tools.ozone.team.defs#roleModerator",
|
|
659
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
660
|
-
},
|
|
661
|
-
Object {
|
|
662
|
-
"createdAt": "1970-01-01T00:00:00.000Z",
|
|
663
|
-
"did": "user(9)",
|
|
664
|
-
"disabled": false,
|
|
665
|
-
"lastUpdatedBy": "user(1)",
|
|
666
|
-
"profile": Object {
|
|
667
|
-
"associated": Object {
|
|
668
|
-
"feedgens": 0,
|
|
669
|
-
"labeler": false,
|
|
670
|
-
"lists": 0,
|
|
671
|
-
"starterPacks": 0,
|
|
672
|
-
},
|
|
673
|
-
"did": "user(9)",
|
|
674
|
-
"followersCount": 2,
|
|
675
|
-
"followsCount": 1,
|
|
676
|
-
"handle": "carol.test",
|
|
677
|
-
"labels": Array [],
|
|
678
|
-
"postsCount": 2,
|
|
679
|
-
"viewer": Object {
|
|
680
|
-
"blockedBy": false,
|
|
681
|
-
"muted": false,
|
|
682
|
-
},
|
|
683
|
-
},
|
|
684
|
-
"role": "tools.ozone.team.defs#roleTriage",
|
|
685
|
-
"updatedAt": "1970-01-01T00:00:00.000Z",
|
|
686
|
-
},
|
|
687
|
-
]
|
|
688
|
-
`;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ComAtprotoModerationDefs,
|
|
3
|
+
ToolsOzoneModerationDefs,
|
|
4
|
+
} from '@atproto/api'
|
|
5
|
+
import {
|
|
6
|
+
ModeratorClient,
|
|
7
|
+
SeedClient,
|
|
8
|
+
TestNetwork,
|
|
9
|
+
basicSeed,
|
|
10
|
+
} from '@atproto/dev-env'
|
|
11
|
+
|
|
12
|
+
describe('reporter-stats', () => {
|
|
13
|
+
let network: TestNetwork
|
|
14
|
+
let sc: SeedClient
|
|
15
|
+
let modClient: ModeratorClient
|
|
16
|
+
|
|
17
|
+
beforeAll(async () => {
|
|
18
|
+
network = await TestNetwork.create({
|
|
19
|
+
dbPostgresSchema: 'ozone_reporter_stats',
|
|
20
|
+
ozone: {
|
|
21
|
+
dbMaterializedViewRefreshIntervalMs: 1000,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
sc = network.getSeedClient()
|
|
25
|
+
modClient = network.ozone.getModClient()
|
|
26
|
+
await basicSeed(sc)
|
|
27
|
+
await network.processAll()
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
afterAll(async () => {
|
|
31
|
+
await network.close()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const getReporterStats = async (
|
|
35
|
+
did: string,
|
|
36
|
+
): Promise<ToolsOzoneModerationDefs.ReporterStats | undefined> => {
|
|
37
|
+
const { stats } = await modClient.getReporterStats([did])
|
|
38
|
+
return stats[0]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
it('updates reporter stats based on actions', async () => {
|
|
42
|
+
const bobsPostSubject = {
|
|
43
|
+
$type: 'com.atproto.repo.strongRef',
|
|
44
|
+
uri: sc.posts[sc.dids.bob][1].ref.uriStr,
|
|
45
|
+
cid: sc.posts[sc.dids.bob][1].ref.cidStr,
|
|
46
|
+
}
|
|
47
|
+
const carolsAccountSubject = {
|
|
48
|
+
$type: 'com.atproto.admin.defs#repoRef',
|
|
49
|
+
did: sc.dids.carol,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await Promise.all([
|
|
53
|
+
sc.createReport({
|
|
54
|
+
reportedBy: sc.dids.alice,
|
|
55
|
+
reasonType: ComAtprotoModerationDefs.REASONMISLEADING,
|
|
56
|
+
reason: 'misleading',
|
|
57
|
+
subject: bobsPostSubject,
|
|
58
|
+
}),
|
|
59
|
+
sc.createReport({
|
|
60
|
+
reportedBy: sc.dids.alice,
|
|
61
|
+
reasonType: ComAtprotoModerationDefs.REASONOTHER,
|
|
62
|
+
reason: 'test',
|
|
63
|
+
subject: bobsPostSubject,
|
|
64
|
+
}),
|
|
65
|
+
sc.createReport({
|
|
66
|
+
reportedBy: sc.dids.alice,
|
|
67
|
+
reasonType: ComAtprotoModerationDefs.REASONMISLEADING,
|
|
68
|
+
reason: 'misleading',
|
|
69
|
+
subject: carolsAccountSubject,
|
|
70
|
+
}),
|
|
71
|
+
])
|
|
72
|
+
|
|
73
|
+
await network.processAll()
|
|
74
|
+
const statsAfterReport = await getReporterStats(sc.dids.alice)
|
|
75
|
+
expect(statsAfterReport).toMatchObject({
|
|
76
|
+
did: sc.dids.alice,
|
|
77
|
+
accountReportCount: 1,
|
|
78
|
+
recordReportCount: 2,
|
|
79
|
+
reportedAccountCount: 1,
|
|
80
|
+
reportedRecordCount: 1,
|
|
81
|
+
takendownAccountCount: 0,
|
|
82
|
+
takendownRecordCount: 0,
|
|
83
|
+
labeledAccountCount: 0,
|
|
84
|
+
labeledRecordCount: 0,
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
await Promise.all([
|
|
88
|
+
modClient.performTakedown({
|
|
89
|
+
subject: bobsPostSubject,
|
|
90
|
+
policies: ['trolling'],
|
|
91
|
+
}),
|
|
92
|
+
modClient.emitEvent({
|
|
93
|
+
subject: carolsAccountSubject,
|
|
94
|
+
event: {
|
|
95
|
+
$type: 'tools.ozone.moderation.defs#modEventLabel',
|
|
96
|
+
createLabelVals: ['spam'],
|
|
97
|
+
negateLabelVals: [],
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
])
|
|
101
|
+
|
|
102
|
+
await network.processAll()
|
|
103
|
+
await new Promise((resolve) => setTimeout(resolve, 1000))
|
|
104
|
+
const statsAfterAction = await getReporterStats(sc.dids.alice)
|
|
105
|
+
expect(statsAfterAction).toMatchObject({
|
|
106
|
+
did: sc.dids.alice,
|
|
107
|
+
accountReportCount: 1,
|
|
108
|
+
recordReportCount: 2,
|
|
109
|
+
reportedAccountCount: 1,
|
|
110
|
+
reportedRecordCount: 1,
|
|
111
|
+
takendownAccountCount: 0,
|
|
112
|
+
takendownRecordCount: 1,
|
|
113
|
+
labeledAccountCount: 1,
|
|
114
|
+
labeledRecordCount: 0,
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
})
|
package/tests/team.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AtpAgent } from '@atproto/api'
|
|
1
|
+
import { AtpAgent, ToolsOzoneTeamDefs } from '@atproto/api'
|
|
2
2
|
import { SeedClient, TestNetwork, basicSeed } from '@atproto/dev-env'
|
|
3
3
|
import { forSnapshot } from './_util'
|
|
4
4
|
|
|
@@ -38,8 +38,8 @@ describe('team management', () => {
|
|
|
38
38
|
describe('listMembers', () => {
|
|
39
39
|
it('allows all members to list all members', async () => {
|
|
40
40
|
const [{ data: forAdmin }, { data: forTriage }] = await Promise.all([
|
|
41
|
-
adminAgent.
|
|
42
|
-
triageAgent.
|
|
41
|
+
adminAgent.tools.ozone.team.listMembers({}),
|
|
42
|
+
triageAgent.tools.ozone.team.listMembers({}),
|
|
43
43
|
])
|
|
44
44
|
expect(forSnapshot(forAdmin.members)).toMatchSnapshot()
|
|
45
45
|
expect(forSnapshot(forTriage.members)).toMatchSnapshot()
|
|
@@ -47,20 +47,50 @@ describe('team management', () => {
|
|
|
47
47
|
|
|
48
48
|
expect(forAdmin.members.length).toEqual(forTriage.members.length)
|
|
49
49
|
})
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
it('allows filtering members by role', async () => {
|
|
51
|
+
const [{ data: onlyAdmins }, { data: onlyTriage }] = await Promise.all([
|
|
52
|
+
adminAgent.tools.ozone.team.listMembers({
|
|
53
|
+
roles: [ToolsOzoneTeamDefs.ROLEADMIN],
|
|
54
|
+
}),
|
|
55
|
+
adminAgent.tools.ozone.team.listMembers({
|
|
56
|
+
roles: [ToolsOzoneTeamDefs.ROLETRIAGE],
|
|
57
|
+
}),
|
|
56
58
|
])
|
|
57
|
-
expect(forSnapshot(forAdmin.members)).toMatchSnapshot()
|
|
58
|
-
expect(forSnapshot(forTriage.members)).toMatchSnapshot()
|
|
59
|
-
// Validate that the list looks the same to both admin and triage members
|
|
60
59
|
|
|
61
|
-
expect(
|
|
60
|
+
expect(
|
|
61
|
+
onlyAdmins.members.find(
|
|
62
|
+
({ role }) => role !== ToolsOzoneTeamDefs.ROLEADMIN,
|
|
63
|
+
),
|
|
64
|
+
).toBeUndefined()
|
|
65
|
+
|
|
66
|
+
expect(
|
|
67
|
+
onlyTriage.members.find(
|
|
68
|
+
({ role }) => role !== ToolsOzoneTeamDefs.ROLETRIAGE,
|
|
69
|
+
),
|
|
70
|
+
).toBeUndefined()
|
|
71
|
+
})
|
|
72
|
+
it('allows filtering members by disabled status', async () => {
|
|
73
|
+
const [{ data: onlyDisabled }, { data: onlyEnabled }] = await Promise.all(
|
|
74
|
+
[
|
|
75
|
+
adminAgent.tools.ozone.team.listMembers({
|
|
76
|
+
disabled: true,
|
|
77
|
+
}),
|
|
78
|
+
adminAgent.tools.ozone.team.listMembers({
|
|
79
|
+
disabled: false,
|
|
80
|
+
}),
|
|
81
|
+
],
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
expect(
|
|
85
|
+
onlyDisabled.members.find(({ disabled }) => !disabled),
|
|
86
|
+
).toBeUndefined()
|
|
87
|
+
|
|
88
|
+
expect(
|
|
89
|
+
onlyEnabled.members.find(({ disabled }) => disabled),
|
|
90
|
+
).toBeUndefined()
|
|
62
91
|
})
|
|
63
92
|
})
|
|
93
|
+
|
|
64
94
|
describe('addMember', () => {
|
|
65
95
|
const newMemberData = {
|
|
66
96
|
did: 'did:plc:newMember',
|
|
@@ -69,15 +99,15 @@ describe('team management', () => {
|
|
|
69
99
|
}
|
|
70
100
|
it('only allows admins to add member', async () => {
|
|
71
101
|
await expect(
|
|
72
|
-
triageAgent.
|
|
102
|
+
triageAgent.tools.ozone.team.addMember(newMemberData),
|
|
73
103
|
).rejects.toThrow('Must be an admin to add a member')
|
|
74
104
|
const { data: newMember } =
|
|
75
|
-
await adminAgent.
|
|
105
|
+
await adminAgent.tools.ozone.team.addMember(newMemberData)
|
|
76
106
|
expect(forSnapshot(newMember)).toMatchSnapshot()
|
|
77
107
|
})
|
|
78
108
|
it('throws error when trying to add existing member', async () => {
|
|
79
109
|
await expect(
|
|
80
|
-
adminAgent.
|
|
110
|
+
adminAgent.tools.ozone.team.addMember(newMemberData),
|
|
81
111
|
).rejects.toThrow('member already exists')
|
|
82
112
|
})
|
|
83
113
|
})
|
|
@@ -85,19 +115,19 @@ describe('team management', () => {
|
|
|
85
115
|
it('only allows admins to delete members', async () => {
|
|
86
116
|
const {
|
|
87
117
|
data: { members: initialMembers },
|
|
88
|
-
} = await adminAgent.
|
|
118
|
+
} = await adminAgent.tools.ozone.team.listMembers({})
|
|
89
119
|
await expect(
|
|
90
|
-
triageAgent.
|
|
120
|
+
triageAgent.tools.ozone.team.deleteMember({
|
|
91
121
|
did: sc.dids.bob,
|
|
92
122
|
}),
|
|
93
123
|
).rejects.toThrow('Must be an admin to delete a member')
|
|
94
124
|
|
|
95
|
-
await adminAgent.
|
|
125
|
+
await adminAgent.tools.ozone.team.deleteMember({
|
|
96
126
|
did: sc.dids.bob,
|
|
97
127
|
})
|
|
98
128
|
const {
|
|
99
129
|
data: { members: membersAfterDelete },
|
|
100
|
-
} = await adminAgent.
|
|
130
|
+
} = await adminAgent.tools.ozone.team.listMembers({})
|
|
101
131
|
|
|
102
132
|
expect(membersAfterDelete.length).toEqual(initialMembers.length - 1)
|
|
103
133
|
expect(membersAfterDelete.map(({ did }) => did)).not.toContain(
|
|
@@ -107,7 +137,7 @@ describe('team management', () => {
|
|
|
107
137
|
|
|
108
138
|
it('throws error when trying to remove non-existent member', async () => {
|
|
109
139
|
await expect(
|
|
110
|
-
adminAgent.
|
|
140
|
+
adminAgent.tools.ozone.team.deleteMember({
|
|
111
141
|
did: 'did:plc:test',
|
|
112
142
|
}),
|
|
113
143
|
).rejects.toThrow('member not found')
|
|
@@ -118,19 +148,19 @@ describe('team management', () => {
|
|
|
118
148
|
const getCarol = async () => {
|
|
119
149
|
const {
|
|
120
150
|
data: { members },
|
|
121
|
-
} = await adminAgent.
|
|
151
|
+
} = await adminAgent.tools.ozone.team.listMembers({})
|
|
122
152
|
|
|
123
153
|
return members.find(({ did }) => did === sc.dids.carol)
|
|
124
154
|
}
|
|
125
155
|
await expect(
|
|
126
|
-
triageAgent.
|
|
156
|
+
triageAgent.tools.ozone.team.updateMember({
|
|
127
157
|
disabled: false,
|
|
128
158
|
did: sc.dids.carol,
|
|
129
159
|
role: 'tools.ozone.team.defs#roleAdmin',
|
|
130
160
|
}),
|
|
131
161
|
).rejects.toThrow('Must be an admin to update a member')
|
|
132
162
|
|
|
133
|
-
await adminAgent.
|
|
163
|
+
await adminAgent.tools.ozone.team.updateMember({
|
|
134
164
|
did: sc.dids.carol,
|
|
135
165
|
role: 'tools.ozone.team.defs#roleAdmin',
|
|
136
166
|
})
|
|
@@ -141,7 +171,7 @@ describe('team management', () => {
|
|
|
141
171
|
// Verify that params that we didn't send did not get updated
|
|
142
172
|
expect(carolAfterRoleChange?.disabled).toEqual(false)
|
|
143
173
|
|
|
144
|
-
await adminAgent.
|
|
174
|
+
await adminAgent.tools.ozone.team.updateMember({
|
|
145
175
|
did: sc.dids.carol,
|
|
146
176
|
disabled: true,
|
|
147
177
|
})
|
|
@@ -152,7 +182,7 @@ describe('team management', () => {
|
|
|
152
182
|
})
|
|
153
183
|
it('throws error when trying to update non-existent member', async () => {
|
|
154
184
|
await expect(
|
|
155
|
-
adminAgent.
|
|
185
|
+
adminAgent.tools.ozone.team.updateMember({
|
|
156
186
|
disabled: false,
|
|
157
187
|
did: 'did:plc:test',
|
|
158
188
|
role: 'tools.ozone.team.defs#roleAdmin',
|