1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/mipilin synced 2025-05-10 23:33:07 +00:00

uhhh yeah

Signed-off-by: roxwize <rae@roxwize.xyz>
This commit is contained in:
Rae 5e 2024-12-25 18:44:29 -05:00
parent 5abe0b5fad
commit afc634b0d2
Signed by: rae
GPG key ID: 5B1A0FAB9BAB81EE
43 changed files with 573 additions and 3792 deletions

View file

@ -4,6 +4,12 @@ import { inviteCodes, updates } from "../db/schema.js";
import { count, desc, eq } from "drizzle-orm";
import fs from "node:fs/promises";
export enum UserStatus {
MODERATOR = 0b001,
BANNED = 0b010,
TRUSTED = 0b100
};
const nonceChars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_";
let nonce: string;
@ -64,7 +70,7 @@ export async function render(
}
const inviteCodeChars = "abcdefghijklmnopqrstuvwxyz0123456789"
export async function createInviteCode(db: NodePgDatabase, user: number, expires: Date, confersModerator = false) {
export async function createInviteCode(db: NodePgDatabase, user: number, expires: Date, confers = 0) {
let existingToken = 1, token: string;
while (existingToken) {
token = user.toString().padStart(4, "0") + "-"
@ -84,7 +90,7 @@ export async function createInviteCode(db: NodePgDatabase, user: number, expires
user: user || undefined,
granted: new Date(Date.now()),
expires,
confersModerator
confers
});
return token;
}