From 3cee30dcbcee78a95e9e7072f83d975fd8bcc164 Mon Sep 17 00:00:00 2001 From: Timothee Legros Date: Wed, 7 Aug 2024 20:40:02 +0200 Subject: [PATCH 1/3] topics deletion fix --- .../server/controllers/server_topics_methods/delete_topic.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/commonwealth/server/controllers/server_topics_methods/delete_topic.ts b/packages/commonwealth/server/controllers/server_topics_methods/delete_topic.ts index 62036d720ec..7545369a2c8 100644 --- a/packages/commonwealth/server/controllers/server_topics_methods/delete_topic.ts +++ b/packages/commonwealth/server/controllers/server_topics_methods/delete_topic.ts @@ -27,7 +27,7 @@ export async function __deleteTopic( throw new AppError(Errors.TopicNotFound); } - const isAdmin = validateOwner({ + const isAdmin = await validateOwner({ models: this.models, user, communityId: topic.community_id, From ec986b7b2de2706a805bf4b6045dbf317ec1f166 Mon Sep 17 00:00:00 2001 From: Timothee Legros Date: Wed, 7 Aug 2024 20:44:30 +0200 Subject: [PATCH 2/3] topic creation fix --- .../server/controllers/server_topics_methods/create_topic.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/commonwealth/server/controllers/server_topics_methods/create_topic.ts b/packages/commonwealth/server/controllers/server_topics_methods/create_topic.ts index 138788aae0e..cb68f4a5d80 100644 --- a/packages/commonwealth/server/controllers/server_topics_methods/create_topic.ts +++ b/packages/commonwealth/server/controllers/server_topics_methods/create_topic.ts @@ -56,7 +56,7 @@ export async function __createTopic( true, ); - const isAdmin = validateOwner({ + const isAdmin = await validateOwner({ models: this.models, user, // @ts-expect-error StrictNullChecks From bf6ad628771dd8055adfed2acf11027211d3c945 Mon Sep 17 00:00:00 2001 From: Timothee Legros Date: Wed, 7 Aug 2024 20:52:23 +0200 Subject: [PATCH 3/3] test fix --- .../unit/server_controllers/server_topics_controller.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/commonwealth/test/unit/server_controllers/server_topics_controller.spec.ts b/packages/commonwealth/test/unit/server_controllers/server_topics_controller.spec.ts index e1a60385504..957627cfa4a 100644 --- a/packages/commonwealth/test/unit/server_controllers/server_topics_controller.spec.ts +++ b/packages/commonwealth/test/unit/server_controllers/server_topics_controller.spec.ts @@ -78,7 +78,7 @@ const createMockedTopicsController = (isAdmin: boolean = false) => { describe('ServerTopicsController', () => { test('#createTopic', async () => { - const { controller, user, chain } = createMockedTopicsController(); + const { controller, user, chain } = createMockedTopicsController(true); const [topic] = await Promise.all( await controller.createTopic({ user, @@ -99,7 +99,7 @@ describe('ServerTopicsController', () => { }); test('#deleteTopic', async () => { - const { controller, user } = createMockedTopicsController(); + const { controller, user } = createMockedTopicsController(true); await controller.deleteTopic({ user, topicId: 1,