]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/activitypub.ts
Add originallyPublishedAt unit tests
[github/Chocobozzz/PeerTube.git] / server / helpers / activitypub.ts
index bcbd9be59d52bb07bb2d19b248698ec96c98e244..e850efe138eb53a4097e4a1a4cd742f6a1f60c57 100644 (file)
@@ -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 <T> (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',
@@ -29,10 +29,13 @@ function activityPubContextify <T> (data: T) {
         size: 'sc:Number',
         fps: '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: {
@@ -106,10 +109,10 @@ function buildSignedActivity (byActor: ActorModel, data: Object) {
   return signJsonLDObject(byActor, activity) as Promise<Activity>
 }
 
-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 +126,7 @@ function checkUrlsSameHost (url1: string, url2: string) {
 
 export {
   checkUrlsSameHost,
-  getActorUrl,
+  getAPId,
   activityPubContextify,
   activityPubCollectionPagination,
   buildSignedActivity