diff options
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/user.ts | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 38c6d474a..522ea3310 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts | |||
@@ -19,7 +19,7 @@ import { | |||
19 | Table, | 19 | Table, |
20 | UpdatedAt | 20 | UpdatedAt |
21 | } from 'sequelize-typescript' | 21 | } from 'sequelize-typescript' |
22 | import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared' | 22 | import { hasUserRight, USER_ROLE_LABELS, UserRight, VideoPrivacy } from '../../../shared' |
23 | import { User, UserRole } from '../../../shared/models/users' | 23 | import { User, UserRole } from '../../../shared/models/users' |
24 | import { | 24 | import { |
25 | isNoInstanceConfigWarningModal, | 25 | isNoInstanceConfigWarningModal, |
@@ -63,7 +63,7 @@ import { | |||
63 | MUserFormattable, | 63 | MUserFormattable, |
64 | MUserId, | 64 | MUserId, |
65 | MUserNotifSettingChannelDefault, | 65 | MUserNotifSettingChannelDefault, |
66 | MUserWithNotificationSetting | 66 | MUserWithNotificationSetting, MVideoFullLight |
67 | } from '@server/typings/models' | 67 | } from '@server/typings/models' |
68 | 68 | ||
69 | enum ScopeNames { | 69 | enum ScopeNames { |
@@ -575,6 +575,20 @@ export class UserModel extends Model<UserModel> { | |||
575 | .then(u => u.map(u => u.username)) | 575 | .then(u => u.map(u => u.username)) |
576 | } | 576 | } |
577 | 577 | ||
578 | canGetVideo (video: MVideoFullLight) { | ||
579 | if (video.privacy === VideoPrivacy.INTERNAL) return true | ||
580 | |||
581 | if (video.privacy === VideoPrivacy.PRIVATE) { | ||
582 | return video.VideoChannel && video.VideoChannel.Account.userId === this.id | ||
583 | } | ||
584 | |||
585 | if (video.isBlacklisted()) { | ||
586 | return this.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) | ||
587 | } | ||
588 | |||
589 | return false | ||
590 | } | ||
591 | |||
578 | hasRight (right: UserRight) { | 592 | hasRight (right: UserRight) { |
579 | return hasUserRight(this.role, right) | 593 | return hasUserRight(this.role, right) |
580 | } | 594 | } |