good forst commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
|
||||
import { MessagesService } from './messages.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { RolesGuard } from '../auth/roles.guard';
|
||||
import { Roles } from '../auth/roles.decorator';
|
||||
import { CurrentTenantContext } from '../auth/current-tenant.decorator';
|
||||
import { TenantContext } from '../../common/tenant-context';
|
||||
|
||||
@Controller('admin/messages')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('OWNER', 'ADMIN')
|
||||
export class MessagesController {
|
||||
constructor(private readonly messagesService: MessagesService) {}
|
||||
|
||||
@Get('pending')
|
||||
listPending(@CurrentTenantContext() ctx: TenantContext) {
|
||||
return this.messagesService.listPending(ctx.tenantId);
|
||||
}
|
||||
|
||||
@Get('pending/count')
|
||||
pendingCount(@CurrentTenantContext() ctx: TenantContext) {
|
||||
return this.messagesService.pendingCount(ctx.tenantId);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
get(
|
||||
@CurrentTenantContext() ctx: TenantContext,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
return this.messagesService.get(ctx.tenantId, id);
|
||||
}
|
||||
|
||||
@Post(':id/approve')
|
||||
approve(
|
||||
@CurrentTenantContext() ctx: TenantContext,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
return this.messagesService.approve(ctx.tenantId, ctx.adminId ?? '', id);
|
||||
}
|
||||
|
||||
@Post('reindex')
|
||||
reindex(@CurrentTenantContext() ctx: TenantContext) {
|
||||
return this.messagesService.reindexApproved(ctx.tenantId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user