Fix: only local channels.

This commit is contained in:
John Livingston 2023-08-09 14:18:28 +02:00
parent a25c4822fa
commit cb6decfa84
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
2 changed files with 11 additions and 3 deletions

View File

@ -54,7 +54,11 @@ interface ChannelInfos {
ownerAccountId: number ownerAccountId: number
} }
async function getChannelInfosById (options: RegisterServerOptions, channelId: number): Promise<ChannelInfos | null> { async function getChannelInfosById (
options: RegisterServerOptions,
channelId: number,
restrictToLocalChannels: boolean = false
): Promise<ChannelInfos | null> {
if (!channelId) { if (!channelId) {
throw new Error('Missing channelId') throw new Error('Missing channelId')
} }
@ -69,7 +73,11 @@ async function getChannelInfosById (options: RegisterServerOptions, channelId: n
' "videoChannel"."accountId" as "ownerAccountId"' + ' "videoChannel"."accountId" as "ownerAccountId"' +
' FROM "videoChannel"' + ' FROM "videoChannel"' +
' RIGHT JOIN "actor" ON "actor"."id" = "videoChannel"."actorId"' + ' 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)) { if (!Array.isArray(results)) {
throw new Error('getChannelInfosById: query result is not an array.') throw new Error('getChannelInfosById: query result is not an array.')

View File

@ -19,7 +19,7 @@ async function initModerationApiRouter (options: RegisterServerOptions): Promise
return return
} }
const channelInfos = await getChannelInfosById(options, parseInt(channelId)) const channelInfos = await getChannelInfosById(options, parseInt(channelId), true)
if (!channelInfos) { if (!channelInfos) {
logger.warn(`Channel ${channelId} not found`) logger.warn(`Channel ${channelId} not found`)
res.sendStatus(404) res.sendStatus(404)