feat: make the support require nothing

This commit is contained in:
Nathnael
2026-07-08 05:33:02 +00:00
parent 9cd3ac42b4
commit a817976db8
11 changed files with 237 additions and 508 deletions

View File

@@ -17,6 +17,8 @@ import { JwtGuard } from '../../common/jwt.guard';
import {
CreateConversationDto,
CreateGuestConversationDto,
DeviceIdBodyDto,
DeviceSendMessageDto,
GuestIdBodyDto,
GuestSendMessageDto,
ListConversationsQueryDto,
@@ -103,7 +105,39 @@ export class SupportController {
return this.service.unreadCount('USER', { iamUserId: userId(req) });
}
// ---- customer: guest (unauthenticated) --------------------------------
// ---- customer: device-scoped single thread (portal) -------------------
// No auth, no forms. One conversation per device id (localStorage). Anyone
// with the device id can see that thread — accepted MVP trade-off.
@Get('device/thread')
@IsPublic()
@ApiOperation({ summary: "Get the device's support thread + messages" })
deviceThread(@Query('deviceId') deviceId: string) {
return this.service.getDeviceThread(deviceId);
}
@Post('device/messages')
@IsPublic()
@ApiOperation({ summary: 'Send a message (creates the thread on first send)' })
deviceSend(@Body() body: DeviceSendMessageDto) {
return this.service.sendDeviceMessage(body.deviceId, body.text);
}
@Post('device/read')
@IsPublic()
@ApiOperation({ summary: 'Mark the device thread read' })
deviceRead(@Body() body: DeviceIdBodyDto) {
return this.service.markDeviceRead(body.deviceId);
}
@Get('device/unread-count')
@IsPublic()
@ApiOperation({ summary: "Count the device thread's unread messages" })
deviceUnread(@Query('deviceId') deviceId: string) {
return this.service.unreadCount('USER', { guestId: deviceId });
}
// ---- customer: guest (unauthenticated, multi-ticket) ------------------
// No JwtGuard. Access is scoped by a client-generated `guestId` (the bearer
// of access — anyone with it sees that thread; accepted MVP trade-off).