feat: 房间创建者管理权限——锁定房间、踢人、结束投票
This commit is contained in:
@@ -51,6 +51,9 @@ export async function buildRoomStatus(
|
||||
likeCounts,
|
||||
swipeCounts: data.swipeCounts,
|
||||
restaurants: data.restaurants,
|
||||
creatorId: data.creatorId,
|
||||
locked: data.locked,
|
||||
users: data.users,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -9,6 +9,9 @@ export interface RoomData {
|
||||
likes: Record<string, string[]>;
|
||||
swipeCounts: Record<string, number>;
|
||||
match: string | null;
|
||||
creatorId: string;
|
||||
locked: boolean;
|
||||
kickedUsers: string[];
|
||||
}
|
||||
|
||||
function generateRoomId(): string {
|
||||
@@ -22,6 +25,9 @@ function normalize(raw: Partial<RoomData>): RoomData {
|
||||
likes: raw.likes ?? {},
|
||||
swipeCounts: raw.swipeCounts ?? {},
|
||||
match: raw.match ?? null,
|
||||
creatorId: raw.creatorId ?? "",
|
||||
locked: raw.locked ?? false,
|
||||
kickedUsers: raw.kickedUsers ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -45,7 +51,7 @@ async function cleanupExpiredRooms() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function createRoom(restaurants: Restaurant[]): Promise<string> {
|
||||
export async function createRoom(restaurants: Restaurant[], creatorId: string): Promise<string> {
|
||||
await cleanupExpiredRooms();
|
||||
|
||||
const data: RoomData = {
|
||||
@@ -54,6 +60,9 @@ export async function createRoom(restaurants: Restaurant[]): Promise<string> {
|
||||
likes: {},
|
||||
swipeCounts: {},
|
||||
match: null,
|
||||
creatorId,
|
||||
locked: false,
|
||||
kickedUsers: [],
|
||||
};
|
||||
|
||||
const expiresAt = new Date(Date.now() + ROOM_TTL_MS);
|
||||
|
||||
Reference in New Issue
Block a user