Reading livechat-active parameter on live creation API endpoint:
So that the Android Peertube Live app can pass the parameter withing the first (and only) API call. Implements #400.
This commit is contained in:
parent
ae2d45b007
commit
9e8e2a2572
@ -16,7 +16,7 @@ TODO: tag conversejs livechat branch, and replace commit ID in build-converse.js
|
|||||||
* #416: Deregister prosodyctl interval callback when spawn.stdin disappears.
|
* #416: Deregister prosodyctl interval callback when spawn.stdin disappears.
|
||||||
* #423: Merging video-watch scope into common scope.
|
* #423: Merging video-watch scope into common scope.
|
||||||
* Rewriting the share chat dialog with more modern code.
|
* Rewriting the share chat dialog with more modern code.
|
||||||
* #400: Enable the chat by default when a live is created. So that lives created by the Android Peertube Live app will have chat by default.
|
* #400: Reading livechat-active parameter on live creation API endpoint. So that the Android Peertube Live app can pass the parameter withing the first (and only) API call.
|
||||||
|
|
||||||
## 10.0.2
|
## 10.0.2
|
||||||
|
|
||||||
|
@ -13,15 +13,26 @@ async function initCustomFields (options: RegisterServerOptions): Promise<void>
|
|||||||
|
|
||||||
registerHook({
|
registerHook({
|
||||||
target: 'action:api.live-video.created',
|
target: 'action:api.live-video.created',
|
||||||
handler: async ({ video }: { video: Video | undefined }) => {
|
handler: async ({ video, req }: { video: Video | undefined, req: any }) => {
|
||||||
if (!video?.id) { return }
|
if (!video?.id) { return }
|
||||||
// When creating a new live, if the chat is an option 'per video', we enable the chat by default.
|
// When creating a new live, if 'chat-per-live-video' is true,
|
||||||
|
// we must read req.body.pluginData['livechat-active'] (as for action:api.video.updated).
|
||||||
// This is done for the Peertube live Android app, which does not update the video after creation.
|
// This is done for the Peertube live Android app, which does not update the video after creation.
|
||||||
// See: https://github.com/JohnXLivingston/peertube-plugin-livechat/issues/400
|
// See: https://github.com/JohnXLivingston/peertube-plugin-livechat/issues/400
|
||||||
|
|
||||||
|
// Note: following code is a little bit verbose, to be sure it can't fail, even with old Peertube versions.
|
||||||
|
if (!req || (typeof req !== 'object') || !('body' in req)) { return }
|
||||||
|
if (!req.body || (typeof req.body !== 'object') || !('pluginData' in req.body)) { return }
|
||||||
|
const pluginData = req.body?.pluginData
|
||||||
|
if (!pluginData || (typeof pluginData !== 'object') || !('livechat-active' in pluginData)) { return }
|
||||||
|
if (pluginData['livechat-active'] !== true) { return }
|
||||||
|
|
||||||
const setting = await options.settingsManager.getSetting('chat-per-live-video')
|
const setting = await options.settingsManager.getSetting('chat-per-live-video')
|
||||||
if (setting !== true) { return }
|
if (setting !== true) { return }
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
`New live created, enabling chat by default by setting livechat-active=true for video ${video.id.toString()}.`
|
'New live created, livechat-active parameter given, ' +
|
||||||
|
`enabling chat by default by setting livechat-active=true for video ${video.id.toString()}.`
|
||||||
)
|
)
|
||||||
await storageManager.storeData(`livechat-active-${video.id.toString()}`, true)
|
await storageManager.storeData(`livechat-active-${video.id.toString()}`, true)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user