From 9eee32fc34ece1cc5e624ae15d81bfede68be33f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 May 2017 14:11:01 +0200 Subject: [PATCH] Client: fix update button displayed on non owned video --- client/src/app/videos/shared/video.model.ts | 4 ++++ client/src/app/videos/video-watch/video-watch.component.ts | 3 +-- server/tests/api/video-abuse.js | 2 +- server/tests/api/video-blacklist.js | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts index 1cfb312b6..fafdb4ac4 100644 --- a/client/src/app/videos/shared/video.model.ts +++ b/client/src/app/videos/shared/video.model.ts @@ -93,6 +93,10 @@ export class Video { return user && user.isAdmin() === true && this.isLocal === false; } + isUpdatableBy(user) { + return user && this.isLocal === true && user.username === this.author; + } + isVideoNSFWForUser(user: User) { // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos... return (this.nsfw && (!user || user.displayNSFW === false)); 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 07b2a1d1f..756f66726 100644 --- a/client/src/app/videos/video-watch/video-watch.component.ts +++ b/client/src/app/videos/video-watch/video-watch.component.ts @@ -229,8 +229,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } canUserUpdateVideo() { - return this.authService.getUser() !== null && - this.authService.getUser().username === this.video.author; + return this.video.isUpdatableBy(this.authService.getUser()); } isVideoRemovable() { diff --git a/server/tests/api/video-abuse.js b/server/tests/api/video-abuse.js index a9af74857..c2b6186bd 100644 --- a/server/tests/api/video-abuse.js +++ b/server/tests/api/video-abuse.js @@ -17,7 +17,7 @@ describe('Test video abuses', function () { let servers = [] before(function (done) { - this.timeout(30000) + this.timeout(40000) series([ // Run servers diff --git a/server/tests/api/video-blacklist.js b/server/tests/api/video-blacklist.js index 6287b9b08..20b7c5de3 100644 --- a/server/tests/api/video-blacklist.js +++ b/server/tests/api/video-blacklist.js @@ -17,7 +17,7 @@ describe('Test video blacklists', function () { let servers = [] before(function (done) { - this.timeout(30000) + this.timeout(40000) series([ // Run servers