feat: flag rescinding logic + api method

This commit is contained in:
Julian Lam
2023-10-11 12:06:33 -04:00
parent cc8fe4353d
commit e012edea3b
7 changed files with 62 additions and 1 deletions

View File

@@ -49,6 +49,16 @@ flagsApi.update = async (caller, data) => {
flagsApi.delete = async (_, { flagId }) => await flags.purge([flagId]);
flagsApi.rescind = async ({ uid }, { flagId }) => {
const { type, targetId } = await flags.get(flagId);
const exists = await flags.exists(type, targetId, uid);
if (!exists) {
throw new Error('[[error:no-flag]]');
}
await flags.rescindReport(type, targetId, uid);
};
flagsApi.appendNote = async (caller, data) => {
const allowed = await user.isPrivileged(caller.uid);
if (!allowed) {