X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Factivitypub.ts;h=31c6187d108d9ea60fbc4e2607f51fffc54a557f;hb=7ccddd7b5250bd25a917a6e77e58b87b9484a2a4;hp=bcbd9be59d52bb07bb2d19b248698ec96c98e244;hpb=babecc3c09cd4ed06fe643a97fff4bcc31c5a9be;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index bcbd9be59..31c6187d1 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts @@ -1,7 +1,7 @@ import * as Bluebird from 'bluebird' import * as validator from 'validator' import { ResultList } from '../../shared/models' -import { Activity, ActivityPubActor } from '../../shared/models/activitypub' +import { Activity } from '../../shared/models/activitypub' import { ACTIVITY_PUB } from '../initializers' import { ActorModel } from '../models/activitypub/actor' import { signJsonLDObject } from './peertube-crypto' @@ -15,7 +15,7 @@ function activityPubContextify (data: T) { 'https://w3id.org/security/v1', { RsaSignature2017: 'https://w3id.org/security#RsaSignature2017', - pt: 'https://joinpeertube.org/ns', + pt: 'https://joinpeertube.org/ns#', sc: 'http://schema.org#', Hashtag: 'as:Hashtag', uuid: 'sc:identifier', @@ -28,11 +28,17 @@ function activityPubContextify (data: T) { state: 'sc:Number', size: 'sc:Number', fps: 'sc:Number', + startTimestamp: 'sc:Number', + stopTimestamp: 'sc:Number', + position: 'sc:Number', commentsEnabled: 'sc:Boolean', + downloadEnabled: 'sc:Boolean', waitTranscoding: 'sc:Boolean', expires: 'sc:expires', support: 'sc:Text', - CacheFile: 'pt:CacheFile' + CacheFile: 'pt:CacheFile', + Infohash: 'pt:Infohash', + originallyPublishedAt: 'sc:DateTime' }, { likes: { @@ -43,6 +49,10 @@ function activityPubContextify (data: T) { '@id': 'as:dislikes', '@type': '@id' }, + playlists: { + '@id': 'pt:playlists', + '@type': '@id' + }, shares: { '@id': 'as:shares', '@type': '@id' @@ -64,7 +74,7 @@ async function activityPubCollectionPagination (baseUrl: string, handler: Activi return { id: baseUrl, - type: 'OrderedCollection', + type: 'OrderedCollectionPage', totalItems: result.total, first: baseUrl + '?page=1' } @@ -106,10 +116,10 @@ function buildSignedActivity (byActor: ActorModel, data: Object) { return signJsonLDObject(byActor, activity) as Promise } -function getActorUrl (activityActor: string | ActivityPubActor) { - if (typeof activityActor === 'string') return activityActor +function getAPId (activity: string | { id: string }) { + if (typeof activity === 'string') return activity - return activityActor.id + return activity.id } function checkUrlsSameHost (url1: string, url2: string) { @@ -123,7 +133,7 @@ function checkUrlsSameHost (url1: string, url2: string) { export { checkUrlsSameHost, - getActorUrl, + getAPId, activityPubContextify, activityPubCollectionPagination, buildSignedActivity