From f49b8d9b697f098490e81ce0afd889ba37dcb2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 20 Jan 2021 23:40:40 +0100 Subject: Allow only admin to download a video --- client/src/app/+videos/+video-watch/video-watch.component.ts | 2 +- client/src/app/shared/shared-main/video/video.model.ts | 4 ++++ .../shared/shared-video-miniature/video-actions-dropdown.component.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index c757a5e93..2b56d5064 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -239,7 +239,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } isVideoDownloadable () { - return this.video && this.video instanceof VideoDetails && this.video.downloadEnabled && !this.video.isLive + return this.video && this.video instanceof VideoDetails && this.video.isDownloadableBy(this.user) && !this.video.isLive } loadCompleteDescription () { diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts index d51dfbc6d..fb00c11ff 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts @@ -179,6 +179,10 @@ export class Video implements VideoServerModel { return serverConfig.instance.defaultNSFWPolicy !== 'display' } + isDownloadableBy (user: AuthUser) { + return user && this.isLocal === true && user.hasRight(UserRight.SEE_ALL_VIDEOS) + } + isRemovableBy (user: AuthUser) { return user && this.isLocal === true && user.hasRight(UserRight.REMOVE_ANY_VIDEO) } diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts index 3c2b46d16..2bc9bf7e4 100644 --- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts @@ -163,7 +163,7 @@ export class VideoActionsDropdownComponent implements OnChanges { return this.video && this.video.isLive !== true && this.video instanceof VideoDetails && - this.video.downloadEnabled + this.video.isDownloadableBy(this.user) } canVideoBeDuplicated () { -- cgit v1.2.3