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