fix: chat — group creation (snake_case member_ids), readable mention color

This commit is contained in:
2026-04-14 17:54:05 +03:00
parent 18e1eb86af
commit 2cdc44b495
2 changed files with 7 additions and 2 deletions

View File

@@ -341,8 +341,13 @@ const chatRoutes: FastifyPluginAsync = async (fastify) => {
const hotelId = await getHotelId(slug)
if (!hotelId) return reply.code(404).send({ error: 'Hotel not found' })
const { name, memberIds } = request.body
const name = request.body?.name
// Frontend sends snake_case (transformKeysToSnake converts camelCase)
const memberIds: string[] = Array.isArray((request.body as Record<string, unknown>)?.member_ids)
? (request.body as Record<string, unknown>).member_ids as string[]
: Array.isArray(request.body?.memberIds) ? request.body.memberIds : []
if (!name?.trim()) return reply.code(400).send({ error: 'Name required' })
if (memberIds.length === 0) return reply.code(400).send({ error: 'At least one member required' })
const userId = request.user.sub
const allMembers = [...new Set([userId, ...memberIds])]