Users can save, pick, and delete prepared messages shared across the organization. Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Param,
|
|
Patch,
|
|
Post,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
import { CurrentUser } from '../auth/current-user.decorator';
|
|
import type { Actor } from '../common/record-scope';
|
|
import {
|
|
CreateSmsTemplateDto,
|
|
UpdateSmsTemplateDto,
|
|
} from './sms-templates.dto';
|
|
import { SmsTemplatesService } from './sms-templates.service';
|
|
|
|
@Controller('sms-templates')
|
|
@UseGuards(JwtAuthGuard)
|
|
export class SmsTemplatesController {
|
|
constructor(private readonly templates: SmsTemplatesService) {}
|
|
|
|
@Get()
|
|
list(@CurrentUser() user: Actor) {
|
|
return this.templates.list(user.organizationId);
|
|
}
|
|
|
|
@Post()
|
|
create(@CurrentUser() user: Actor, @Body() dto: CreateSmsTemplateDto) {
|
|
return this.templates.create(user.organizationId, dto);
|
|
}
|
|
|
|
@Patch(':id')
|
|
update(
|
|
@CurrentUser() user: Actor,
|
|
@Param('id') id: string,
|
|
@Body() dto: UpdateSmsTemplateDto,
|
|
) {
|
|
return this.templates.update(user.organizationId, id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(@CurrentUser() user: Actor, @Param('id') id: string) {
|
|
return this.templates.remove(user.organizationId, id);
|
|
}
|
|
}
|