Builtin Prosody: adding the prosody-room-type settings to allow rooms to be per channel or per video. WIP.

This commit is contained in:
John Livingston
2021-08-05 15:41:49 +02:00
parent 5237c20332
commit 5c0b274f39
9 changed files with 203 additions and 70 deletions

View File

@ -45,7 +45,43 @@ async function getUserNameByChannelId (options: RegisterServerOptions, channelId
return results[0].username ?? null
}
interface ChannelInfos {
id: number
name: string
displayName: string
}
async function getChannelInfosById (options: RegisterServerOptions, channelId: number): Promise<ChannelInfos | null> {
if (!channelId) {
throw new Error('Missing channelId')
}
if (!Number.isInteger(channelId)) {
throw new Error('Invalid channelId: not an integer')
}
const [results] = await options.peertubeHelpers.database.query(
'SELECT' +
' "actor"."preferredUsername" as "channelName", ' +
' "videoChannel"."name" as "channelDisplayName"' +
' FROM "videoChannel"' +
' RIGHT JOIN "actor" ON "actor"."id" = "videoChannel"."actorId"' +
' WHERE "videoChannel"."id" = ' + channelId.toString()
)
if (!Array.isArray(results)) {
throw new Error('getChannelInfosById: query result is not an array.')
}
if (!results[0]) {
options.peertubeHelpers.logger.debug(`getChannelInfosById: channel ${channelId} not found.`)
return null
}
return {
id: channelId,
name: results[0].channelName ?? '',
displayName: results[0].channelDisplayName ?? ''
}
}
export {
getChannelNameById,
getUserNameByChannelId
getUserNameByChannelId,
getChannelInfosById
}