feat: #9109, ability to delete a post's diffs

This commit is contained in:
gasoved
2021-01-28 21:42:10 +03:00
committed by Julian Lam
parent a87416971b
commit eb642f40b9
6 changed files with 164 additions and 59 deletions

View File

@@ -260,9 +260,14 @@ postsAPI.getDiffs = async (caller, data) => {
let usernames = await user.getUsersFields(uids, ['username']);
usernames = usernames.map(userObj => (userObj.uid ? userObj.username : null));
const cid = await posts.getCidByPid(data.pid);
const isModerator = await privileges.users.isModerator(cid, caller.uid);
let canEdit = true;
try {
await user.isPrivilegedOrSelf(caller.uid, post.uid);
if (!isModerator) {
await user.isPrivilegedOrSelf(caller.uid, post.uid);
}
} catch (e) {
canEdit = false;
}
@@ -276,6 +281,7 @@ postsAPI.getDiffs = async (caller, data) => {
username: usernames[idx],
})),
editable: canEdit,
deletable: isModerator,
};
};