]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/activitypub.ts
Fix account link in the menu
[github/Chocobozzz/PeerTube.git] / server / helpers / activitypub.ts
index 97115680cd129383ed27eaf6cc6a934863a2add3..1934fa0f024b600e491948bf428736315532ca84 100644 (file)
@@ -1,5 +1,5 @@
 import { ResultList } from '../../shared/models'
-import { Activity } from '../../shared/models/activitypub'
+import { Activity, ActivityPubActor } from '../../shared/models/activitypub'
 import { ACTIVITY_PUB } from '../initializers'
 import { ActorModel } from '../models/activitypub/actor'
 import { signObject } from './peertube-crypto'
@@ -19,14 +19,34 @@ function activityPubContextify <T> (data: T) {
         'language': 'http://schema.org/inLanguage',
         'views': 'http://schema.org/Number',
         'size': 'http://schema.org/Number',
-        'commentsEnabled': 'http://schema.org/Boolean'
+        'commentsEnabled': 'http://schema.org/Boolean',
+        'support': 'http://schema.org/Text'
+      },
+      {
+        likes: {
+          '@id': 'as:likes',
+          '@type': '@id'
+        },
+        dislikes: {
+          '@id': 'as:dislikes',
+          '@type': '@id'
+        },
+        shares: {
+          '@id': 'as:shares',
+          '@type': '@id'
+        },
+        comments: {
+          '@id': 'as:comments',
+          '@type': '@id'
+        }
       }
     ]
   })
 }
 
-function activityPubCollection (results: any[]) {
+function activityPubCollection (url: string, results: any[]) {
   return {
+    id: url,
     type: 'OrderedCollection',
     totalItems: results.length,
     orderedItems: results
@@ -78,9 +98,16 @@ function buildSignedActivity (byActor: ActorModel, data: Object) {
   return signObject(byActor, activity) as Promise<Activity>
 }
 
+function getActorUrl (activityActor: string | ActivityPubActor) {
+  if (typeof activityActor === 'string') return activityActor
+
+  return activityActor.id
+}
+
 // ---------------------------------------------------------------------------
 
 export {
+  getActorUrl,
   activityPubContextify,
   activityPubCollectionPagination,
   activityPubCollection,