6ed69d2c2f
The data format used by plugin v6.3.0 was not well suited. Here comes a new data format, with S2S informations. The plugin can automatically upgrade old format. It also continues to provide the old format, so than remote instance that did not update the plugin will still work.
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
|
import type { RemoteVideoHandlerParams } from './types'
|
|
import { storeVideoLiveChatInfos, storeRemoteServerInfos } from './storage'
|
|
import { sanitizePeertubeLiveChatInfos } from './sanitize'
|
|
|
|
/**
|
|
* This function reads incoming ActivityPub data, to detect LiveChat informations.
|
|
* @param options server options
|
|
* @param param1 handler parameters
|
|
* @returns void
|
|
*/
|
|
async function readIncomingAPVideo (
|
|
options: RegisterServerOptions,
|
|
{ video, videoAPObject }: RemoteVideoHandlerParams
|
|
): Promise<void> {
|
|
let peertubeLiveChat = ('peertubeLiveChat' in videoAPObject) ? videoAPObject.peertubeLiveChat : false
|
|
|
|
// We must sanitize peertubeLiveChat, as it comes for the outer world.
|
|
peertubeLiveChat = sanitizePeertubeLiveChatInfos(options, peertubeLiveChat)
|
|
|
|
await storeVideoLiveChatInfos(options, video, peertubeLiveChat)
|
|
if (video.remote) {
|
|
await storeRemoteServerInfos(options, peertubeLiveChat)
|
|
}
|
|
}
|
|
|
|
export {
|
|
readIncomingAPVideo
|
|
}
|