Files
lingxi-web/telegram-gateway/src/modules/tg-dialogs/tg-dialogs.controller.ts
T
wmq 06112602ec feat(gateway): include production Telegram user gateway
Version the NestJS TDLib gateway with Docker deployment, migrations, automated tests and platform integration documentation while excluding all account sessions, credentials, runtime databases and backups.
2026-08-01 18:38:20 +08:00

85 lines
2.6 KiB
TypeScript

import { Controller, Post, Get, Param, Body, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiSecurity } from '@nestjs/swagger';
import { TgDialogsService } from './tg-dialogs.service';
import { TenantGuard } from '../../common/guards/tenant.guard';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
@ApiTags('TG Dialogs')
@ApiBearerAuth()
@ApiSecurity('tenant-id')
@Controller('tg-accounts/:accountId/dialogs')
@UseGuards(TenantGuard)
export class TgDialogsController {
constructor(private readonly tgDialogsService: TgDialogsService) {}
@Get('me')
getMe(
@CurrentUser('tenantId') tenantId: string,
@Param('accountId') accountId: string,
) {
return this.tgDialogsService.getMe(tenantId, accountId);
}
@Post('open-by-phone')
openByPhone(
@CurrentUser('tenantId') tenantId: string,
@Param('accountId') accountId: string,
@Body() body: { phoneNumber: string },
) {
return this.tgDialogsService.openByPhone(tenantId, accountId, body.phoneNumber);
}
@Post('open-by-username')
openByUsername(
@CurrentUser('tenantId') tenantId: string,
@Param('accountId') accountId: string,
@Body() body: { username: string },
) {
return this.tgDialogsService.openByUsername(tenantId, accountId, body.username);
}
@Post('open-by-user/:userId')
openByUserId(
@CurrentUser('tenantId') tenantId: string,
@Param('accountId') accountId: string,
@Param('userId') userId: string,
) {
return this.tgDialogsService.openByUserId(tenantId, accountId, +userId);
}
@Get('sessions')
getActiveSessions(
@CurrentUser('tenantId') tenantId: string,
@Param('accountId') accountId: string,
) {
return this.tgDialogsService.getActiveSessions(tenantId, accountId);
}
@Post('sessions/:sessionId/terminate')
terminateSession(
@CurrentUser('tenantId') tenantId: string,
@Param('accountId') accountId: string,
@Param('sessionId') sessionId: string,
) {
return this.tgDialogsService.terminateSession(tenantId, accountId, sessionId);
}
@Post('users/:userId/block')
blockUser(
@CurrentUser('tenantId') tenantId: string,
@Param('accountId') accountId: string,
@Param('userId') userId: string,
) {
return this.tgDialogsService.setUserBlocked(tenantId, accountId, Number(userId), true);
}
@Post('users/:userId/unblock')
unblockUser(
@CurrentUser('tenantId') tenantId: string,
@Param('accountId') accountId: string,
@Param('userId') userId: string,
) {
return this.tgDialogsService.setUserBlocked(tenantId, accountId, Number(userId), false);
}
}