New debug modes for AP/RSS publishing.
This commit is contained in:
parent
cc68eb9010
commit
ad8b71b582
@ -15,6 +15,8 @@ interface DebugContent {
|
||||
logRotateEvery?: number
|
||||
remoteServerInfosMaxAge?: number
|
||||
prosodyDebuggerOptions?: ProsodyDebuggerOptions
|
||||
alwaysPublishXMPPRoom?: boolean
|
||||
enablePodcastChatTagForNonLive?: boolean
|
||||
}
|
||||
|
||||
type DebugNumericValue = 'renewCertCheckInterval'
|
||||
@ -23,6 +25,8 @@ type DebugNumericValue = 'renewCertCheckInterval'
|
||||
| 'logRotateCheckInterval'
|
||||
| 'remoteServerInfosMaxAge'
|
||||
|
||||
type DebugBooleanValue = 'alwaysPublishXMPPRoom' | 'enablePodcastChatTagForNonLive'
|
||||
|
||||
let debugContent: DebugContent | null | false = null
|
||||
function _readDebugFile (options: RegisterServerOptions): DebugContent | false {
|
||||
if (debugContent !== null) { return debugContent }
|
||||
@ -55,6 +59,8 @@ function _readDebugFile (options: RegisterServerOptions): DebugContent | false {
|
||||
debugContent.renewCertCheckInterval = _getNumericOptions(options, json, 'renew_cert_check_interval')
|
||||
debugContent.renewSelfSignedCertInterval = _getNumericOptions(options, json, 'renew_self_signed_cert_interval')
|
||||
debugContent.remoteServerInfosMaxAge = _getNumericOptions(options, json, 'remote_server_infos_max_age')
|
||||
debugContent.alwaysPublishXMPPRoom = json.always_publish_xmpp_room === true
|
||||
debugContent.enablePodcastChatTagForNonLive = json.enable_podcast_chat_tag_for_nonlive === true
|
||||
} catch (err) {
|
||||
logger.error('Failed to read the debug_mode file content:', err)
|
||||
}
|
||||
@ -100,11 +106,19 @@ function unloadDebugMode (): void {
|
||||
/**
|
||||
* Check if debug mode is enabled
|
||||
* @param options server options
|
||||
* @param feature optional feature name.
|
||||
* Returns true only if the debug_mode file contains a key with that name, and that is true.
|
||||
* @returns true if debug mode enabled
|
||||
*/
|
||||
function isDebugMode (options: RegisterServerOptions): boolean {
|
||||
function isDebugMode (options: RegisterServerOptions, feature?: DebugBooleanValue): boolean {
|
||||
const debugContent = _readDebugFile(options)
|
||||
return !!debugContent
|
||||
if (!debugContent) {
|
||||
return false
|
||||
}
|
||||
if (!feature) {
|
||||
return true
|
||||
}
|
||||
return debugContent[feature] === true
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@ import { canonicalizePluginUri } from '../uri/canonicalize'
|
||||
import { getProsodyDomain } from '../prosody/config/domain'
|
||||
import { fillVideoCustomFields } from '../custom-fields'
|
||||
import { loc } from '../loc'
|
||||
import { isDebugMode } from '../debug'
|
||||
|
||||
/**
|
||||
* This function adds LiveChat information on video ActivityPub data if relevant.
|
||||
@ -99,7 +100,8 @@ async function videoBuildJSONLD (
|
||||
// - prosody-room-allow-s2s
|
||||
// - prosody-s2s-port
|
||||
// For now, this can be tested reading serverInfos.directs2s
|
||||
if (serverInfos.directs2s) {
|
||||
// There is a debug_mode flag to always enable it.
|
||||
if (!!serverInfos.directs2s || isDebugMode(options, 'alwaysPublishXMPPRoom')) {
|
||||
discussionLinks.push({
|
||||
type: 'Link',
|
||||
name: chatTitle,
|
||||
|
@ -4,6 +4,7 @@ import { videoHasWebchat } from '../../../shared/lib/video'
|
||||
import { fillVideoCustomFields } from '../custom-fields'
|
||||
import { getProsodyDomain } from '../prosody/config/domain'
|
||||
import { getPublicChatUri } from '../uri/webchat'
|
||||
import { isDebugMode } from '../debug'
|
||||
|
||||
async function initRSS (options: RegisterServerOptions): Promise<void> {
|
||||
const logger = options.peertubeHelpers.logger
|
||||
@ -15,7 +16,7 @@ async function initRSS (options: RegisterServerOptions): Promise<void> {
|
||||
handler: async (
|
||||
result: CustomTag[], { video, liveItem }: { video: Video, liveItem: boolean }
|
||||
): Promise<CustomTag[]> => {
|
||||
if (!liveItem) {
|
||||
if (!liveItem && !isDebugMode(options, 'enablePodcastChatTagForNonLive')) {
|
||||
// Note: the Podcast RSS feed specification does not handle chats for non-live.
|
||||
// So we just return here.
|
||||
return result
|
||||
@ -67,7 +68,11 @@ async function initRSS (options: RegisterServerOptions): Promise<void> {
|
||||
// In order to connect to the chat using standard xmpp, it requires these settings:
|
||||
// - prosody-room-allow-s2s
|
||||
// - prosody-s2s-port
|
||||
if (settings['prosody-room-allow-s2s'] && settings['prosody-s2s-port']) {
|
||||
// Or there is a special debug_mode option
|
||||
if (
|
||||
(settings['prosody-room-allow-s2s'] && settings['prosody-s2s-port']) ||
|
||||
isDebugMode(options, 'alwaysPublishXMPPRoom')
|
||||
) {
|
||||
let roomJID: string
|
||||
if (settings['prosody-room-type'] === 'channel') {
|
||||
roomJID = `channel.${video.channel.id}@room.${prosodyDomain}`
|
||||
|
Loading…
x
Reference in New Issue
Block a user