Skip to content

Commit

Permalink
Merge pull request #649 from elmadev/mod-edit-replay
Browse files Browse the repository at this point in the history
feat(replays): Allow mods to edit replay tags and DrivenBy
  • Loading branch information
sunehs authored Feb 5, 2024
2 parents 24962c8 + 65058c8 commit b5aa574
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/api/replay.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,12 @@ const EditReplay = async data => {
if (!rec) {
return 404;
}
if (rec.dataValues.UploadedBy === data.KuskiIndex) {
const update = { Comment: data.edit.Comment, Unlisted: data.edit.Unlisted };
if (rec.dataValues.UploadedBy === data.KuskiIndex || data.mod) {
const update = {};
if (rec.dataValues.UploadedBy === data.KuskiIndex) {
update.Comment = data.edit.Comment;
update.Unlisted = data.edit.Unlisted;
}
const k = await Kuski.findOne({ where: { Kuski: data.edit.DrivenBy } });
if (k) {
update.DrivenBy = k.KuskiIndex;
Expand Down Expand Up @@ -909,7 +913,11 @@ router
.post('/edit', async (req, res) => {
const auth = authContext(req);
if (auth.auth) {
const edit = await EditReplay({ ...req.body, KuskiIndex: auth.userid });
const edit = await EditReplay({
...req.body,
KuskiIndex: auth.userid,
mod: auth.mod,
});
res.sendStatus(edit);
} else {
res.sendStatus(401);
Expand Down

0 comments on commit b5aa574

Please sign in to comment.