-import * as url from 'url'
-
-import { database as db } from '../initializers'
-import { logger } from './logger'
-import { doRequest, doRequestAndSaveToFile } from './requests'
-import { isRemoteAccountValid } from './custom-validators'
-import { ActivityPubActor } from '../../shared/models/activitypub/activitypub-actor'
-import { ResultList } from '../../shared/models/result-list.model'
-import { CONFIG } from '../initializers/constants'
-import { VideoInstance } from '../models/video/video-interface'
-import { ActivityIconObject } from '../../shared/index'
-import { join } from 'path'
-
-function generateThumbnailFromUrl (video: VideoInstance, icon: ActivityIconObject) {
- const thumbnailName = video.getThumbnailName()
- const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, thumbnailName)
-
- const options = {
- method: 'GET',
- uri: icon.url
- }
- return doRequestAndSaveToFile(options, thumbnailPath)
-}
-
-function getActivityPubUrl (type: 'video' | 'videoChannel', uuid: string) {
- if (type === 'video') return CONFIG.WEBSERVER.URL + '/videos/watch/' + uuid
- else if (type === 'videoChannel') return CONFIG.WEBSERVER.URL + '/video-channels/' + uuid
-
- return ''
+import * as Bluebird from 'bluebird'
+import * as validator from 'validator'
+import { ResultList } from '../../shared/models'
+import { Activity, ActivityPubActor } from '../../shared/models/activitypub'
+import { ACTIVITY_PUB } from '../initializers'
+import { ActorModel } from '../models/activitypub/actor'
+import { signObject } from './peertube-crypto'
+import { pageToStartAndCount } from './core-utils'
+
+function activityPubContextify <T> (data: T) {
+ return Object.assign(data, {
+ '@context': [
+ 'https://www.w3.org/ns/activitystreams',
+ 'https://w3id.org/security/v1',
+ {
+ RsaSignature2017: 'https://w3id.org/security#RsaSignature2017',
+ Hashtag: 'as:Hashtag',
+ uuid: 'http://schema.org/identifier',
+ category: 'http://schema.org/category',
+ licence: 'http://schema.org/license',
+ subtitleLanguage: 'http://schema.org/subtitleLanguage',
+ sensitive: 'as:sensitive',
+ language: 'http://schema.org/inLanguage',
+ views: 'http://schema.org/Number',
+ stats: 'http://schema.org/Number',
+ size: 'http://schema.org/Number',
+ commentsEnabled: 'http://schema.org/Boolean',
+ waitTranscoding: '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'
+ }
+ }
+ ]
+ })