mirror of
https://github.com/spacebarchat/server.git
synced 2024-09-19 17:21:35 +02:00
Add <Channel>.position to public endpoints
This commit is contained in:
parent
ef13c8c814
commit
e116e93693
@ -50,7 +50,13 @@ router.get(
|
||||
const channel = await Channel.findOneOrFail({
|
||||
where: { id: channel_id },
|
||||
});
|
||||
if (!channel.guild_id) return res.send(channel);
|
||||
|
||||
channel.position = await Channel.calculatePosition(
|
||||
channel_id,
|
||||
channel.guild_id,
|
||||
channel.guild,
|
||||
);
|
||||
return res.send(channel);
|
||||
},
|
||||
);
|
||||
|
@ -53,6 +53,11 @@ router.put(
|
||||
where: { id: channel_id },
|
||||
});
|
||||
if (!channel.guild_id) throw new HTTPError("Channel not found", 404);
|
||||
channel.position = await Channel.calculatePosition(
|
||||
channel_id,
|
||||
channel.guild_id,
|
||||
channel.guild,
|
||||
);
|
||||
|
||||
if (body.type === 0) {
|
||||
if (!(await Role.count({ where: { id: overwrite_id } })))
|
||||
|
@ -41,6 +41,14 @@ router.get(
|
||||
const { guild_id } = req.params;
|
||||
const channels = await Channel.find({ where: { guild_id } });
|
||||
|
||||
for await (const channel of channels) {
|
||||
channel.position = await Channel.calculatePosition(
|
||||
channel.id,
|
||||
guild_id,
|
||||
channel.guild,
|
||||
);
|
||||
}
|
||||
|
||||
res.json(channels);
|
||||
},
|
||||
);
|
||||
@ -71,6 +79,11 @@ router.post(
|
||||
{ ...body, guild_id },
|
||||
req.user_id,
|
||||
);
|
||||
channel.position = await Channel.calculatePosition(
|
||||
channel.id,
|
||||
guild_id,
|
||||
channel.guild,
|
||||
);
|
||||
|
||||
res.status(201).json(channel);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user