1 import { ContextType } from '@shared/models'
3 function getContextData (type: ContextType) {
4 const context: any[] = [
5 'https://www.w3.org/ns/activitystreams',
6 'https://w3id.org/security/v1',
8 RsaSignature2017: 'https://w3id.org/security#RsaSignature2017'
12 if (type !== 'View' && type !== 'Announce') {
14 pt: 'https://joinpeertube.org/ns#',
15 sc: 'http://schema.org#'
18 if (type === 'CacheFile') {
19 Object.assign(additional, {
20 expires: 'sc:expires',
21 CacheFile: 'pt:CacheFile'
24 Object.assign(additional, {
25 Hashtag: 'as:Hashtag',
26 uuid: 'sc:identifier',
27 category: 'sc:category',
28 licence: 'sc:license',
29 subtitleLanguage: 'sc:subtitleLanguage',
30 sensitive: 'as:sensitive',
31 language: 'sc:inLanguage',
33 // TODO: remove in a few versions, introduced in 4.2
36 isLiveBroadcast: 'sc:isLiveBroadcast',
38 '@type': 'sc:Boolean',
39 '@id': 'pt:liveSaveReplay'
42 '@type': 'sc:Boolean',
43 '@id': 'pt:permanentLive'
47 '@id': 'pt:latencyMode'
50 Infohash: 'pt:Infohash',
51 Playlist: 'pt:Playlist',
52 PlaylistElement: 'pt:PlaylistElement',
54 originallyPublishedAt: 'sc:datePublished',
73 '@id': 'pt:startTimestamp'
77 '@id': 'pt:stopTimestamp'
84 '@type': 'sc:Boolean',
85 '@id': 'pt:commentsEnabled'
88 '@type': 'sc:Boolean',
89 '@id': 'pt:downloadEnabled'
92 '@type': 'sc:Boolean',
93 '@id': 'pt:waitTranscoding'
104 '@id': 'as:dislikes',
108 '@id': 'pt:playlists',
116 '@id': 'as:comments',
122 context.push(additional)
130 function activityPubContextify <T> (data: T, type: ContextType = 'All') {
131 return Object.assign({}, data, getContextData(type))
136 activityPubContextify