From 9896f8e094c06a0980b835902df2d9cb384bbd3d Mon Sep 17 00:00:00 2001 From: Corban-Lee Jones Date: Wed, 30 Apr 2025 23:57:55 +0100 Subject: [PATCH] fix(api): correctly handle arguments for channels and active --- src/server/controllers/guild/api/feed.controller.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/server/controllers/guild/api/feed.controller.ts b/src/server/controllers/guild/api/feed.controller.ts index 34c1770..8eba5dd 100644 --- a/src/server/controllers/guild/api/feed.controller.ts +++ b/src/server/controllers/guild/api/feed.controller.ts @@ -25,6 +25,11 @@ export const post = async (request: Request, response: Response) => { const guildId = request.params.guildId; const { name, url, active, channels } = request.body; + // channels comes through as either String[] or String + const formattedChannels = Array.isArray(channels) + ? channels.map((channelId) => ({ channel_id: channelId })) + : [{ channel_id: channels }] + let feed; try { @@ -33,8 +38,8 @@ export const post = async (request: Request, response: Response) => { name: name, url: url, guild_id: guildId, - active: active, - channels: channels + active: active === "on", + channels: { create: formattedChannels } } }); }