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:
parent
5abe0b5fad
commit
afc634b0d2
43 changed files with 573 additions and 3792 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue