From 156c50af3085468a47b8ae73fe8cfcae46b42398 Mon Sep 17 00:00:00 2001 From: Lucas Declercq Date: Sat, 6 Oct 2018 19:17:21 +0200 Subject: Add downloadingEnabled property to video model --- shared/models/activitypub/objects/video-torrent-object.ts | 3 ++- shared/models/videos/video-create.model.ts | 1 + shared/models/videos/video-update.model.ts | 1 + shared/models/videos/video.model.ts | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) (limited to 'shared') diff --git a/shared/models/activitypub/objects/video-torrent-object.ts b/shared/models/activitypub/objects/video-torrent-object.ts index 8504c178f..beb2f519e 100644 --- a/shared/models/activitypub/objects/video-torrent-object.ts +++ b/shared/models/activitypub/objects/video-torrent-object.ts @@ -20,7 +20,8 @@ export interface VideoTorrentObject { subtitleLanguage: ActivityIdentifierObject[] views: number sensitive: boolean - commentsEnabled: boolean + commentsEnabled: boolean, + downloadingEnabled: boolean, waitTranscoding: boolean state: VideoState published: string diff --git a/shared/models/videos/video-create.model.ts b/shared/models/videos/video-create.model.ts index 190d63783..6e5e03e0a 100644 --- a/shared/models/videos/video-create.model.ts +++ b/shared/models/videos/video-create.model.ts @@ -13,6 +13,7 @@ export interface VideoCreate { name: string tags?: string[] commentsEnabled?: boolean + downloadingEnabled?: boolean privacy: VideoPrivacy scheduleUpdate?: VideoScheduleUpdate } diff --git a/shared/models/videos/video-update.model.ts b/shared/models/videos/video-update.model.ts index ed141a824..bf7a9af37 100644 --- a/shared/models/videos/video-update.model.ts +++ b/shared/models/videos/video-update.model.ts @@ -11,6 +11,7 @@ export interface VideoUpdate { privacy?: VideoPrivacy tags?: string[] commentsEnabled?: boolean + downloadingEnabled?: boolean nsfw?: boolean waitTranscoding?: boolean channelId?: number diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 4a9fa58b1..783cd86e5 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts @@ -82,6 +82,7 @@ export interface VideoDetails extends Video { files: VideoFile[] account: Account commentsEnabled: boolean + downloadingEnabled: boolean // Not optional in details (unlike in Video) waitTranscoding: boolean -- cgit v1.2.3 From 7f2cfe3a792856f7de6f1d13688aa3d06ec1bf70 Mon Sep 17 00:00:00 2001 From: Lucas Declercq Date: Mon, 8 Oct 2018 14:45:22 +0200 Subject: Rename downloadingEnabled property to downloadEnabled --- shared/models/activitypub/objects/video-torrent-object.ts | 2 +- shared/models/videos/video-create.model.ts | 2 +- shared/models/videos/video-update.model.ts | 2 +- shared/models/videos/video.model.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'shared') diff --git a/shared/models/activitypub/objects/video-torrent-object.ts b/shared/models/activitypub/objects/video-torrent-object.ts index beb2f519e..4231fbb68 100644 --- a/shared/models/activitypub/objects/video-torrent-object.ts +++ b/shared/models/activitypub/objects/video-torrent-object.ts @@ -21,7 +21,7 @@ export interface VideoTorrentObject { views: number sensitive: boolean commentsEnabled: boolean, - downloadingEnabled: boolean, + downloadEnabled: boolean, waitTranscoding: boolean state: VideoState published: string diff --git a/shared/models/videos/video-create.model.ts b/shared/models/videos/video-create.model.ts index 6e5e03e0a..f153a1d00 100644 --- a/shared/models/videos/video-create.model.ts +++ b/shared/models/videos/video-create.model.ts @@ -13,7 +13,7 @@ export interface VideoCreate { name: string tags?: string[] commentsEnabled?: boolean - downloadingEnabled?: boolean + downloadEnabled?: boolean privacy: VideoPrivacy scheduleUpdate?: VideoScheduleUpdate } diff --git a/shared/models/videos/video-update.model.ts b/shared/models/videos/video-update.model.ts index bf7a9af37..6f96633ae 100644 --- a/shared/models/videos/video-update.model.ts +++ b/shared/models/videos/video-update.model.ts @@ -11,7 +11,7 @@ export interface VideoUpdate { privacy?: VideoPrivacy tags?: string[] commentsEnabled?: boolean - downloadingEnabled?: boolean + downloadEnabled?: boolean nsfw?: boolean waitTranscoding?: boolean channelId?: number diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 783cd86e5..4a792fcbc 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts @@ -82,7 +82,7 @@ export interface VideoDetails extends Video { files: VideoFile[] account: Account commentsEnabled: boolean - downloadingEnabled: boolean + downloadEnabled: boolean // Not optional in details (unlike in Video) waitTranscoding: boolean -- cgit v1.2.3 From 5abb9fbbd12e7097e348d6a38622d364b1fa47ed Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 10 Jan 2019 15:39:51 +0100 Subject: Add ability to unfederate a local video (on blacklist) --- .../models/videos/blacklist/video-blacklist-create.model.ts | 1 + shared/models/videos/blacklist/video-blacklist.model.ts | 1 + shared/utils/server/servers.ts | 4 ++++ shared/utils/videos/video-blacklist.ts | 11 +++++++++-- 4 files changed, 15 insertions(+), 2 deletions(-) (limited to 'shared') diff --git a/shared/models/videos/blacklist/video-blacklist-create.model.ts b/shared/models/videos/blacklist/video-blacklist-create.model.ts index 89c69cb56..6e7d36421 100644 --- a/shared/models/videos/blacklist/video-blacklist-create.model.ts +++ b/shared/models/videos/blacklist/video-blacklist-create.model.ts @@ -1,3 +1,4 @@ export interface VideoBlacklistCreate { reason?: string + unfederate?: boolean } diff --git a/shared/models/videos/blacklist/video-blacklist.model.ts b/shared/models/videos/blacklist/video-blacklist.model.ts index ef4e5e3a2..4bd976190 100644 --- a/shared/models/videos/blacklist/video-blacklist.model.ts +++ b/shared/models/videos/blacklist/video-blacklist.model.ts @@ -2,6 +2,7 @@ export interface VideoBlacklist { id: number createdAt: Date updatedAt: Date + unfederated: boolean reason?: string video: { diff --git a/shared/utils/server/servers.ts b/shared/utils/server/servers.ts index 568385a41..1e9c83c72 100644 --- a/shared/utils/server/servers.ts +++ b/shared/utils/server/servers.ts @@ -145,8 +145,12 @@ function runServer (serverNumber: number, configOverride?: Object, args = []) { if (dontContinue === true) return server.app.stdout.removeListener('data', onStdout) + + process.on('exit', () => process.kill(server.app.pid)) + res(server) }) + }) } diff --git a/shared/utils/videos/video-blacklist.ts b/shared/utils/videos/video-blacklist.ts index 2c176fde0..f2ae0ed26 100644 --- a/shared/utils/videos/video-blacklist.ts +++ b/shared/utils/videos/video-blacklist.ts @@ -1,11 +1,18 @@ import * as request from 'supertest' -function addVideoToBlacklist (url: string, token: string, videoId: number | string, reason?: string, specialStatus = 204) { +function addVideoToBlacklist ( + url: string, + token: string, + videoId: number | string, + reason?: string, + unfederate?: boolean, + specialStatus = 204 +) { const path = '/api/v1/videos/' + videoId + '/blacklist' return request(url) .post(path) - .send({ reason }) + .send({ reason, unfederate }) .set('Accept', 'application/json') .set('Authorization', 'Bearer ' + token) .expect(specialStatus) -- cgit v1.2.3 From 9b4b15f91c485f9a7fe2ed314b4101f4b7506b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20B=C3=A9ranger?= <43744761+auberanger@users.noreply.github.com> Date: Mon, 14 Jan 2019 09:06:48 +0100 Subject: WIP : Indicate to users how "trending" works (#1458) * Get the INTERVAL_DAYS const in the video-trending component * Change Trending section title * Add a tooltip to explain how trending section works * Minor CSS fix for the my-feed popover next to the titlepage --- shared/models/server/server-config.model.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'shared') diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts index 7031009d9..f4245ed4d 100644 --- a/shared/models/server/server-config.model.ts +++ b/shared/models/server/server-config.model.ts @@ -78,4 +78,10 @@ export interface ServerConfig { videoQuota: number videoQuotaDaily: number } + + trending: { + videos: { + intervalDays: number + } + } } -- cgit v1.2.3 From 44b9c0ba31c4a97e3d874f33226ad935c3a90dd5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 15 Jan 2019 09:45:54 +0100 Subject: Add totalLocalVideoFilesSize in stats --- shared/models/server/server-stats.model.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'shared') diff --git a/shared/models/server/server-stats.model.ts b/shared/models/server/server-stats.model.ts index a6bd2d4d3..74f3de5d3 100644 --- a/shared/models/server/server-stats.model.ts +++ b/shared/models/server/server-stats.model.ts @@ -5,6 +5,7 @@ export interface ServerStats { totalLocalVideos: number totalLocalVideoViews: number totalLocalVideoComments: number + totalLocalVideoFilesSize: number totalVideos: number totalVideoComments: number -- cgit v1.2.3 From 848f499def54db2dd36437ef0dfb74dd5041c23b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 15 Jan 2019 11:14:12 +0100 Subject: Prepare Dislike/Flag/View fixes For now we Create these activities, but we should just send them directly. This fix handles correctly direct Dislikes/Flags/Views, we'll implement the sending correctly these activities in the next peertube version --- shared/models/activitypub/activity.ts | 31 +++++++++++++++++++---- shared/models/activitypub/objects/object.model.ts | 1 + 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 shared/models/activitypub/objects/object.model.ts (limited to 'shared') diff --git a/shared/models/activitypub/activity.ts b/shared/models/activitypub/activity.ts index 44cb99efb..89994f665 100644 --- a/shared/models/activitypub/activity.ts +++ b/shared/models/activitypub/activity.ts @@ -5,12 +5,14 @@ import { DislikeObject } from './objects/dislike-object' import { VideoAbuseObject } from './objects/video-abuse-object' import { VideoCommentObject } from './objects/video-comment-object' import { ViewObject } from './objects/view-object' +import { APObject } from './objects/object.model' export type Activity = ActivityCreate | ActivityUpdate | ActivityDelete | ActivityFollow | ActivityAccept | ActivityAnnounce | - ActivityUndo | ActivityLike | ActivityReject + ActivityUndo | ActivityLike | ActivityReject | ActivityView | ActivityDislike | ActivityFlag -export type ActivityType = 'Create' | 'Update' | 'Delete' | 'Follow' | 'Accept' | 'Announce' | 'Undo' | 'Like' | 'Reject' +export type ActivityType = 'Create' | 'Update' | 'Delete' | 'Follow' | 'Accept' | 'Announce' | 'Undo' | 'Like' | 'Reject' | + 'View' | 'Dislike' | 'Flag' export interface ActivityAudience { to: string[] @@ -59,15 +61,34 @@ export interface ActivityReject extends BaseActivity { export interface ActivityAnnounce extends BaseActivity { type: 'Announce' - object: string | { id: string } + object: APObject } export interface ActivityUndo extends BaseActivity { type: 'Undo', - object: ActivityFollow | ActivityLike | ActivityCreate | ActivityAnnounce + object: ActivityFollow | ActivityLike | ActivityDislike | ActivityCreate | ActivityAnnounce } export interface ActivityLike extends BaseActivity { type: 'Like', - object: string + object: APObject +} + +export interface ActivityView extends BaseActivity { + type: 'View', + actor: string + object: APObject +} + +export interface ActivityDislike extends BaseActivity { + id: string + type: 'Dislike' + actor: string + object: APObject +} + +export interface ActivityFlag extends BaseActivity { + type: 'Flag', + content: string, + object: APObject } diff --git a/shared/models/activitypub/objects/object.model.ts b/shared/models/activitypub/objects/object.model.ts new file mode 100644 index 000000000..3fd33800a --- /dev/null +++ b/shared/models/activitypub/objects/object.model.ts @@ -0,0 +1 @@ +export type APObject = string | { id: string } -- cgit v1.2.3 From 457bb213b273a9b206cc5654eb085cede4e916ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 16 Jan 2019 16:05:40 +0100 Subject: Refactor how we use icons Inject them in an angular component so we can easily change their color --- shared/models/actors/actor.model.ts | 2 +- shared/models/users/user-notification.model.ts | 30 +++++++++++--------------- shared/models/videos/video.model.ts | 4 ++-- 3 files changed, 16 insertions(+), 20 deletions(-) (limited to 'shared') diff --git a/shared/models/actors/actor.model.ts b/shared/models/actors/actor.model.ts index 6b3b1b47c..a3953874d 100644 --- a/shared/models/actors/actor.model.ts +++ b/shared/models/actors/actor.model.ts @@ -10,5 +10,5 @@ export interface Actor { followersCount: number createdAt: Date | string updatedAt: Date | string - avatar: Avatar + avatar?: Avatar } diff --git a/shared/models/users/user-notification.model.ts b/shared/models/users/user-notification.model.ts index f41b6f534..eaeb422df 100644 --- a/shared/models/users/user-notification.model.ts +++ b/shared/models/users/user-notification.model.ts @@ -22,16 +22,22 @@ export interface VideoInfo { name: string } +export interface ActorInfo { + id: number + displayName: string + name: string + avatar?: { + path: string + } +} + export interface UserNotification { id: number type: UserNotificationType read: boolean video?: VideoInfo & { - channel: { - id: number - displayName: string - } + channel: ActorInfo } videoImport?: { @@ -45,10 +51,7 @@ export interface UserNotification { comment?: { id: number threadId: number - account: { - id: number - displayName: string - } + account: ActorInfo video: VideoInfo } @@ -62,18 +65,11 @@ export interface UserNotification { video: VideoInfo } - account?: { - id: number - displayName: string - name: string - } + account?: ActorInfo actorFollow?: { id: number - follower: { - name: string - displayName: string - } + follower: ActorInfo following: { type: 'account' | 'channel' name: string diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 4a9fa58b1..022876a0b 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts @@ -24,7 +24,7 @@ export interface VideoChannelAttribute { displayName: string url: string host: string - avatar: Avatar + avatar?: Avatar } export interface AccountAttribute { @@ -34,7 +34,7 @@ export interface AccountAttribute { displayName: string url: string host: string - avatar: Avatar + avatar?: Avatar } export interface Video { -- cgit v1.2.3 From dc094603cd9eccce3243a6b6ccec3416491f59d2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 17 Jan 2019 11:23:40 +0100 Subject: Fix tests --- shared/utils/server/servers.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'shared') diff --git a/shared/utils/server/servers.ts b/shared/utils/server/servers.ts index 1e9c83c72..cb57e0a69 100644 --- a/shared/utils/server/servers.ts +++ b/shared/utils/server/servers.ts @@ -146,7 +146,11 @@ function runServer (serverNumber: number, configOverride?: Object, args = []) { server.app.stdout.removeListener('data', onStdout) - process.on('exit', () => process.kill(server.app.pid)) + process.on('exit', () => { + try { + process.kill(server.app.pid) + } catch { /* empty */ } + }) res(server) }) -- cgit v1.2.3 From 38967f7b73cec6f6198c72d62f8d64bb88e6951c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 21 Jan 2019 13:52:46 +0100 Subject: Add server host in notification account field --- shared/models/users/user-notification.model.ts | 1 + shared/utils/users/user-notifications.ts | 1 + 2 files changed, 2 insertions(+) (limited to 'shared') diff --git a/shared/models/users/user-notification.model.ts b/shared/models/users/user-notification.model.ts index eaeb422df..186b62612 100644 --- a/shared/models/users/user-notification.model.ts +++ b/shared/models/users/user-notification.model.ts @@ -26,6 +26,7 @@ export interface ActorInfo { id: number displayName: string name: string + host: string avatar?: { path: string } diff --git a/shared/utils/users/user-notifications.ts b/shared/utils/users/user-notifications.ts index bcbe29fc7..b85d5d2f1 100644 --- a/shared/utils/users/user-notifications.ts +++ b/shared/utils/users/user-notifications.ts @@ -146,6 +146,7 @@ function checkVideo (video: any, videoName?: string, videoUUID?: string) { function checkActor (actor: any) { expect(actor.displayName).to.be.a('string') expect(actor.displayName).to.not.be.empty + expect(actor.host).to.not.be.undefined } function checkComment (comment: any, commentId: number, threadId: number) { -- cgit v1.2.3 From ebff55d8d6747d0627f135ab668f43e0d6125a37 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 21 Jan 2019 15:58:07 +0100 Subject: Fix tests --- shared/utils/users/user-notifications.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shared') diff --git a/shared/utils/users/user-notifications.ts b/shared/utils/users/user-notifications.ts index b85d5d2f1..c8ed7df30 100644 --- a/shared/utils/users/user-notifications.ts +++ b/shared/utils/users/user-notifications.ts @@ -274,8 +274,8 @@ async function checkNewActorFollow ( checkActor(notification.actorFollow.follower) expect(notification.actorFollow.follower.displayName).to.equal(followerDisplayName) expect(notification.actorFollow.follower.name).to.equal(followerName) + expect(notification.actorFollow.follower.host).to.not.be.undefined - checkActor(notification.actorFollow.following) expect(notification.actorFollow.following.displayName).to.equal(followingDisplayName) expect(notification.actorFollow.following.type).to.equal(followType) } else { -- cgit v1.2.3 From 092092969633bbcf6d4891a083ea497a7d5c3154 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 29 Jan 2019 08:37:25 +0100 Subject: Add hls support on server --- .../activitypub/objects/cache-file-object.ts | 4 +- .../models/activitypub/objects/common-objects.ts | 60 +++++++++++++++------- shared/models/server/custom-config.model.ts | 3 ++ shared/models/server/server-config.model.ts | 8 ++- .../videos/video-streaming-playlist.model.ts | 12 +++++ .../models/videos/video-streaming-playlist.type.ts | 3 ++ shared/models/videos/video.model.ts | 5 ++ shared/utils/index.ts | 2 + shared/utils/requests/requests.ts | 13 +++-- shared/utils/server/config.ts | 3 ++ shared/utils/server/servers.ts | 7 ++- shared/utils/videos/video-playlists.ts | 21 ++++++++ shared/utils/videos/videos.ts | 13 ++++- 13 files changed, 125 insertions(+), 29 deletions(-) create mode 100644 shared/models/videos/video-streaming-playlist.model.ts create mode 100644 shared/models/videos/video-streaming-playlist.type.ts create mode 100644 shared/utils/videos/video-playlists.ts (limited to 'shared') diff --git a/shared/models/activitypub/objects/cache-file-object.ts b/shared/models/activitypub/objects/cache-file-object.ts index 0a5125f5b..4b0a3a724 100644 --- a/shared/models/activitypub/objects/cache-file-object.ts +++ b/shared/models/activitypub/objects/cache-file-object.ts @@ -1,9 +1,9 @@ -import { ActivityVideoUrlObject } from './common-objects' +import { ActivityVideoUrlObject, ActivityPlaylistUrlObject } from './common-objects' export interface CacheFileObject { id: string type: 'CacheFile', object: string expires: string - url: ActivityVideoUrlObject + url: ActivityVideoUrlObject | ActivityPlaylistUrlObject } diff --git a/shared/models/activitypub/objects/common-objects.ts b/shared/models/activitypub/objects/common-objects.ts index 118a4f43d..8c89810d6 100644 --- a/shared/models/activitypub/objects/common-objects.ts +++ b/shared/models/activitypub/objects/common-objects.ts @@ -28,25 +28,47 @@ export type ActivityVideoUrlObject = { fps: number } -export type ActivityUrlObject = - ActivityVideoUrlObject - | - { - type: 'Link' - // TODO: remove mimeType (backward compatibility, introduced in v1.1.0) - mimeType?: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' - mediaType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' - href: string - height: number - } - | - { - type: 'Link' - // TODO: remove mimeType (backward compatibility, introduced in v1.1.0) - mimeType?: 'text/html' - mediaType: 'text/html' - href: string - } +export type ActivityPlaylistSegmentHashesObject = { + type: 'Link' + name: 'sha256' + // TODO: remove mimeType (backward compatibility, introduced in v1.1.0) + mimeType?: 'application/json' + mediaType: 'application/json' + href: string +} + +export type ActivityPlaylistInfohashesObject = { + type: 'Infohash' + name: string +} + +export type ActivityPlaylistUrlObject = { + type: 'Link' + // TODO: remove mimeType (backward compatibility, introduced in v1.1.0) + mimeType?: 'application/x-mpegURL' + mediaType: 'application/x-mpegURL' + href: string + tag?: (ActivityPlaylistSegmentHashesObject | ActivityPlaylistInfohashesObject)[] +} + +export type ActivityBitTorrentUrlObject = { + type: 'Link' + // TODO: remove mimeType (backward compatibility, introduced in v1.1.0) + mimeType?: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' + mediaType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' + href: string + height: number +} + +export type ActivityHtmlUrlObject = { + type: 'Link' + // TODO: remove mimeType (backward compatibility, introduced in v1.1.0) + mimeType?: 'text/html' + mediaType: 'text/html' + href: string +} + +export type ActivityUrlObject = ActivityVideoUrlObject | ActivityPlaylistUrlObject | ActivityBitTorrentUrlObject | ActivityHtmlUrlObject export interface ActivityPubAttributedTo { type: 'Group' | 'Person' diff --git a/shared/models/server/custom-config.model.ts b/shared/models/server/custom-config.model.ts index 7a3eaa33f..b42ff90c6 100644 --- a/shared/models/server/custom-config.model.ts +++ b/shared/models/server/custom-config.model.ts @@ -61,6 +61,9 @@ export interface CustomConfig { '720p': boolean '1080p': boolean } + hls: { + enabled: boolean + } } import: { diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts index f4245ed4d..baafed31f 100644 --- a/shared/models/server/server-config.model.ts +++ b/shared/models/server/server-config.model.ts @@ -25,11 +25,15 @@ export interface ServerConfig { signup: { allowed: boolean, - allowedForCurrentIP: boolean, + allowedForCurrentIP: boolean requiresEmailVerification: boolean } transcoding: { + hls: { + enabled: boolean + } + enabledResolutions: number[] } @@ -48,7 +52,7 @@ export interface ServerConfig { file: { size: { max: number - }, + } extensions: string[] } } diff --git a/shared/models/videos/video-streaming-playlist.model.ts b/shared/models/videos/video-streaming-playlist.model.ts new file mode 100644 index 000000000..17f8fe865 --- /dev/null +++ b/shared/models/videos/video-streaming-playlist.model.ts @@ -0,0 +1,12 @@ +import { VideoStreamingPlaylistType } from './video-streaming-playlist.type' + +export class VideoStreamingPlaylist { + id: number + type: VideoStreamingPlaylistType + playlistUrl: string + segmentsSha256Url: string + + redundancies: { + baseUrl: string + }[] +} diff --git a/shared/models/videos/video-streaming-playlist.type.ts b/shared/models/videos/video-streaming-playlist.type.ts new file mode 100644 index 000000000..3b403f295 --- /dev/null +++ b/shared/models/videos/video-streaming-playlist.type.ts @@ -0,0 +1,3 @@ +export enum VideoStreamingPlaylistType { + HLS = 1 +} diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 022876a0b..803db8255 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts @@ -5,6 +5,7 @@ import { VideoChannel } from './channel/video-channel.model' import { VideoPrivacy } from './video-privacy.enum' import { VideoScheduleUpdate } from './video-schedule-update.model' import { VideoConstant } from './video-constant.model' +import { VideoStreamingPlaylist } from './video-streaming-playlist.model' export interface VideoFile { magnetUri: string @@ -86,4 +87,8 @@ export interface VideoDetails extends Video { // Not optional in details (unlike in Video) waitTranscoding: boolean state: VideoConstant + + trackerUrls: string[] + + streamingPlaylists: VideoStreamingPlaylist[] } diff --git a/shared/utils/index.ts b/shared/utils/index.ts index e08bbfd2a..156901372 100644 --- a/shared/utils/index.ts +++ b/shared/utils/index.ts @@ -17,6 +17,8 @@ export * from './users/users' export * from './videos/video-abuses' export * from './videos/video-blacklist' export * from './videos/video-channels' +export * from './videos/video-comments' +export * from './videos/video-playlists' export * from './videos/videos' export * from './videos/video-change-ownership' export * from './feeds/feeds' diff --git a/shared/utils/requests/requests.ts b/shared/utils/requests/requests.ts index 77e9f6164..fc687c701 100644 --- a/shared/utils/requests/requests.ts +++ b/shared/utils/requests/requests.ts @@ -1,10 +1,17 @@ import * as request from 'supertest' import { buildAbsoluteFixturePath, root } from '../miscs/miscs' import { isAbsolute, join } from 'path' +import { parse } from 'url' + +function makeRawRequest (url: string, statusCodeExpected?: number) { + const { host, protocol, pathname } = parse(url) + + return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected }) +} function makeGetRequest (options: { url: string, - path: string, + path?: string, query?: any, token?: string, statusCodeExpected?: number, @@ -13,8 +20,7 @@ function makeGetRequest (options: { if (!options.statusCodeExpected) options.statusCodeExpected = 400 if (options.contentType === undefined) options.contentType = 'application/json' - const req = request(options.url) - .get(options.path) + const req = request(options.url).get(options.path) if (options.contentType) req.set('Accept', options.contentType) if (options.token) req.set('Authorization', 'Bearer ' + options.token) @@ -164,5 +170,6 @@ export { makePostBodyRequest, makePutBodyRequest, makeDeleteRequest, + makeRawRequest, updateAvatarRequest } diff --git a/shared/utils/server/config.ts b/shared/utils/server/config.ts index 0c5512bab..29c24cff9 100644 --- a/shared/utils/server/config.ts +++ b/shared/utils/server/config.ts @@ -97,6 +97,9 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) { '480p': true, '720p': false, '1080p': false + }, + hls: { + enabled: false } }, import: { diff --git a/shared/utils/server/servers.ts b/shared/utils/server/servers.ts index cb57e0a69..bde7dd5c2 100644 --- a/shared/utils/server/servers.ts +++ b/shared/utils/server/servers.ts @@ -166,9 +166,13 @@ async function reRunServer (server: ServerInfo, configOverride?: any) { } async function checkTmpIsEmpty (server: ServerInfo) { + return checkDirectoryIsEmpty(server, 'tmp') +} + +async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) { const testDirectory = 'test' + server.serverNumber - const directoryPath = join(root(), testDirectory, 'tmp') + const directoryPath = join(root(), testDirectory, directory) const directoryExists = existsSync(directoryPath) expect(directoryExists).to.be.true @@ -199,6 +203,7 @@ async function waitUntilLog (server: ServerInfo, str: string, count = 1) { // --------------------------------------------------------------------------- export { + checkDirectoryIsEmpty, checkTmpIsEmpty, ServerInfo, flushAndRunMultipleServers, diff --git a/shared/utils/videos/video-playlists.ts b/shared/utils/videos/video-playlists.ts new file mode 100644 index 000000000..9a0710ca6 --- /dev/null +++ b/shared/utils/videos/video-playlists.ts @@ -0,0 +1,21 @@ +import { makeRawRequest } from '../requests/requests' + +function getPlaylist (url: string, statusCodeExpected = 200) { + return makeRawRequest(url, statusCodeExpected) +} + +function getSegment (url: string, statusCodeExpected = 200) { + return makeRawRequest(url, statusCodeExpected) +} + +function getSegmentSha256 (url: string, statusCodeExpected = 200) { + return makeRawRequest(url, statusCodeExpected) +} + +// --------------------------------------------------------------------------- + +export { + getPlaylist, + getSegment, + getSegmentSha256 +} diff --git a/shared/utils/videos/videos.ts b/shared/utils/videos/videos.ts index 0cf6e7c4f..b5b33e038 100644 --- a/shared/utils/videos/videos.ts +++ b/shared/utils/videos/videos.ts @@ -271,7 +271,16 @@ function removeVideo (url: string, token: string, id: number | string, expectedS async function checkVideoFilesWereRemoved ( videoUUID: string, serverNumber: number, - directories = [ 'redundancy', 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ] + directories = [ + 'redundancy', + 'videos', + 'thumbnails', + 'torrents', + 'previews', + 'captions', + join('playlists', 'hls'), + join('redundancy', 'hls') + ] ) { const testDirectory = 'test' + serverNumber @@ -279,7 +288,7 @@ async function checkVideoFilesWereRemoved ( const directoryPath = join(root(), testDirectory, directory) const directoryExists = existsSync(directoryPath) - expect(directoryExists).to.be.true + if (!directoryExists) continue const files = await readdir(directoryPath) for (const file of files) { -- cgit v1.2.3 From 4c280004ce62bf11ddb091854c28f1e1d54a54d6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Feb 2019 15:08:19 +0100 Subject: Use a single file instead of segments for HLS --- .../activitypub/activitypub-ordered-collection.ts | 5 ++- shared/utils/requests/requests.ts | 8 +++-- shared/utils/videos/video-playlists.ts | 36 ++++++++++++++++++++-- 3 files changed, 42 insertions(+), 7 deletions(-) (limited to 'shared') diff --git a/shared/models/activitypub/activitypub-ordered-collection.ts b/shared/models/activitypub/activitypub-ordered-collection.ts index dfec0bb76..3de0890bb 100644 --- a/shared/models/activitypub/activitypub-ordered-collection.ts +++ b/shared/models/activitypub/activitypub-ordered-collection.ts @@ -2,6 +2,9 @@ export interface ActivityPubOrderedCollection { '@context': string[] type: 'OrderedCollection' | 'OrderedCollectionPage' totalItems: number - partOf?: string orderedItems: T[] + + partOf?: string + next?: string + first?: string } diff --git a/shared/utils/requests/requests.ts b/shared/utils/requests/requests.ts index fc687c701..6b59e24fc 100644 --- a/shared/utils/requests/requests.ts +++ b/shared/utils/requests/requests.ts @@ -3,10 +3,10 @@ import { buildAbsoluteFixturePath, root } from '../miscs/miscs' import { isAbsolute, join } from 'path' import { parse } from 'url' -function makeRawRequest (url: string, statusCodeExpected?: number) { +function makeRawRequest (url: string, statusCodeExpected?: number, range?: string) { const { host, protocol, pathname } = parse(url) - return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected }) + return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected, range }) } function makeGetRequest (options: { @@ -15,7 +15,8 @@ function makeGetRequest (options: { query?: any, token?: string, statusCodeExpected?: number, - contentType?: string + contentType?: string, + range?: string }) { if (!options.statusCodeExpected) options.statusCodeExpected = 400 if (options.contentType === undefined) options.contentType = 'application/json' @@ -25,6 +26,7 @@ function makeGetRequest (options: { if (options.contentType) req.set('Accept', options.contentType) if (options.token) req.set('Authorization', 'Bearer ' + options.token) if (options.query) req.query(options.query) + if (options.range) req.set('Range', options.range) return req.expect(options.statusCodeExpected) } diff --git a/shared/utils/videos/video-playlists.ts b/shared/utils/videos/video-playlists.ts index 9a0710ca6..eb25011cb 100644 --- a/shared/utils/videos/video-playlists.ts +++ b/shared/utils/videos/video-playlists.ts @@ -1,21 +1,51 @@ import { makeRawRequest } from '../requests/requests' +import { sha256 } from '../../../server/helpers/core-utils' +import { VideoStreamingPlaylist } from '../../models/videos/video-streaming-playlist.model' +import { expect } from 'chai' function getPlaylist (url: string, statusCodeExpected = 200) { return makeRawRequest(url, statusCodeExpected) } -function getSegment (url: string, statusCodeExpected = 200) { - return makeRawRequest(url, statusCodeExpected) +function getSegment (url: string, statusCodeExpected = 200, range?: string) { + return makeRawRequest(url, statusCodeExpected, range) } function getSegmentSha256 (url: string, statusCodeExpected = 200) { return makeRawRequest(url, statusCodeExpected) } +async function checkSegmentHash ( + baseUrlPlaylist: string, + baseUrlSegment: string, + videoUUID: string, + resolution: number, + hlsPlaylist: VideoStreamingPlaylist +) { + const res = await getPlaylist(`${baseUrlPlaylist}/${videoUUID}/${resolution}.m3u8`) + const playlist = res.text + + const videoName = `${videoUUID}-${resolution}-fragmented.mp4` + + const matches = /#EXT-X-BYTERANGE:(\d+)@(\d+)/.exec(playlist) + + const length = parseInt(matches[1], 10) + const offset = parseInt(matches[2], 10) + const range = `${offset}-${offset + length - 1}` + + const res2 = await getSegment(`${baseUrlSegment}/${videoUUID}/${videoName}`, 206, `bytes=${range}`) + + const resSha = await getSegmentSha256(hlsPlaylist.segmentsSha256Url) + + const sha256Server = resSha.body[ videoName ][range] + expect(sha256(res2.body)).to.equal(sha256Server) +} + // --------------------------------------------------------------------------- export { getPlaylist, getSegment, - getSegmentSha256 + getSegmentSha256, + checkSegmentHash } -- cgit v1.2.3 From b426edd4854adc6e65844d8c54b8998e792b5778 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 11 Feb 2019 09:30:29 +0100 Subject: Cleanup reset user password by admin And add some tests --- shared/models/users/user-update.model.ts | 1 + shared/utils/users/users.ts | 2 ++ 2 files changed, 3 insertions(+) (limited to 'shared') diff --git a/shared/models/users/user-update.model.ts b/shared/models/users/user-update.model.ts index abde51321..cd215bab3 100644 --- a/shared/models/users/user-update.model.ts +++ b/shared/models/users/user-update.model.ts @@ -1,6 +1,7 @@ import { UserRole } from './user-role' export interface UserUpdate { + password?: string email?: string emailVerified?: boolean videoQuota?: number diff --git a/shared/utils/users/users.ts b/shared/utils/users/users.ts index 61a7e3757..7191b263e 100644 --- a/shared/utils/users/users.ts +++ b/shared/utils/users/users.ts @@ -213,11 +213,13 @@ function updateUser (options: { emailVerified?: boolean, videoQuota?: number, videoQuotaDaily?: number, + password?: string, role?: UserRole }) { const path = '/api/v1/users/' + options.userId const toSend = {} + if (options.password !== undefined && options.password !== null) toSend['password'] = options.password if (options.email !== undefined && options.email !== null) toSend['email'] = options.email if (options.emailVerified !== undefined && options.emailVerified !== null) toSend['emailVerified'] = options.emailVerified if (options.videoQuota !== undefined && options.videoQuota !== null) toSend['videoQuota'] = options.videoQuota -- cgit v1.2.3