import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; import { TelegrafExecutionContext } from '../../../lib/execution-context/telegraf-execution-context'; import { Context } from '../../interfaces/context.interface'; import { TelegrafException } from '../../../lib/errors'; @Injectable() export class AdminGuard implements CanActivate { private readonly ADMIN_IDS = []; canActivate(context: ExecutionContext): boolean { const ctx = TelegrafExecutionContext.create(context); const { from } = ctx.getContext(); const isAdmin = this.ADMIN_IDS.includes(from.id); if (!isAdmin) { throw new TelegrafException('You are not admin >:('); } return true; } }