From ff9d43f62a4f4737c5bfe955883b48c5440f323a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 22 Jun 2022 09:44:08 +0200 Subject: Refactor video rights checker --- server/models/user/user.ts | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'server/models') diff --git a/server/models/user/user.ts b/server/models/user/user.ts index a25551ecd..dc260e512 100644 --- a/server/models/user/user.ts +++ b/server/models/user/user.ts @@ -29,12 +29,11 @@ import { MUserDefault, MUserFormattable, MUserNotifSettingChannelDefault, - MUserWithNotificationSetting, - MVideoWithRights + MUserWithNotificationSetting } from '@server/types/models' import { AttributesOnly } from '@shared/typescript-utils' import { hasUserRight, USER_ROLE_LABELS } from '../../../shared/core-utils/users' -import { AbuseState, MyUser, UserRight, VideoPlaylistType, VideoPrivacy } from '../../../shared/models' +import { AbuseState, MyUser, UserRight, VideoPlaylistType } from '../../../shared/models' import { User, UserRole } from '../../../shared/models/users' import { UserAdminFlag } from '../../../shared/models/users/user-flag.model' import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' @@ -851,22 +850,6 @@ export class UserModel extends Model>> { .then(u => u.map(u => u.username)) } - canGetVideo (video: MVideoWithRights) { - const videoUserId = video.VideoChannel.Account.userId - - if (video.isBlacklisted()) { - return videoUserId === this.id || this.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) - } - - if (video.privacy === VideoPrivacy.PRIVATE) { - return video.VideoChannel && videoUserId === this.id || this.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) - } - - if (video.privacy === VideoPrivacy.INTERNAL) return true - - return false - } - hasRight (right: UserRight) { return hasUserRight(this.role, right) } -- cgit v1.2.3