add blacklist model and refactor channel kind 43 43

This commit is contained in:
Ren Amamiya
2023-04-25 12:51:56 +07:00
parent cf26aa504e
commit 95e4a27b69
6 changed files with 96 additions and 32 deletions

View File

@@ -170,3 +170,26 @@ export async function updateLastLogin(value: number) {
const db = await connect();
return await db.execute(`UPDATE settings SET value = ${value} WHERE key = "last_login";`);
}
// get blacklist by kind and account id
export async function getBlacklist(account_id: number, kind: number) {
const db = await connect();
return await db.select(`SELECT content FROM blacklist WHERE account_id = "${account_id}" AND kind = "${kind}";`);
}
// add to blacklist
export async function addToBlacklist(account_id: number, content: string, kind: number, status?: number) {
const db = await connect();
return await db.execute('INSERT OR IGNORE INTO blacklist (account_id, content, kind, status) VALUES (?, ?, ?, ?);', [
account_id,
content,
kind,
status || 1,
]);
}
// update item in blacklist
export async function updateItemInBlacklist(content: string, status: number) {
const db = await connect();
return await db.execute(`UPDATE blacklist SET status = "${status}" WHERE content = "${content}";`);
}