Skip to content

Commit

Permalink
Merge pull request #44 from hyphacoop/hook-names
Browse files Browse the repository at this point in the history
fix: hook names are case-sensitive
  • Loading branch information
RangerMauve authored Feb 21, 2024
2 parents 893a428 + 3d5a0d0 commit b038d34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/server/hooksystem.test.ts
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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',
Expand All @@ -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')
Expand All @@ -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',
Expand All @@ -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')
Expand All @@ -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',
Expand All @@ -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')
})
6 changes: 3 additions & 3 deletions src/server/hooksystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ export default class HookSystem {
}

async dispatchModerationQueued (actor: string, activity: APActivity): Promise<boolean> {
return await this.dispatchHook('ModerationQueued', actor, activity)
return await this.dispatchHook('moderationqueued', actor, activity)
}

async dispatchOnApproved (actor: string, activity: APActivity): Promise<boolean> {
return await this.dispatchHook('OnApproved', actor, activity)
return await this.dispatchHook('onapproved', actor, activity)
}

async dispatchOnRejected (actor: string, activity: APActivity): Promise<boolean> {
return await this.dispatchHook('OnRejected', actor, activity)
return await this.dispatchHook('onrejected', actor, activity)
}

private async dispatchHook (hookType: string, actor: string, activity: APActivity): Promise<boolean> {
Expand Down

0 comments on commit b038d34

Please sign in to comment.