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.
Fix #400.
This commit is contained in:
John Livingston 2024-06-11 10:41:12 +02:00
parent 6e35c243c8
commit ae2d45b007
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
2 changed files with 17 additions and 0 deletions

View File

@ -16,6 +16,7 @@ TODO: tag conversejs livechat branch, and replace commit ID in build-converse.js
* #416: Deregister prosodyctl interval callback when spawn.stdin disappears.
* #423: Merging video-watch scope into common scope.
* 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.
## 10.0.2

View File

@ -11,6 +11,22 @@ async function initCustomFields (options: RegisterServerOptions): Promise<void>
const storageManager = options.storageManager
const logger = options.peertubeHelpers.logger
registerHook({
target: 'action:api.live-video.created',
handler: async ({ video }: { video: Video | undefined }) => {
if (!video?.id) { return }
// When creating a new live, if the chat is an option 'per video', we enable the chat by default.
// 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
const setting = await options.settingsManager.getSetting('chat-per-live-video')
if (setting !== true) { return }
logger.info(
`New live created, enabling chat by default by setting livechat-active=true for video ${video.id.toString()}.`
)
await storageManager.storeData(`livechat-active-${video.id.toString()}`, true)
}
})
registerHook({
target: 'action:api.video.updated',
handler: async (params: any) => {