Silownie: dolaczenie do prywatnej silowni odrzucane (403) - tylko zaproszenia
This commit is contained in:
@@ -158,10 +158,11 @@ export async function rateGym(
|
||||
return { vote: existing?.vote === vote ? null : vote, up, down };
|
||||
}
|
||||
|
||||
/** Join an existing gym (creates a MEMBER membership). */
|
||||
/** Join an existing gym (creates a MEMBER membership). Private gyms are invitation-only. */
|
||||
export async function joinGym(prisma: PrismaClient, userId: string, gymId: string) {
|
||||
const gym = await prisma.gym.findUnique({ where: { id: gymId } });
|
||||
if (!gym) throw notFound('Gym not found');
|
||||
if (gym.isPrivate) throw forbidden('Private gyms are invitation-only');
|
||||
const existing = await prisma.gymMembership.findUnique({
|
||||
where: { userId_gymId: { userId, gymId } },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user