fix(api): correctly handle arguments for channels and active
This commit is contained in:
parent
acde6e1bbb
commit
9896f8e094
@ -25,6 +25,11 @@ export const post = async (request: Request, response: Response) => {
|
|||||||
const guildId = request.params.guildId;
|
const guildId = request.params.guildId;
|
||||||
const { name, url, active, channels } = request.body;
|
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;
|
let feed;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -33,8 +38,8 @@ export const post = async (request: Request, response: Response) => {
|
|||||||
name: name,
|
name: name,
|
||||||
url: url,
|
url: url,
|
||||||
guild_id: guildId,
|
guild_id: guildId,
|
||||||
active: active,
|
active: active === "on",
|
||||||
channels: channels
|
channels: { create: formattedChannels }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user