fix document 500 error and fix users tabel for bot
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
|
||||
import { PrismaService } from '../../infra/prisma.service';
|
||||
import { RbacService } from '../rbac.service';
|
||||
import {
|
||||
BOTFATHER_BOT_USERNAME,
|
||||
BOTFATHER_DISPLAY_NAME,
|
||||
@@ -16,7 +17,10 @@ export class BotFatherSeedService implements OnModuleInit {
|
||||
private cachedUserId: string | null = null;
|
||||
private cachedBotId: string | null = null;
|
||||
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly rbac: RbacService
|
||||
) {}
|
||||
|
||||
async onModuleInit() {
|
||||
await this.ensureBotFather();
|
||||
@@ -101,6 +105,7 @@ export class BotFatherSeedService implements OnModuleInit {
|
||||
|
||||
await this.upsertSetting(BOTFATHER_SETTING_USER_ID, botFatherUser.id, 'UUID системного пользователя BotFather');
|
||||
await this.upsertSetting(BOTFATHER_SETTING_BOT_ID, bot.id, 'UUID системного бота BotFather');
|
||||
await this.rbac.ensureBotUserRole(botFatherUser.id);
|
||||
|
||||
this.cachedUserId = botFatherUser.id;
|
||||
this.cachedBotId = bot.id;
|
||||
|
||||
@@ -11,6 +11,7 @@ import { PrismaService } from '../../infra/prisma.service';
|
||||
import { AccessService } from '../access.service';
|
||||
import { NotificationsService } from '../notifications.service';
|
||||
import { SettingsService } from '../settings.service';
|
||||
import { RbacService } from '../rbac.service';
|
||||
import { BotRateLimitService } from './bot-rate-limit.service';
|
||||
import { assertValidBotUsername, generateTelegramStyleBotToken, hashBotToken, normalizeBotUsername } from './bot-token.util';
|
||||
import { menuButtonToJson, parseMenuButtonInput, resolveComposerMenuButton } from './bot-menu-button.util';
|
||||
@@ -45,7 +46,8 @@ export class BotFatherService implements OnModuleInit {
|
||||
private readonly access: AccessService,
|
||||
private readonly settings: SettingsService,
|
||||
private readonly rateLimit: BotRateLimitService,
|
||||
private readonly notifications: NotificationsService
|
||||
private readonly notifications: NotificationsService,
|
||||
private readonly rbac: RbacService
|
||||
) {}
|
||||
|
||||
async onModuleInit() {
|
||||
@@ -84,6 +86,8 @@ export class BotFatherService implements OnModuleInit {
|
||||
select: { id: true }
|
||||
});
|
||||
|
||||
await this.rbac.ensureBotUserRole(systemUser.id);
|
||||
|
||||
this.logger.log(`Создан системный пользователь для бота @${bot.username}`);
|
||||
return { userId: systemUser.id, botId: bot.id };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user