import { Inject, Injectable } from '@nestjs/common'; import { Endpoint } from '@/server/api/endpoint-base.js'; import type { ChannelsRepository } from '@/models/index.js'; import { ChannelEntityService } from '@/core/entities/ChannelEntityService.js'; import { DI } from '@/di-symbols.js'; import { ApiError } from '../../error.js'; // eslint-disable-next-line import/no-default-export @Injectable() export default class extends Endpoint<'channels/show'> { name = 'channels/show' as const; constructor( @Inject(DI.channelsRepository) private channelsRepository: ChannelsRepository, private channelEntityService: ChannelEntityService, ) { super(async (ps, me) => { const channel = await this.channelsRepository.findOneBy({ id: ps.channelId, }); if (channel == null) { throw new ApiError(this.meta.errors.noSuchChannel); } return await this.channelEntityService.pack(channel, me, true); }); } }