mirror of
https://github.com/Discreetly/server.git
synced 2026-01-09 12:37:58 -05:00
fixed room lookups but createRooms is still broken
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -14,7 +14,7 @@
|
||||
"body-parser": "^1.20.2",
|
||||
"cors": "^2.8.5",
|
||||
"discreetly-claimcodes": "^1.1.3",
|
||||
"discreetly-interfaces": "^0.1.25",
|
||||
"discreetly-interfaces": "^0.1.29",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"express-basic-auth": "^1.2.1",
|
||||
@@ -3470,9 +3470,9 @@
|
||||
"integrity": "sha512-2QnlhYUPIGLl11XgxIxl6ZKIJZoS2T1ABIHbqjBbec0YYQ2qfWZ7JWH53OZm0mqeO8Dbjon5zK3YNoGiuYJ1Gg=="
|
||||
},
|
||||
"node_modules/discreetly-interfaces": {
|
||||
"version": "0.1.25",
|
||||
"resolved": "https://registry.npmjs.org/discreetly-interfaces/-/discreetly-interfaces-0.1.25.tgz",
|
||||
"integrity": "sha512-yWKAycHE6mwJbROT+9rQNE5fwYrYmL+VH9ZJfHl2nqt3L++31djQjVgV2xG5/rYBTrkUPnEbFXpzRF1i2pqO7g==",
|
||||
"version": "0.1.29",
|
||||
"resolved": "https://registry.npmjs.org/discreetly-interfaces/-/discreetly-interfaces-0.1.29.tgz",
|
||||
"integrity": "sha512-3R63KkmB+wFKFFzD9DixX3VDoLCYkDuMQZucAItmXbjE+0tFgmrK683a1/WBI9VkBhARip6HsVNrjzaGqdR1Aw==",
|
||||
"dependencies": {
|
||||
"poseidon-lite": "^0.2.0",
|
||||
"rlnjs": "^3.1.4"
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"body-parser": "^1.20.2",
|
||||
"cors": "^2.8.5",
|
||||
"discreetly-claimcodes": "^1.1.3",
|
||||
"discreetly-interfaces": "^0.1.25",
|
||||
"discreetly-interfaces": "^0.1.29",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"express-basic-auth": "^1.2.1",
|
||||
|
||||
@@ -10,17 +10,6 @@ datasource db {
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
enum RoomMembershipType {
|
||||
IDENTITY_LIST
|
||||
RLN_CONTRACT
|
||||
BANDADA
|
||||
}
|
||||
|
||||
enum RoomType {
|
||||
PUBLIC
|
||||
PRIVATE
|
||||
PIXEL
|
||||
}
|
||||
|
||||
model Rooms {
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
@@ -29,7 +18,7 @@ model Rooms {
|
||||
rateLimit Int @default(1000) // epoch length in ms
|
||||
banRateLimit Int @default(1000000) // starting number of epochs banned for
|
||||
userMessageLimit Int @default(1) // per epoch
|
||||
membershipType RoomMembershipType @default(IDENTITY_LIST)
|
||||
membershipType String @default("IDENTITY_LIST")
|
||||
identities String[] @default([])
|
||||
contractAddress String? // RLN_CONTRACT as "chainID:0xADDRESS"
|
||||
bandadaAddress String? // BANDADA as "url:groupID"
|
||||
@@ -37,7 +26,7 @@ model Rooms {
|
||||
messages Messages[]
|
||||
claimCodes ClaimCodes[] @relation(fields: [claimCodeIds], references: [id])
|
||||
claimCodeIds String[] @default([]) @db.ObjectId
|
||||
type RoomType @default(PUBLIC)
|
||||
type String
|
||||
}
|
||||
|
||||
model ClaimCodes {
|
||||
|
||||
@@ -18,8 +18,8 @@ interface RoomsFromClaimCode {
|
||||
roomIds: string[];
|
||||
}
|
||||
|
||||
export function getRoomByID(id: string): Promise<RoomI | null> {
|
||||
return prisma.rooms
|
||||
export async function getRoomByID(id: string): Promise<RoomI | null> {
|
||||
const room = await prisma.rooms
|
||||
.findUnique({
|
||||
where: {
|
||||
roomId: id
|
||||
@@ -44,6 +44,12 @@ export function getRoomByID(id: string): Promise<RoomI | null> {
|
||||
console.error(err);
|
||||
throw err; // Add this line to throw the error
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
if (room) {
|
||||
resolve(room as RoomI);
|
||||
}
|
||||
reject('Room not found');
|
||||
});
|
||||
}
|
||||
|
||||
export async function getRoomsByIdentity(identity: string): Promise<string[]> {
|
||||
@@ -108,10 +114,16 @@ export function updateRoomIdentities(idc: string, roomIds: string[]): Promise<an
|
||||
});
|
||||
}
|
||||
|
||||
export function findUpdatedRooms(roomIds: string[]): Promise<RoomI[]> {
|
||||
return prisma.rooms.findMany({
|
||||
export async function findUpdatedRooms(roomIds: string[]): Promise<RoomI[]> {
|
||||
const rooms = await prisma.rooms.findMany({
|
||||
where: { id: { in: roomIds } }
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
if (rooms) {
|
||||
resolve(rooms as RoomI[]);
|
||||
}
|
||||
reject('No rooms found');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user