fix: chat — group members endpoint (all roles), mention first-name only, restore direct-chat button

This commit is contained in:
2026-04-14 17:44:33 +03:00
parent 8353eb7c7f
commit 18e1eb86af
3 changed files with 37 additions and 10 deletions

View File

@@ -521,6 +521,24 @@ const chatRoutes: FastifyPluginAsync = async (fastify) => {
// ── POST notify ───────────────────────────────────────────────────────────
// ── GET /chat/members — list hotel members (accessible to all roles) ─────
fastify.get<SlugParam>(
'/api/hotels/:slug/chat/members',
{ onRequest: [fastify.authenticate] },
async (request, reply) => {
const { slug } = request.params
if (!canAccess(request.user.hotelSlug, request.user.role, slug)) return reply.code(403).send({ error: 'Forbidden' })
const hotelId = await getHotelId(slug)
if (!hotelId) return reply.code(404).send({ error: 'Hotel not found' })
const { rows } = await db.query(
`SELECT id, name, role FROM users WHERE hotel_id = $1 AND active = true ORDER BY name`,
[hotelId],
)
return rows
},
)
fastify.post<SlugParam & { Body: { text: string; system_name?: string } }>(
'/api/hotels/:slug/chat/notify',
{ onRequest: [fastify.authenticate] },