From efa90c073b81b7fc3385f8f3cd0d66a2c43bf59a Mon Sep 17 00:00:00 2001 From: dholms Date: Tue, 19 Dec 2023 20:01:57 -0600 Subject: [PATCH] statuses working --- .../api/com/atproto/admin/queryModerationStatuses.ts | 8 ++------ packages/ozone/src/services/moderation/index.ts | 12 +++++++++++- .../ozone/tests/admin/moderation-statuses.test.ts | 6 +++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/ozone/src/api/com/atproto/admin/queryModerationStatuses.ts b/packages/ozone/src/api/com/atproto/admin/queryModerationStatuses.ts index 7dbb4457b34..682ef819f81 100644 --- a/packages/ozone/src/api/com/atproto/admin/queryModerationStatuses.ts +++ b/packages/ozone/src/api/com/atproto/admin/queryModerationStatuses.ts @@ -40,12 +40,8 @@ export default function (server: Server, ctx: AppContext) { limit, cursor, }) - const subjectStatuses = results.statuses.map( - (status) => - moderationService.views.formatSubjectStatus({ - ...status, - handle: '', - }), // @TODO fix handle + const subjectStatuses = results.statuses.map((status) => + moderationService.views.formatSubjectStatus(status), ) return { encoding: 'application/json', diff --git a/packages/ozone/src/services/moderation/index.ts b/packages/ozone/src/services/moderation/index.ts index 5fd9cc0e6c3..0e9e1a9a190 100644 --- a/packages/ozone/src/services/moderation/index.ts +++ b/packages/ozone/src/services/moderation/index.ts @@ -690,7 +690,17 @@ export class ModerationService { const results = await paginatedBuilder.execute() - return { statuses: results, cursor: keyset.packFromResult(results) } + const dids = dedupeStrs(results.map((r) => r.did)) + const handlesByDid = await this.getHandlesByDid(dids) + const resultsWithHandles = results.map((r) => ({ + ...r, + handle: handlesByDid.get(r.did), + })) + + return { + statuses: resultsWithHandles, + cursor: keyset.packFromResult(results), + } } async isSubjectTakendown( diff --git a/packages/ozone/tests/admin/moderation-statuses.test.ts b/packages/ozone/tests/admin/moderation-statuses.test.ts index 5109cc43b0e..fa010160048 100644 --- a/packages/ozone/tests/admin/moderation-statuses.test.ts +++ b/packages/ozone/tests/admin/moderation-statuses.test.ts @@ -75,8 +75,12 @@ describe('moderation-statuses', () => { beforeAll(async () => { network = await TestNetwork.create({ dbPostgresSchema: 'bsky_moderation_statuses', + ozone: { enabled: true }, }) - agent = network.bsky.getClient() + if (!network.ozone) { + throw new Error('Ozone not setup') + } + agent = network.ozone.getClient() pdsAgent = network.pds.getClient() sc = network.getSeedClient() await basicSeed(sc)