undid scancache changes

pull/82/head
TheCodedProf 3 years ago
parent 7ebd9fab10
commit 21d4b0f9a5
No known key found for this signature in database
GPG Key ID: 803E7CCB5577E6A2

@ -268,7 +268,7 @@ export async function callback(_client: NucleusClient, message: Message) {
const check = TestString(
content,
config.filters.wordFilter.words.loose,
config.filters.wordFilter.words.strict,
config.filters.wordFilter.words.strict
);
if (check !== null) {
messageException(message.guild.id, message.channel.id, message.id);

@ -618,37 +618,37 @@ export class ScanCache {
}
async write(hash: string, type: "nsfw" | "malware" | "bad_link", data: boolean, tags?: string[]) {
await this.scanCache.insertOne(
{ hash: hash, [type]: data, tags: tags ?? [], addedAt: new Date() },
collectionOptions
);
// await this.scanCache.updateOne(
// { hash: hash },
// {
// $set: (() => {
// switch (type) {
// case "nsfw": {
// return { nsfw: data, addedAt: new Date() };
// }
// case "malware": {
// return { malware: data, addedAt: new Date() };
// }
// case "bad_link": {
// return { bad_link: data, tags: tags ?? [], addedAt: new Date() };
// }
// default: {
// throw new Error("Invalid type");
// }
// }
// })()
// // No you can't just do { [type]: data }, yes it's a typescript error, no I don't know how to fix it
// // cleanly, yes it would be marginally more elegant, no it's not essential, yes I'd be happy to review
// // PRs that did improve this snippet
// // Made an attempt... Gave up... Just Leave It
// // Counter: 2
// },
// Object.assign({ upsert: true }, collectionOptions)
// await this.scanCache.insertOne(
// { hash: hash, [type]: data, tags: tags ?? [], addedAt: new Date() },
// collectionOptions
// );
await this.scanCache.updateOne(
{ hash: hash },
{
$set: (() => {
switch (type) {
case "nsfw": {
return { nsfw: data, addedAt: new Date() };
}
case "malware": {
return { malware: data, addedAt: new Date() };
}
case "bad_link": {
return { bad_link: data, tags: tags ?? [], addedAt: new Date() };
}
default: {
throw new Error("Invalid type");
}
}
})()
// No you can't just do { [type]: data }, yes it's a typescript error, no I don't know how to fix it
// cleanly, yes it would be marginally more elegant, no it's not essential, yes I'd be happy to review
// PRs that did improve this snippet
// Made an attempt... Gave up... Just Leave It
// Counter: 2
},
Object.assign({ upsert: true }, collectionOptions)
);
}
async cleanup() {

Loading…
Cancel
Save