From 900ced3ea53e161e3b135ccb4ea5f6df37ae3a2b Mon Sep 17 00:00:00 2001 From: f Date: Mon, 19 Feb 2024 10:57:06 -0300 Subject: [PATCH 1/2] fix: hook names are case-sensitive --- src/server/hooksystem.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/hooksystem.ts b/src/server/hooksystem.ts index 15c2b8a..6d75d91 100644 --- a/src/server/hooksystem.ts +++ b/src/server/hooksystem.ts @@ -49,15 +49,15 @@ export default class HookSystem { } async dispatchModerationQueued (actor: string, activity: APActivity): Promise { - return await this.dispatchHook('ModerationQueued', actor, activity) + return await this.dispatchHook('moderationqueued', actor, activity) } async dispatchOnApproved (actor: string, activity: APActivity): Promise { - return await this.dispatchHook('OnApproved', actor, activity) + return await this.dispatchHook('onapproved', actor, activity) } async dispatchOnRejected (actor: string, activity: APActivity): Promise { - return await this.dispatchHook('OnRejected', actor, activity) + return await this.dispatchHook('onrejected', actor, activity) } private async dispatchHook (hookType: string, actor: string, activity: APActivity): Promise { From 3d5a0d0aaee3f84504b3d4fb8d5f642e194f4e7a Mon Sep 17 00:00:00 2001 From: f Date: Mon, 19 Feb 2024 11:00:36 -0300 Subject: [PATCH 2/2] fix: tests --- src/server/hooksystem.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/server/hooksystem.test.ts b/src/server/hooksystem.test.ts index e6c5075..c000b7d 100644 --- a/src/server/hooksystem.test.ts +++ b/src/server/hooksystem.test.ts @@ -1,7 +1,7 @@ import test from 'ava' import HookSystem from './hooksystem' -test('HookSystem triggers ModerationQueued with expected parameters', async (t) => { +test('HookSystem triggers moderationqueued with expected parameters', async (t) => { // Mock the fetch API const mockFetch: any = (url: string, options: any) => { t.is(url, 'https://example.com/hook') @@ -19,7 +19,7 @@ test('HookSystem triggers ModerationQueued with expected parameters', async (t) return { hooks: { get: async (hookType: string) => { - if (hookType === 'ModerationQueued') { + if (hookType === 'moderationqueued') { return { url: 'https://example.com/hook', method: 'POST', @@ -44,7 +44,7 @@ test('HookSystem triggers ModerationQueued with expected parameters', async (t) t.true(result, 'Hook should be triggered successfully') }) -test('HookSystem triggers OnApproved with expected parameters', async (t) => { +test('HookSystem triggers onapproved with expected parameters', async (t) => { // Mock the fetch API const mockFetch: any = (url: string, options: any) => { t.is(url, 'https://example.com/hook-approved') @@ -62,7 +62,7 @@ test('HookSystem triggers OnApproved with expected parameters', async (t) => { return { hooks: { get: async (hookType: string) => { - if (hookType === 'OnApproved') { + if (hookType === 'onapproved') { return { url: 'https://example.com/hook-approved', method: 'POST', @@ -84,10 +84,10 @@ test('HookSystem triggers OnApproved with expected parameters', async (t) => { type: 'TestApproved' }) - t.true(result, 'Hook should be triggered successfully for OnApproved') + t.true(result, 'Hook should be triggered successfully for onapproved') }) -test('HookSystem triggers OnRejected with expected parameters', async (t) => { +test('HookSystem triggers onrejected with expected parameters', async (t) => { // Mock the fetch API const mockFetch: any = (url: string, options: any) => { t.is(url, 'https://example.com/hook-rejected') @@ -105,7 +105,7 @@ test('HookSystem triggers OnRejected with expected parameters', async (t) => { return { hooks: { get: async (hookType: string) => { - if (hookType === 'OnRejected') { + if (hookType === 'onrejected') { return { url: 'https://example.com/hook-rejected', method: 'POST', @@ -127,5 +127,5 @@ test('HookSystem triggers OnRejected with expected parameters', async (t) => { type: 'TestRejected' }) - t.true(result, 'Hook should be triggered successfully for OnRejected') + t.true(result, 'Hook should be triggered successfully for onrejected') })