mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 14:50:57 +00:00
feat: make the support require nothing
This commit is contained in:
@@ -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).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user