From e4f97babf701481b55cc10fb3448feab5f97c867 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 9 Nov 2017 17:51:58 +0100 Subject: Begin activitypub --- shared/models/activitypub/activity.ts | 34 ++++++++++++++++++++++ shared/models/activitypub/activitypub-actor.ts | 27 +++++++++++++++++ .../models/activitypub/activitypub-collection.ts | 9 ++++++ .../activitypub/activitypub-ordered-collection.ts | 9 ++++++ shared/models/activitypub/activitypub-root.ts | 5 ++++ shared/models/activitypub/activitypub-signature.ts | 6 ++++ shared/models/activitypub/index.ts | 8 +++++ .../models/activitypub/objects/common-objects.ts | 25 ++++++++++++++++ shared/models/activitypub/objects/index.ts | 3 ++ .../activitypub/objects/video-channel-object.ts | 8 +++++ .../activitypub/objects/video-torrent-object.ts | 25 ++++++++++++++++ shared/models/activitypub/webfinger.ts | 9 ++++++ shared/models/index.ts | 1 + shared/models/job.model.ts | 1 + shared/models/videos/video.model.ts | 2 +- 15 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 shared/models/activitypub/activity.ts create mode 100644 shared/models/activitypub/activitypub-actor.ts create mode 100644 shared/models/activitypub/activitypub-collection.ts create mode 100644 shared/models/activitypub/activitypub-ordered-collection.ts create mode 100644 shared/models/activitypub/activitypub-root.ts create mode 100644 shared/models/activitypub/activitypub-signature.ts create mode 100644 shared/models/activitypub/index.ts create mode 100644 shared/models/activitypub/objects/common-objects.ts create mode 100644 shared/models/activitypub/objects/index.ts create mode 100644 shared/models/activitypub/objects/video-channel-object.ts create mode 100644 shared/models/activitypub/objects/video-torrent-object.ts create mode 100644 shared/models/activitypub/webfinger.ts (limited to 'shared') diff --git a/shared/models/activitypub/activity.ts b/shared/models/activitypub/activity.ts new file mode 100644 index 000000000..0274416b2 --- /dev/null +++ b/shared/models/activitypub/activity.ts @@ -0,0 +1,34 @@ +import { + VideoChannelObject, + VideoTorrentObject +} from './objects' +import { ActivityPubSignature } from './activitypub-signature' + +export type Activity = ActivityCreate | ActivityUpdate | ActivityFlag + +// Flag -> report abuse +export type ActivityType = 'Create' | 'Update' | 'Flag' + +export interface BaseActivity { + '@context'?: any[] + id: string + to: string[] + actor: string + type: ActivityType + signature: ActivityPubSignature +} + +export interface ActivityCreate extends BaseActivity { + type: 'Create' + object: VideoTorrentObject | VideoChannelObject +} + +export interface ActivityUpdate extends BaseActivity { + type: 'Update' + object: VideoTorrentObject | VideoChannelObject +} + +export interface ActivityFlag extends BaseActivity { + type: 'Flag' + object: string +} diff --git a/shared/models/activitypub/activitypub-actor.ts b/shared/models/activitypub/activitypub-actor.ts new file mode 100644 index 000000000..77489135c --- /dev/null +++ b/shared/models/activitypub/activitypub-actor.ts @@ -0,0 +1,27 @@ +export interface ActivityPubActor { + '@context': any[] + type: 'Person' | 'Application' + id: string + following: string + followers: string + inbox: string + outbox: string + preferredUsername: string + url: string + name: string + endpoints: { + sharedInbox: string + } + + uuid: string + publicKey: { + id: string + owner: string + publicKeyPem: string + } + + // Not used + // summary: string + // icon: string[] + // liked: string +} diff --git a/shared/models/activitypub/activitypub-collection.ts b/shared/models/activitypub/activitypub-collection.ts new file mode 100644 index 000000000..60a6a6b04 --- /dev/null +++ b/shared/models/activitypub/activitypub-collection.ts @@ -0,0 +1,9 @@ +import { Activity } from './activity' + +export interface ActivityPubCollection { + '@context': string[] + type: 'Collection' | 'CollectionPage' + totalItems: number + partOf?: string + items: Activity[] +} diff --git a/shared/models/activitypub/activitypub-ordered-collection.ts b/shared/models/activitypub/activitypub-ordered-collection.ts new file mode 100644 index 000000000..4080fd740 --- /dev/null +++ b/shared/models/activitypub/activitypub-ordered-collection.ts @@ -0,0 +1,9 @@ +import { Activity } from './activity' + +export interface ActivityPubOrderedCollection { + '@context': string[] + type: 'OrderedCollection' | 'OrderedCollectionPage' + totalItems: number + partOf?: string + orderedItems: Activity[] +} diff --git a/shared/models/activitypub/activitypub-root.ts b/shared/models/activitypub/activitypub-root.ts new file mode 100644 index 000000000..6a67f3101 --- /dev/null +++ b/shared/models/activitypub/activitypub-root.ts @@ -0,0 +1,5 @@ +import { Activity } from './activity' +import { ActivityPubCollection } from './activitypub-collection' +import { ActivityPubOrderedCollection } from './activitypub-ordered-collection' + +export type RootActivity = Activity | ActivityPubCollection | ActivityPubOrderedCollection diff --git a/shared/models/activitypub/activitypub-signature.ts b/shared/models/activitypub/activitypub-signature.ts new file mode 100644 index 000000000..1d9f4b3b3 --- /dev/null +++ b/shared/models/activitypub/activitypub-signature.ts @@ -0,0 +1,6 @@ +export interface ActivityPubSignature { + type: 'GraphSignature2012' + created: Date, + creator: string + signatureValue: string +} diff --git a/shared/models/activitypub/index.ts b/shared/models/activitypub/index.ts new file mode 100644 index 000000000..6cacb24d2 --- /dev/null +++ b/shared/models/activitypub/index.ts @@ -0,0 +1,8 @@ +export * from './activity' +export * from './activitypub-actor' +export * from './activitypub-collection' +export * from './activitypub-ordered-collection' +export * from './activitypub-root' +export * from './activitypub-signature' +export * from './objects' +export * from './webfinger' diff --git a/shared/models/activitypub/objects/common-objects.ts b/shared/models/activitypub/objects/common-objects.ts new file mode 100644 index 000000000..3eaab21b5 --- /dev/null +++ b/shared/models/activitypub/objects/common-objects.ts @@ -0,0 +1,25 @@ +export interface ActivityIdentifierObject { + identifier: string + name: string +} + +export interface ActivityTagObject { + type: 'Hashtag' + name: string +} + +export interface ActivityIconObject { + type: 'Image' + url: string + mediaType: 'image/jpeg' + width: number + height: number +} + +export interface ActivityUrlObject { + type: 'Link' + mimeType: 'video/mp4' | 'video/webm' | 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' + url: string + width: number + size?: number +} diff --git a/shared/models/activitypub/objects/index.ts b/shared/models/activitypub/objects/index.ts new file mode 100644 index 000000000..8c2e2daca --- /dev/null +++ b/shared/models/activitypub/objects/index.ts @@ -0,0 +1,3 @@ +export * from './common-objects' +export * from './video-channel-object' +export * from './video-torrent-object' diff --git a/shared/models/activitypub/objects/video-channel-object.ts b/shared/models/activitypub/objects/video-channel-object.ts new file mode 100644 index 000000000..d64b4aed8 --- /dev/null +++ b/shared/models/activitypub/objects/video-channel-object.ts @@ -0,0 +1,8 @@ +import { ActivityIdentifierObject } from './common-objects' + +export interface VideoChannelObject { + type: 'VideoChannel' + name: string + content: string + uuid: ActivityIdentifierObject +} diff --git a/shared/models/activitypub/objects/video-torrent-object.ts b/shared/models/activitypub/objects/video-torrent-object.ts new file mode 100644 index 000000000..00cc0a649 --- /dev/null +++ b/shared/models/activitypub/objects/video-torrent-object.ts @@ -0,0 +1,25 @@ +import { + ActivityIconObject, + ActivityIdentifierObject, + ActivityTagObject, + ActivityUrlObject +} from './common-objects' + +export interface VideoTorrentObject { + type: 'Video' + name: string + duration: string + uuid: string + tag: ActivityTagObject[] + category: ActivityIdentifierObject + licence: ActivityIdentifierObject + language: ActivityIdentifierObject + views: number + nsfw: boolean + published: Date + updated: Date + mediaType: 'text/markdown' + content: string + icon: ActivityIconObject + url: ActivityUrlObject[] +} diff --git a/shared/models/activitypub/webfinger.ts b/shared/models/activitypub/webfinger.ts new file mode 100644 index 000000000..b94baf996 --- /dev/null +++ b/shared/models/activitypub/webfinger.ts @@ -0,0 +1,9 @@ +export interface WebFingerData { + subject: string + aliases: string[] + links: { + rel: 'self' + type: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' + href: string + }[] +} diff --git a/shared/models/index.ts b/shared/models/index.ts index 02665a3e6..0ccb84d24 100644 --- a/shared/models/index.ts +++ b/shared/models/index.ts @@ -1,3 +1,4 @@ +export * from './activitypub' export * from './pods' export * from './users' export * from './videos' diff --git a/shared/models/job.model.ts b/shared/models/job.model.ts index 411c91482..ab723084a 100644 --- a/shared/models/job.model.ts +++ b/shared/models/job.model.ts @@ -1 +1,2 @@ export type JobState = 'pending' | 'processing' | 'error' | 'success' +export type JobCategory = 'transcoding' | 'http-request' diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 2f4ee2462..0606f1aec 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts @@ -13,7 +13,7 @@ export interface VideoFile { export interface Video { id: number uuid: string - author: string + account: string createdAt: Date | string updatedAt: Date | string categoryLabel: string -- cgit v1.2.3