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;
|
const { id, name, url, active, channels } = request.body;
|
||||||
|
|
||||||
// channels comes through as either String[] or String
|
// channels comes through as either String[] or String
|
||||||
const formattedChannels = Array.isArray(channels)
|
let formattedChannels = undefined;
|
||||||
? channels.map((channelId) => ({ channel_id: channelId }))
|
if (channels !== undefined) {
|
||||||
: [{ channel_id: channels }]
|
formattedChannels = Array.isArray(channels)
|
||||||
|
? channels.map((channelId) => ({ channel_id: channelId }))
|
||||||
|
: [{ channel_id: channels }]
|
||||||
|
}
|
||||||
|
|
||||||
let feed;
|
let feed;
|
||||||
|
|
||||||
@ -73,7 +76,10 @@ export const patch = async (request: Request, response: Response) => {
|
|||||||
url: url,
|
url: url,
|
||||||
guild_id: guildId,
|
guild_id: guildId,
|
||||||
active: active === "on",
|
active: active === "on",
|
||||||
channels: channels !== undefined ? { create: formattedChannels } : channels
|
channels: {
|
||||||
|
deleteMany: {},
|
||||||
|
create: formattedChannels
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user