Initial WIP commit to add <podcast:chat> tag to Podcast RSS feeds
This commit is contained in:
committed by
John Livingston
parent
81110da5e1
commit
97a5d4b408
@ -1,4 +1,4 @@
|
||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||
import type { RegisterServerOptions, Video } from '@peertube/peertube-types'
|
||||
import { migrateSettings } from './lib/migration/settings'
|
||||
import { initSettings } from './lib/settings'
|
||||
import { initCustomFields } from './lib/custom-fields'
|
||||
@ -8,6 +8,8 @@ import { prepareProsody, ensureProsodyRunning, ensureProsodyNotRunning } from '.
|
||||
import { unloadDebugMode } from './lib/debug'
|
||||
import { loadLoc } from './lib/loc'
|
||||
import decache from 'decache'
|
||||
import { CustomTag } from '@peertube/feed/lib/typings'
|
||||
import { URL } from 'url'
|
||||
|
||||
// FIXME: Peertube unregister don't have any parameter.
|
||||
// Using this global variable to fix this, so we can use helpers to unregister.
|
||||
@ -31,6 +33,33 @@ async function register (options: RegisterServerOptions): Promise<any> {
|
||||
await initRouters(options)
|
||||
await initFederation(options)
|
||||
|
||||
options.registerHook({
|
||||
// @ts-expect-error Type doesn't exist for peertube 5.1 yet
|
||||
target: 'filter:feed.podcast.video.create-custom-tags.result',
|
||||
handler: (result: CustomTag[], { video, liveItem }: { video: Video, liveItem: boolean }) => {
|
||||
if (!liveItem) {
|
||||
return result
|
||||
}
|
||||
|
||||
const webserverUrl = options.peertubeHelpers.config.getWebserverUrl()
|
||||
const hostname = (new URL(webserverUrl)).hostname
|
||||
const embedUrl = `${webserverUrl}/plugins/livechat/router/webchat/room/${encodeURIComponent(video.uuid)}`
|
||||
const xmppHostname = `room.${hostname}`
|
||||
|
||||
return result.concat([
|
||||
{
|
||||
name: 'podcast:chat',
|
||||
attributes: {
|
||||
server: xmppHostname,
|
||||
protocol: 'xmpp',
|
||||
space: `${video.uuid}@${xmppHostname}`,
|
||||
embedUrl: embedUrl
|
||||
}
|
||||
}
|
||||
])
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
await prepareProsody(options)
|
||||
await ensureProsodyRunning(options)
|
||||
|
Reference in New Issue
Block a user