fix document 500 error and fix users tabel for bot
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Body, Controller, ForbiddenException, Get, Param, Patch, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiBody, ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { map } from 'rxjs';
|
||||
import { CoreGrpcService } from '../core-grpc.service';
|
||||
import { CurrentAdmin } from '../decorators/current-admin.decorator';
|
||||
@@ -76,6 +77,38 @@ export class AdminController {
|
||||
return this.core.admin.SetSuperAdmin({ actorUserId: admin.id, userId, isSuperAdmin: dto.isSuperAdmin });
|
||||
}
|
||||
|
||||
@Get('bot-accounts')
|
||||
@ApiOperation({ summary: 'Системные учётные записи ботов', description: 'Возвращает пользователей, связанных с Telegram-ботами (BotFather и боты пользователей).' })
|
||||
listBotAccounts(@Query() query: ListUsersQueryDto, @CurrentAdmin() admin: AdminRequestUser) {
|
||||
if (!admin.canViewUsers && !admin.canManageUsers && !admin.isSuperAdmin && !admin.permissions.includes('bots.manage.all')) {
|
||||
throw new ForbiddenException('Недостаточно прав для просмотра ботов');
|
||||
}
|
||||
return this.core.admin.ListBotAccounts(query).pipe(
|
||||
map((response) => {
|
||||
const payload = response as { users?: Array<{ roles?: string[] }> };
|
||||
return {
|
||||
users: (payload.users ?? []).map((user) => ({
|
||||
...user,
|
||||
roles: user.roles ?? []
|
||||
}))
|
||||
};
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@Post(':userId/totp/admin-disable')
|
||||
@UseGuards(SuperAdminGuard)
|
||||
@ApiOperation({ summary: 'Отключить 2FA пользователя', description: 'Супер-администратор может принудительно отключить TOTP без кода пользователя.' })
|
||||
@ApiParam({ name: 'userId', description: 'ID пользователя' })
|
||||
adminDisableTotp(@Param('userId') userId: string, @CurrentAdmin() admin: AdminRequestUser) {
|
||||
return firstValueFrom(
|
||||
this.core.security.AdminDisableTotp({
|
||||
actorUserId: admin.id,
|
||||
userId
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@Patch(':userId/verification')
|
||||
@ApiOperation({ summary: 'Верифицировать или снять верификацию', description: 'Требуется право users.verify.' })
|
||||
@ApiParam({ name: 'userId', description: 'ID пользователя' })
|
||||
|
||||
Reference in New Issue
Block a user