mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 06:40:57 +00:00
feat: WIP element Chat intergration
This commit is contained in:
35
apps/edr-freight-api/src/modules/chat/chat.controller.ts
Normal file
35
apps/edr-freight-api/src/modules/chat/chat.controller.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Controller, Get, Post, UseGuards } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { CurrentUser } from '@tria-plc/api-common/modules/auth/decorators/current-user.decorator';
|
||||
import { JwtGuard } from '@tria-plc/api-common/modules/auth/services/jwt.guard';
|
||||
import type { TCurrentUser } from '@tria-plc/api-common/modules/auth/types/current-user.type';
|
||||
|
||||
import { ChatSync } from '../../common/booking-guards';
|
||||
import { ChatProvisioningService } from './chat-provisioning.service';
|
||||
import { ChatSsoService } from './chat-sso.service';
|
||||
|
||||
@ApiTags('chat')
|
||||
@Controller('chat')
|
||||
@ApiBearerAuth()
|
||||
export class ChatController {
|
||||
constructor(
|
||||
private readonly sso: ChatSsoService,
|
||||
private readonly provisioning: ChatProvisioningService,
|
||||
) {}
|
||||
|
||||
@Get('sso')
|
||||
@UseGuards(JwtGuard)
|
||||
@ApiOperation({ summary: 'One-click sign-in link into EDR internal chat' })
|
||||
getSso(@CurrentUser() user: TCurrentUser) {
|
||||
return this.sso.getSsoUrl(user);
|
||||
}
|
||||
|
||||
@Post('sync')
|
||||
@ChatSync()
|
||||
@ApiOperation({
|
||||
summary: 'Re-run the chat room/membership reconcile immediately (normally nightly)',
|
||||
})
|
||||
sync() {
|
||||
return this.provisioning.reconcile();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user