import * as Bluebird from 'bluebird'
+import { URL } from 'url'
import validator from 'validator'
+import { ContextType } from '@shared/models/activitypub/context'
import { ResultList } from '../../shared/models'
-import { Activity } from '../../shared/models/activitypub'
import { ACTIVITY_PUB, REMOTE_SCHEME } from '../initializers/constants'
-import { signJsonLDObject } from './peertube-crypto'
+import { MActor, MVideoWithHost } from '../types/models'
import { pageToStartAndCount } from './core-utils'
-import { URL } from 'url'
-import { MActor, MVideoAccountLight } from '../typings/models'
-import { ContextType } from '@shared/models/activitypub/context'
+import { signJsonLDObject } from './peertube-crypto'
function getContextData (type: ContextType) {
const context: any[] = [
sensitive: 'as:sensitive',
language: 'sc:inLanguage',
+ isLiveBroadcast: 'sc:isLiveBroadcast',
+ liveSaveReplay: {
+ '@type': 'sc:Boolean',
+ '@id': 'pt:liveSaveReplay'
+ },
+ permanentLive: {
+ '@type': 'sc:Boolean',
+ '@id': 'pt:permanentLive'
+ },
+
Infohash: 'pt:Infohash',
+ Playlist: 'pt:Playlist',
+ PlaylistElement: 'pt:PlaylistElement',
+
originallyPublishedAt: 'sc:datePublished',
views: {
'@type': 'sc:Number',
}
-function buildSignedActivity (byActor: MActor, data: Object, contextType?: ContextType) {
+function buildSignedActivity <T> (byActor: MActor, data: T, contextType?: ContextType) {
const activity = activityPubContextify(data, contextType)
- return signJsonLDObject(byActor, activity) as Promise<Activity>
+ return signJsonLDObject(byActor, activity)
}
function getAPId (activity: string | { id: string }) {
return idHost && actorHost && idHost.toLowerCase() === actorHost.toLowerCase()
}
-function buildRemoteVideoBaseUrl (video: MVideoAccountLight, path: string) {
- const host = video.VideoChannel.Account.Actor.Server.host
+function buildRemoteVideoBaseUrl (video: MVideoWithHost, path: string, scheme?: string) {
+ if (!scheme) scheme = REMOTE_SCHEME.HTTP
+
+ const host = video.VideoChannel.Actor.Server.host
- return REMOTE_SCHEME.HTTP + '://' + host + path
+ return scheme + '://' + host + path
}
// ---------------------------------------------------------------------------