fix: type error in attachment emptying method

This commit is contained in:
Julian Lam
2024-05-10 11:18:30 -04:00
parent baada2fca7
commit 336ea1eeb6

View File

@@ -55,9 +55,8 @@ Attachments.empty = async (pids) => {
winston.verbose(`[posts/attachments] Emptying attachments for ids ${pids.join(', ')}.`); winston.verbose(`[posts/attachments] Emptying attachments for ids ${pids.join(', ')}.`);
const zsets = pids.map(pid => `post:${pid}:attachments`); const zsets = pids.map(pid => `post:${pid}:attachments`);
const hashes = await db.getSortedSetsMembers(zsets); const hashes = await db.getSortedSetsMembers(zsets);
const keys = hashes let keys = hashes.reduce((memo, hashes) => new Set([...memo, ...hashes]), new Set());
.reduce((memo, hashes) => new Set([...memo, ...hashes]), new Set()) keys = Array.from(keys).map(hash => `attachment:${hash}`);
.map(hash => `attachment:${hash}`);
await db.deleteAll(keys.concat(zsets)); await db.deleteAll(keys.concat(zsets));
}; };