mirror of
https://github.com/Discreetly/server.git
synced 2026-04-17 03:00:55 -04:00
feat(create room) custom room id
This commit is contained in:
@@ -12,7 +12,7 @@ async function main() {
|
||||
await createRoom('Alpha Testers', 100000, 12, 30, 20, 'PUBLIC_CHAT');
|
||||
await createRoom('PSE', 100000, 12, 80, 20, 'PUBLIC_CHAT');
|
||||
await createRoom('SBC Experiments', 100000, 12, 20, 20, 'PUBLIC_CHAT');
|
||||
await createRoom('Ban Appeals', 10000, 1, 0, 5, 'PUBLIC_CHAT');
|
||||
await createRoom('Ban Appeals', 10000, 1, 0, 5, 'PUBLIC_CHAT', '666');
|
||||
}
|
||||
|
||||
await main();
|
||||
|
||||
@@ -29,21 +29,22 @@ export async function createRoom(
|
||||
bandadaAddress?: string,
|
||||
bandadaGroupId?: string,
|
||||
bandadaAPIKey?: string,
|
||||
membershipType?: string
|
||||
membershipType?: string,
|
||||
id?: string
|
||||
): Promise<string | undefined> {
|
||||
const claimCodes: { claimcode: string }[] = genClaimCodeArray(numClaimCodes);
|
||||
const mockUsers: string[] = genMockUsers(approxNumMockUsers);
|
||||
const identityCommitments: string[] = mockUsers.map((user) =>
|
||||
getRateCommitmentHash(BigInt(user), BigInt(userMessageLimit)).toString()
|
||||
);
|
||||
const roomIdFromRandom = roomName === 'Ban Appeals' ? '666' : randomBigInt().toString();
|
||||
const roomId = id ? id : randomBigInt().toString();
|
||||
const roomData = {
|
||||
where: {
|
||||
roomId: roomIdFromRandom
|
||||
roomId: roomId
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
roomId: roomIdFromRandom,
|
||||
roomId: roomId,
|
||||
name: roomName,
|
||||
rateLimit: rateLimit,
|
||||
userMessageLimit: userMessageLimit,
|
||||
@@ -63,7 +64,7 @@ export async function createRoom(
|
||||
return await prisma.rooms
|
||||
.upsert(roomData)
|
||||
.then(() => {
|
||||
return roomIdFromRandom;
|
||||
return roomId;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
|
||||
Reference in New Issue
Block a user