mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-19 05:58:32 +03:00
Add remove feature to warnUser
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import crypto from 'crypto';
|
||||
import { HashedValue } from '../types/hash.model';
|
||||
|
||||
export function getHash(value: string, times = 5000) {
|
||||
if (times <= 0) return "";
|
||||
export function getHash<T extends string>(value: T, times = 5000): T & HashedValue {
|
||||
if (times <= 0) return "" as T & HashedValue;
|
||||
|
||||
for (let i = 0; i < times; i++) {
|
||||
let hashCreator = crypto.createHash('sha256');
|
||||
value = hashCreator.update(value).digest('hex');
|
||||
value = hashCreator.update(value).digest('hex') as T;
|
||||
}
|
||||
|
||||
return value;
|
||||
return value as T & HashedValue;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {db} from '../databases/databases';
|
||||
import { HashedUserID } from '../types/user.model';
|
||||
|
||||
export function isUserVIP(userID: string): boolean {
|
||||
export function isUserVIP(userID: HashedUserID): boolean {
|
||||
return db.prepare('get', "SELECT count(*) as userCount FROM vipUsers WHERE userID = ?", [userID]).userCount > 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user