fix: chat — group members endpoint (all roles), mention first-name only, restore direct-chat button
This commit is contained in:
@@ -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] },
|
||||
|
||||
Reference in New Issue
Block a user