diff --git a/src/server/controllers/guild/api/feed.controller.ts b/src/server/controllers/guild/api/feed.controller.ts index 812f5ee..974f55a 100644 --- a/src/server/controllers/guild/api/feed.controller.ts +++ b/src/server/controllers/guild/api/feed.controller.ts @@ -59,9 +59,12 @@ export const patch = async (request: Request, response: Response) => { const { id, 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 formattedChannels = undefined; + if (channels !== undefined) { + formattedChannels = Array.isArray(channels) + ? channels.map((channelId) => ({ channel_id: channelId })) + : [{ channel_id: channels }] + } let feed; @@ -73,7 +76,10 @@ export const patch = async (request: Request, response: Response) => { url: url, guild_id: guildId, active: active === "on", - channels: channels !== undefined ? { create: formattedChannels } : channels + channels: { + deleteMany: {}, + create: formattedChannels + } } }); }