diff --git a/server/lib/database/channel.ts b/server/lib/database/channel.ts index d7a76d69..803f4af8 100644 --- a/server/lib/database/channel.ts +++ b/server/lib/database/channel.ts @@ -54,7 +54,11 @@ interface ChannelInfos { ownerAccountId: number } -async function getChannelInfosById (options: RegisterServerOptions, channelId: number): Promise { +async function getChannelInfosById ( + options: RegisterServerOptions, + channelId: number, + restrictToLocalChannels: boolean = false +): Promise { if (!channelId) { throw new Error('Missing channelId') } @@ -69,7 +73,11 @@ async function getChannelInfosById (options: RegisterServerOptions, channelId: n ' "videoChannel"."accountId" as "ownerAccountId"' + ' FROM "videoChannel"' + ' RIGHT JOIN "actor" ON "actor"."id" = "videoChannel"."actorId"' + - ' WHERE "videoChannel"."id" = ' + channelId.toString() + ' WHERE "videoChannel"."id" = ' + channelId.toString() + + (restrictToLocalChannels + ? ' AND "serverId" is null ' + : '' + ) ) if (!Array.isArray(results)) { throw new Error('getChannelInfosById: query result is not an array.') diff --git a/server/lib/routers/api/moderation.ts b/server/lib/routers/api/moderation.ts index 17512ad6..1061234e 100644 --- a/server/lib/routers/api/moderation.ts +++ b/server/lib/routers/api/moderation.ts @@ -19,7 +19,7 @@ async function initModerationApiRouter (options: RegisterServerOptions): Promise return } - const channelInfos = await getChannelInfosById(options, parseInt(channelId)) + const channelInfos = await getChannelInfosById(options, parseInt(channelId), true) if (!channelInfos) { logger.warn(`Channel ${channelId} not found`) res.sendStatus(404)