fix(api): patching feeds would duplicate channels #4
All checks were successful
Build / build (push) Successful in 52s
All checks were successful
Build / build (push) Successful in 52s
This commit is contained in:
parent
2589cabec6
commit
e4ab506abe
@ -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
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user