mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
feat: ability to re-order topic thumbnails
This commit is contained in:
@@ -166,6 +166,25 @@ Topics.deleteThumb = async (req, res) => {
|
||||
helpers.formatApiResponse(200, res, await topics.thumbs.get(req.params.tid));
|
||||
};
|
||||
|
||||
Topics.reorderThumbs = async (req, res) => {
|
||||
await checkThumbPrivileges({ tid: req.params.tid, uid: req.user.uid, res });
|
||||
if (res.headersSent) {
|
||||
return;
|
||||
}
|
||||
|
||||
const exists = await topics.thumbs.exists(req.params.tid, req.body.path);
|
||||
if (!exists) {
|
||||
return helpers.formatApiResponse(404, res);
|
||||
}
|
||||
|
||||
await topics.thumbs.associate({
|
||||
id: req.params.tid,
|
||||
path: req.body.path,
|
||||
score: req.body.order,
|
||||
});
|
||||
helpers.formatApiResponse(200, res);
|
||||
};
|
||||
|
||||
async function checkThumbPrivileges({ tid, uid, res }) {
|
||||
// req.params.tid could be either a tid (pushing a new thumb to an existing topic)
|
||||
// or a post UUID (a new topic being composed)
|
||||
|
||||
Reference in New Issue
Block a user