aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/user.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-12 15:47:47 +0100
committerChocobozzz <me@florianbigard.com>2019-12-12 16:51:59 +0100
commit22a73cb879a5cc775d4bec3d72fa9c9cf52e5175 (patch)
tree4c8d2d4f6fce8a520420ec83722fefc6d57b7a83 /server/models/account/user.ts
parent91fa7960f42cff3481465bece3389007fbc278d3 (diff)
downloadPeerTube-22a73cb879a5cc775d4bec3d72fa9c9cf52e5175.tar.gz
PeerTube-22a73cb879a5cc775d4bec3d72fa9c9cf52e5175.tar.zst
PeerTube-22a73cb879a5cc775d4bec3d72fa9c9cf52e5175.zip
Add internal privacy mode
Diffstat (limited to 'server/models/account/user.ts')
-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 }