feat: rescind post flags

This commit is contained in:
Opliko
2024-04-14 00:07:55 +02:00
parent 7c4ae8eb82
commit 9ab1a2d129
6 changed files with 72 additions and 0 deletions

View File

@@ -59,6 +59,24 @@ flagsApi.rescind = async ({ uid }, { flagId }) => {
await flags.rescindReport(type, targetId, uid);
};
flagsApi.rescindPost = async ({ uid }, { pid }) => {
const exists = await flags.exists('post', pid, uid);
if (!exists) {
throw new Error('[[error:no-flag]]');
}
await flags.rescindReport('post', pid, uid);
};
flagsApi.rescindUser = async ({ uid }, { uid: targetUid }) => {
const exists = await flags.exists('user', targetUid, uid);
if (!exists) {
throw new Error('[[error:no-flag]]');
}
await flags.rescindReport('user', targetUid, uid);
};
flagsApi.appendNote = async (caller, data) => {
const allowed = await user.isPrivileged(caller.uid);
if (!allowed) {