aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/account')
-rw-r--r--server/models/account/user.ts18
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'
22import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared' 22import { hasUserRight, USER_ROLE_LABELS, UserRight, VideoPrivacy } from '../../../shared'
23import { User, UserRole } from '../../../shared/models/users' 23import { User, UserRole } from '../../../shared/models/users'
24import { 24import {
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
69enum ScopeNames { 69enum 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 }