@atproto/ozone 0.2.5 → 0.2.6
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 +18 -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/report/queryActivities.d.ts +4 -0
- package/dist/api/report/queryActivities.d.ts.map +1 -0
- package/dist/api/report/queryActivities.js +36 -0
- package/dist/api/report/queryActivities.js.map +1 -0
- package/dist/background.d.ts +5 -3
- package/dist/background.d.ts.map +1 -1
- package/dist/background.js +13 -4
- package/dist/background.js.map +1 -1
- package/dist/context.js +1 -1
- package/dist/context.js.map +1 -1
- package/dist/daemon/context.js +1 -1
- package/dist/daemon/context.js.map +1 -1
- package/dist/daemon/verification-listener.d.ts +1 -1
- package/dist/daemon/verification-listener.d.ts.map +1 -1
- package/dist/daemon/verification-listener.js +10 -4
- package/dist/daemon/verification-listener.js.map +1 -1
- package/dist/db/migrations/20260602T120000000Z-add-report-activity-created-index.d.ts +4 -0
- package/dist/db/migrations/20260602T120000000Z-add-report-activity-created-index.d.ts.map +1 -0
- package/dist/db/migrations/20260602T120000000Z-add-report-activity-created-index.js +15 -0
- package/dist/db/migrations/20260602T120000000Z-add-report-activity-created-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 +1 -0
- package/dist/db/migrations/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -13
- package/dist/index.js.map +1 -1
- package/dist/jetstream/service.d.ts +1 -1
- package/dist/jetstream/service.d.ts.map +1 -1
- package/dist/jetstream/service.js +3 -1
- package/dist/jetstream/service.js.map +1 -1
- package/dist/lexicon/index.d.ts +11 -0
- package/dist/lexicon/index.d.ts.map +1 -1
- package/dist/lexicon/index.js +18 -0
- package/dist/lexicon/index.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +338 -0
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +173 -0
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/app/bsky/notification/defs.d.ts +1 -0
- package/dist/lexicon/types/app/bsky/notification/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/notification/defs.js.map +1 -1
- package/dist/lexicon/types/chat/bsky/notification/defs.d.ts +19 -0
- package/dist/lexicon/types/chat/bsky/notification/defs.d.ts.map +1 -0
- package/dist/lexicon/types/chat/bsky/notification/defs.js +19 -0
- package/dist/lexicon/types/chat/bsky/notification/defs.js.map +1 -0
- package/dist/lexicon/types/chat/bsky/notification/getPreferences.d.ts +20 -0
- package/dist/lexicon/types/chat/bsky/notification/getPreferences.d.ts.map +1 -0
- package/dist/lexicon/types/chat/bsky/notification/getPreferences.js +5 -0
- package/dist/lexicon/types/chat/bsky/notification/getPreferences.js.map +1 -0
- package/dist/lexicon/types/chat/bsky/notification/putPreferences.d.ts +26 -0
- package/dist/lexicon/types/chat/bsky/notification/putPreferences.d.ts.map +1 -0
- package/dist/lexicon/types/chat/bsky/notification/putPreferences.js +5 -0
- package/dist/lexicon/types/chat/bsky/notification/putPreferences.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/defs.d.ts +1 -0
- package/dist/lexicon/types/tools/ozone/report/defs.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/report/defs.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/report/queryActivities.d.ts +32 -0
- package/dist/lexicon/types/tools/ozone/report/queryActivities.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/queryActivities.js +5 -0
- package/dist/lexicon/types/tools/ozone/report/queryActivities.js.map +1 -0
- package/dist/mod-service/report.d.ts +1 -0
- package/dist/mod-service/report.d.ts.map +1 -1
- package/dist/mod-service/report.js +16 -0
- package/dist/mod-service/report.js.map +1 -1
- package/dist/report/activity.d.ts +19 -1
- package/dist/report/activity.d.ts.map +1 -1
- package/dist/report/activity.js +27 -1
- package/dist/report/activity.js.map +1 -1
- package/package.json +9 -8
- package/src/api/index.ts +2 -0
- package/src/api/report/queryActivities.ts +64 -0
- package/src/background.ts +19 -4
- package/src/context.ts +1 -1
- package/src/daemon/context.ts +1 -1
- package/src/daemon/verification-listener.ts +9 -4
- package/src/db/migrations/20260602T120000000Z-add-report-activity-created-index.ts +17 -0
- package/src/db/migrations/index.ts +1 -0
- package/src/index.ts +25 -15
- package/src/jetstream/service.ts +3 -1
- package/src/mod-service/report.ts +19 -0
- package/src/report/activity.ts +47 -0
- package/tests/3p-labeler.test.ts +2 -2
- package/tests/_util.ts +8 -25
- package/tests/account-strikes.test.ts +1 -1
- package/tests/ack-all-subjects-of-account.test.ts +1 -1
- package/tests/age-assurance.test.ts +1 -1
- package/tests/blob-divert.test.ts +1 -1
- package/tests/communication-templates.test.ts +1 -1
- package/tests/content-tagger.test.ts +1 -1
- package/tests/db.test.ts +1 -1
- package/tests/expiring-label.test.ts +1 -1
- package/tests/expiring-tags.test.ts +1 -1
- package/tests/get-account-timeline.test.ts +1 -1
- package/tests/get-config.test.ts +1 -1
- package/tests/get-lists.test.ts +2 -1
- package/tests/get-profiles.test.ts +1 -1
- package/tests/get-record.test.ts +1 -1
- package/tests/get-records.test.ts +1 -1
- package/tests/get-repo.test.ts +1 -1
- package/tests/get-report.test.ts +1 -1
- package/tests/get-reporter-stats.test.ts +1 -1
- package/tests/get-repos.test.ts +1 -1
- package/tests/get-starter-pack.test.ts +1 -1
- package/tests/get-subjects.test.ts +1 -1
- package/tests/mod-tool.test.ts +1 -1
- package/tests/moderation-appeals.test.ts +1 -1
- package/tests/moderation-events.test.ts +1 -1
- package/tests/moderation-status-tags.test.ts +1 -1
- package/tests/moderation-statuses.test.ts +1 -1
- package/tests/moderation.test.ts +1 -1
- package/tests/protected-tags.test.ts +1 -1
- package/tests/query-labels.test.ts +1 -1
- package/tests/query-reports.test.ts +1 -1
- package/tests/queue-assignment.test.ts +1 -1
- package/tests/queue-router.test.ts +1 -1
- package/tests/queues.test.ts +1 -1
- package/tests/record-and-account-events.test.ts +1 -1
- package/tests/repo-search.test.ts +2 -2
- package/tests/report-action.test.ts +1 -1
- package/tests/report-activity.test.ts +145 -1
- package/tests/report-assignment.test.ts +1 -1
- package/tests/report-muting.test.ts +1 -1
- package/tests/report-reason.test.ts +1 -1
- package/tests/report-reassign-queue.test.ts +1 -1
- package/tests/report-routing.test.ts +1 -1
- package/tests/report-stats.test.ts +1 -1
- package/tests/revoke-account-credentials.test.ts +1 -1
- package/tests/safelink.test.ts +1 -1
- package/tests/scheduled-action-processor.test.ts +1 -1
- package/tests/scheduled-action.test.ts +1 -1
- package/tests/sequencer.test.ts +1 -1
- package/tests/server.test.ts +9 -12
- package/tests/sets.test.ts +1 -1
- package/tests/settings.test.ts +1 -1
- package/tests/strike-expiry-processor.test.ts +1 -1
- package/tests/subject-priority-score.test.ts +1 -1
- package/tests/takedown.test.ts +1 -1
- package/tests/team.test.ts +1 -1
- package/tests/verification-listener.test.ts +40 -13
- package/tests/verification.test.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
package/tests/_util.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RequestListener, createServer } from 'node:http'
|
|
2
2
|
import { AddressInfo } from 'node:net'
|
|
3
|
-
|
|
3
|
+
// eslint-disable-next-line import/default
|
|
4
|
+
import httpTerminator from 'http-terminator'
|
|
4
5
|
import { CID } from 'multiformats/cid'
|
|
5
6
|
import { lexToJson } from '@atproto/lexicon'
|
|
6
7
|
import { AtUri } from '@atproto/syntax'
|
|
@@ -215,19 +216,11 @@ export const stripViewerFromThread = <T extends ThreadViewPost>(
|
|
|
215
216
|
return thread
|
|
216
217
|
}
|
|
217
218
|
|
|
218
|
-
export async function startServer(
|
|
219
|
-
return new Promise<{
|
|
220
|
-
origin: string
|
|
221
|
-
server: Server
|
|
222
|
-
stop: () => Promise<void>
|
|
223
|
-
}>((resolve, reject) => {
|
|
219
|
+
export async function startServer(listener: RequestListener) {
|
|
220
|
+
return new Promise<AsyncDisposable & { port: number }>((resolve, reject) => {
|
|
224
221
|
const onListen = () => {
|
|
225
222
|
const port = (server.address() as AddressInfo).port
|
|
226
|
-
resolve({
|
|
227
|
-
server,
|
|
228
|
-
origin: `http://localhost:${port}`,
|
|
229
|
-
stop: () => stopServer(server),
|
|
230
|
-
})
|
|
223
|
+
resolve({ port, [Symbol.asyncDispose]: () => terminator.terminate() })
|
|
231
224
|
cleanup()
|
|
232
225
|
}
|
|
233
226
|
const onError = (err: Error) => {
|
|
@@ -239,21 +232,11 @@ export async function startServer(app: Express) {
|
|
|
239
232
|
server.removeListener('error', onError)
|
|
240
233
|
}
|
|
241
234
|
|
|
242
|
-
const server =
|
|
235
|
+
const server = createServer(listener)
|
|
243
236
|
.listen(0)
|
|
244
237
|
.once('listening', onListen)
|
|
245
238
|
.once('error', onError)
|
|
246
|
-
})
|
|
247
|
-
}
|
|
248
239
|
|
|
249
|
-
|
|
250
|
-
return new Promise<void>((resolve, reject) => {
|
|
251
|
-
server.close((err) => {
|
|
252
|
-
if (err) {
|
|
253
|
-
reject(err)
|
|
254
|
-
} else {
|
|
255
|
-
resolve()
|
|
256
|
-
}
|
|
257
|
-
})
|
|
240
|
+
const terminator = httpTerminator.createHttpTerminator({ server })
|
|
258
241
|
})
|
|
259
242
|
}
|
package/tests/db.test.ts
CHANGED
package/tests/get-config.test.ts
CHANGED
package/tests/get-lists.test.ts
CHANGED
|
@@ -35,8 +35,9 @@ describe('admin get lists', () => {
|
|
|
35
35
|
})
|
|
36
36
|
|
|
37
37
|
afterAll(async () => {
|
|
38
|
+
// @TODO figure out why we even need this in afterAll ?
|
|
38
39
|
AtpAgent.configure({ appLabelers: [BSKY_LABELER_DID] })
|
|
39
|
-
await network
|
|
40
|
+
await network?.close()
|
|
40
41
|
})
|
|
41
42
|
|
|
42
43
|
const getAlicesList = async () => {
|
package/tests/get-record.test.ts
CHANGED
package/tests/get-repo.test.ts
CHANGED
package/tests/get-report.test.ts
CHANGED
package/tests/get-repos.test.ts
CHANGED
package/tests/mod-tool.test.ts
CHANGED
package/tests/moderation.test.ts
CHANGED
package/tests/queues.test.ts
CHANGED
|
@@ -28,10 +28,10 @@ describe('admin repo search view', () => {
|
|
|
28
28
|
ids.ToolsOzoneModerationSearchRepos,
|
|
29
29
|
)
|
|
30
30
|
await network.processAll()
|
|
31
|
-
},
|
|
31
|
+
}, 40_000) // @NOTE seeding can take a while
|
|
32
32
|
|
|
33
33
|
afterAll(async () => {
|
|
34
|
-
await network
|
|
34
|
+
await network?.close()
|
|
35
35
|
})
|
|
36
36
|
|
|
37
37
|
beforeAll(async () => {
|
|
@@ -75,7 +75,7 @@ describe('report-activity', () => {
|
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
afterAll(async () => {
|
|
78
|
-
await network
|
|
78
|
+
await network?.close()
|
|
79
79
|
})
|
|
80
80
|
|
|
81
81
|
describe('createActivity — noteActivity', () => {
|
|
@@ -564,4 +564,148 @@ describe('report-activity', () => {
|
|
|
564
564
|
expect(data.activities.some((a) => a.reportId === reportB.id)).toBe(false)
|
|
565
565
|
})
|
|
566
566
|
})
|
|
567
|
+
|
|
568
|
+
describe('queryActivities', () => {
|
|
569
|
+
const queryActivities = async (
|
|
570
|
+
params: {
|
|
571
|
+
activityTypes?: string[]
|
|
572
|
+
createdAfter?: string
|
|
573
|
+
createdBefore?: string
|
|
574
|
+
sortDirection?: 'asc' | 'desc'
|
|
575
|
+
limit?: number
|
|
576
|
+
cursor?: string
|
|
577
|
+
},
|
|
578
|
+
role: 'admin' | 'triage' = 'admin',
|
|
579
|
+
) => {
|
|
580
|
+
return agent.tools.ozone.report.queryActivities(params, {
|
|
581
|
+
headers: await network.ozone.modHeaders(
|
|
582
|
+
ids.ToolsOzoneReportQueryActivities,
|
|
583
|
+
role,
|
|
584
|
+
),
|
|
585
|
+
})
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
it('hydrates the report on each activity', async () => {
|
|
589
|
+
const report = await createReport(sc.dids.alice)
|
|
590
|
+
await createActivity({
|
|
591
|
+
reportId: report.id,
|
|
592
|
+
activity: { $type: `${DEFS}#closeActivity` },
|
|
593
|
+
})
|
|
594
|
+
|
|
595
|
+
const { data } = await queryActivities({
|
|
596
|
+
activityTypes: ['closeActivity'],
|
|
597
|
+
sortDirection: 'desc',
|
|
598
|
+
limit: 100,
|
|
599
|
+
})
|
|
600
|
+
const hit = data.activities.find((a) => a.reportId === report.id)
|
|
601
|
+
expect(hit).toBeDefined()
|
|
602
|
+
expect(hit!.report).toBeDefined()
|
|
603
|
+
expect(hit!.report!.id).toBe(report.id)
|
|
604
|
+
expect(hit!.report!.subject).toBeDefined()
|
|
605
|
+
})
|
|
606
|
+
|
|
607
|
+
it('filters by activity types across reports', async () => {
|
|
608
|
+
const reportA = await createReport(sc.dids.alice)
|
|
609
|
+
const reportB = await createReport(sc.dids.bob)
|
|
610
|
+
await createActivity({
|
|
611
|
+
reportId: reportA.id,
|
|
612
|
+
activity: { $type: `${DEFS}#noteActivity` },
|
|
613
|
+
internalNote: 'note',
|
|
614
|
+
})
|
|
615
|
+
await createActivity({
|
|
616
|
+
reportId: reportA.id,
|
|
617
|
+
activity: { $type: `${DEFS}#closeActivity` },
|
|
618
|
+
})
|
|
619
|
+
await createActivity({
|
|
620
|
+
reportId: reportB.id,
|
|
621
|
+
activity: { $type: `${DEFS}#escalationActivity` },
|
|
622
|
+
})
|
|
623
|
+
|
|
624
|
+
const { data } = await queryActivities({
|
|
625
|
+
activityTypes: ['closeActivity', 'escalationActivity'],
|
|
626
|
+
sortDirection: 'asc',
|
|
627
|
+
})
|
|
628
|
+
|
|
629
|
+
const types = new Set(data.activities.map((a) => a.activity.$type))
|
|
630
|
+
expect(types.has(`${DEFS}#noteActivity`)).toBe(false)
|
|
631
|
+
expect(types.has(`${DEFS}#closeActivity`)).toBe(true)
|
|
632
|
+
expect(types.has(`${DEFS}#escalationActivity`)).toBe(true)
|
|
633
|
+
const reportIds = new Set(data.activities.map((a) => a.reportId))
|
|
634
|
+
expect(reportIds.has(reportA.id)).toBe(true)
|
|
635
|
+
expect(reportIds.has(reportB.id)).toBe(true)
|
|
636
|
+
})
|
|
637
|
+
|
|
638
|
+
it('paginates ascending across multiple reports with stable cursor', async () => {
|
|
639
|
+
const reportA = await createReport(sc.dids.alice)
|
|
640
|
+
const reportB = await createReport(sc.dids.bob)
|
|
641
|
+
const created: number[] = []
|
|
642
|
+
for (let i = 0; i < 3; i++) {
|
|
643
|
+
const r = await createActivity({
|
|
644
|
+
reportId: i % 2 === 0 ? reportA.id : reportB.id,
|
|
645
|
+
activity: { $type: `${DEFS}#noteActivity` },
|
|
646
|
+
internalNote: `n-${i}`,
|
|
647
|
+
})
|
|
648
|
+
created.push(r.data.activity.id)
|
|
649
|
+
}
|
|
650
|
+
const minId = Math.min(...created)
|
|
651
|
+
|
|
652
|
+
const seen: number[] = []
|
|
653
|
+
let cursor: string | undefined
|
|
654
|
+
let pages = 0
|
|
655
|
+
do {
|
|
656
|
+
const { data } = await queryActivities({
|
|
657
|
+
sortDirection: 'asc',
|
|
658
|
+
limit: 2,
|
|
659
|
+
cursor,
|
|
660
|
+
})
|
|
661
|
+
for (const a of data.activities) {
|
|
662
|
+
if (a.id >= minId) seen.push(a.id)
|
|
663
|
+
}
|
|
664
|
+
cursor = data.cursor
|
|
665
|
+
pages++
|
|
666
|
+
if (pages > 50) break // safety net for runaway loops
|
|
667
|
+
} while (cursor)
|
|
668
|
+
|
|
669
|
+
// The created activities should appear in ascending ID order, no dupes.
|
|
670
|
+
const sortedCreated = [...created].sort((a, b) => a - b)
|
|
671
|
+
const seenForCreated = seen.filter((id) => created.includes(id))
|
|
672
|
+
expect(seenForCreated).toEqual(sortedCreated)
|
|
673
|
+
})
|
|
674
|
+
|
|
675
|
+
it('respects createdBefore and createdAfter bounds', async () => {
|
|
676
|
+
const report = await createReport(sc.dids.alice)
|
|
677
|
+
const before = await createActivity({
|
|
678
|
+
reportId: report.id,
|
|
679
|
+
activity: { $type: `${DEFS}#noteActivity` },
|
|
680
|
+
internalNote: 'before',
|
|
681
|
+
})
|
|
682
|
+
// Small wait so the next activity's createdAt is strictly later.
|
|
683
|
+
await new Promise((r) => setTimeout(r, 50))
|
|
684
|
+
const cutoff = new Date().toISOString()
|
|
685
|
+
await new Promise((r) => setTimeout(r, 50))
|
|
686
|
+
const after = await createActivity({
|
|
687
|
+
reportId: report.id,
|
|
688
|
+
activity: { $type: `${DEFS}#noteActivity` },
|
|
689
|
+
internalNote: 'after',
|
|
690
|
+
})
|
|
691
|
+
|
|
692
|
+
const beforeRes = await queryActivities({
|
|
693
|
+
createdBefore: cutoff,
|
|
694
|
+
sortDirection: 'asc',
|
|
695
|
+
limit: 100,
|
|
696
|
+
})
|
|
697
|
+
const beforeIds = new Set(beforeRes.data.activities.map((a) => a.id))
|
|
698
|
+
expect(beforeIds.has(before.data.activity.id)).toBe(true)
|
|
699
|
+
expect(beforeIds.has(after.data.activity.id)).toBe(false)
|
|
700
|
+
|
|
701
|
+
const afterRes = await queryActivities({
|
|
702
|
+
createdAfter: cutoff,
|
|
703
|
+
sortDirection: 'asc',
|
|
704
|
+
limit: 100,
|
|
705
|
+
})
|
|
706
|
+
const afterIds = new Set(afterRes.data.activities.map((a) => a.id))
|
|
707
|
+
expect(afterIds.has(before.data.activity.id)).toBe(false)
|
|
708
|
+
expect(afterIds.has(after.data.activity.id)).toBe(true)
|
|
709
|
+
})
|
|
710
|
+
})
|
|
567
711
|
})
|