From c48e82b5e0478434de30626d14594a97f2402e7c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Sep 2018 16:27:07 +0200 Subject: Basic video redundancy implementation --- shared/models/activitypub/activity.ts | 6 +++--- .../activitypub/objects/cache-file-object.ts | 9 ++++++++ .../models/activitypub/objects/common-objects.ts | 25 +++++++++++++++++----- shared/models/activitypub/objects/index.ts | 1 + .../activitypub/objects/video-torrent-object.ts | 4 ++-- 5 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 shared/models/activitypub/objects/cache-file-object.ts (limited to 'shared/models/activitypub') diff --git a/shared/models/activitypub/activity.ts b/shared/models/activitypub/activity.ts index 46e883e5f..44cb99efb 100644 --- a/shared/models/activitypub/activity.ts +++ b/shared/models/activitypub/activity.ts @@ -1,6 +1,6 @@ import { ActivityPubActor } from './activitypub-actor' import { ActivityPubSignature } from './activitypub-signature' -import { VideoTorrentObject } from './objects' +import { CacheFileObject, VideoTorrentObject } from './objects' import { DislikeObject } from './objects/dislike-object' import { VideoAbuseObject } from './objects/video-abuse-object' import { VideoCommentObject } from './objects/video-comment-object' @@ -29,12 +29,12 @@ export interface BaseActivity { export interface ActivityCreate extends BaseActivity { type: 'Create' - object: VideoTorrentObject | VideoAbuseObject | ViewObject | DislikeObject | VideoCommentObject + object: VideoTorrentObject | VideoAbuseObject | ViewObject | DislikeObject | VideoCommentObject | CacheFileObject } export interface ActivityUpdate extends BaseActivity { type: 'Update' - object: VideoTorrentObject | ActivityPubActor + object: VideoTorrentObject | ActivityPubActor | CacheFileObject } export interface ActivityDelete extends BaseActivity { diff --git a/shared/models/activitypub/objects/cache-file-object.ts b/shared/models/activitypub/objects/cache-file-object.ts new file mode 100644 index 000000000..0a5125f5b --- /dev/null +++ b/shared/models/activitypub/objects/cache-file-object.ts @@ -0,0 +1,9 @@ +import { ActivityVideoUrlObject } from './common-objects' + +export interface CacheFileObject { + id: string + type: 'CacheFile', + object: string + expires: string + url: ActivityVideoUrlObject +} diff --git a/shared/models/activitypub/objects/common-objects.ts b/shared/models/activitypub/objects/common-objects.ts index ff2cfdbb4..1de60da94 100644 --- a/shared/models/activitypub/objects/common-objects.ts +++ b/shared/models/activitypub/objects/common-objects.ts @@ -17,16 +17,31 @@ export interface ActivityIconObject { height: number } -export interface ActivityUrlObject { +export type ActivityVideoUrlObject = { type: 'Link' - mimeType: 'video/mp4' | 'video/webm' | 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' + mimeType: 'video/mp4' | 'video/webm' | 'video/ogg' href: string height: number - - size?: number - fps?: number + size: number + fps: number } +export type ActivityUrlObject = + ActivityVideoUrlObject + | + { + type: 'Link' + mimeType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' + href: string + height: number + } + | + { + type: 'Link' + mimeType: 'text/html' + href: string + } + export interface ActivityPubAttributedTo { type: 'Group' | 'Person' id: string diff --git a/shared/models/activitypub/objects/index.ts b/shared/models/activitypub/objects/index.ts index 3efd3ef13..fba61e12f 100644 --- a/shared/models/activitypub/objects/index.ts +++ b/shared/models/activitypub/objects/index.ts @@ -1,3 +1,4 @@ +export * from './cache-file-object' export * from './common-objects' export * from './video-abuse-object' export * from './video-torrent-object' diff --git a/shared/models/activitypub/objects/video-torrent-object.ts b/shared/models/activitypub/objects/video-torrent-object.ts index 90de8967b..8504c178f 100644 --- a/shared/models/activitypub/objects/video-torrent-object.ts +++ b/shared/models/activitypub/objects/video-torrent-object.ts @@ -1,10 +1,10 @@ import { ActivityIconObject, - ActivityIdentifierObject, ActivityPubAttributedTo, + ActivityIdentifierObject, + ActivityPubAttributedTo, ActivityTagObject, ActivityUrlObject } from './common-objects' -import { ActivityPubOrderedCollection } from '../activitypub-ordered-collection' import { VideoState } from '../../videos' export interface VideoTorrentObject { -- cgit v1.2.3