mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-08 12:37:00 +03:00
addUserAsVIP
- add genAnonUser
This commit is contained in:
@@ -2,10 +2,12 @@ import { genRandom } from "./getRandom";
|
||||
import { UserID, HashedUserID } from "../../src/types/user.model";
|
||||
import { getHash } from "../../src/utils/getHash";
|
||||
|
||||
type info = Record<string, any>
|
||||
|
||||
export interface User {
|
||||
privID: UserID,
|
||||
pubID: HashedUserID
|
||||
info: Record<string, any>
|
||||
info: info
|
||||
}
|
||||
export type userArray = Record<string, User>
|
||||
|
||||
@@ -14,10 +16,16 @@ export interface UsernameUser extends User {
|
||||
}
|
||||
export type usernameUserArray = Record<string, UsernameUser>
|
||||
|
||||
export const genUser = (fnname: string, testcase: string): User => {
|
||||
export const genUser = (fnname: string, testcase: string, info: info = {}): User => {
|
||||
const privID = `${fnname}-${testcase}-${genRandom(2)}` as UserID;
|
||||
const pubID = getHash(privID);
|
||||
return { privID, pubID, info: {} };
|
||||
return { privID, pubID, info };
|
||||
};
|
||||
|
||||
export const genAnonUser = (info: info = {}): User => {
|
||||
const privID = `user-${genRandom()}` as UserID;
|
||||
const pubID = getHash(privID);
|
||||
return { privID, pubID, info };
|
||||
};
|
||||
|
||||
export const genUsers = (fnname: string, testcase: string[]): userArray => {
|
||||
|
||||
Reference in New Issue
Block a user