Table,
UpdatedAt
} from 'sequelize-typescript'
-import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared'
+import { hasUserRight, USER_ROLE_LABELS, UserRight, VideoPrivacy } from '../../../shared'
import { User, UserRole } from '../../../shared/models/users'
import {
isNoInstanceConfigWarningModal,
isUserAdminFlagsValid,
isUserAutoPlayVideoValid,
isUserAutoPlayNextVideoValid,
+ isUserAutoPlayNextVideoPlaylistValid,
isUserBlockedReasonValid,
isUserBlockedValid,
isUserEmailVerifiedValid,
MUserFormattable,
MUserId,
MUserNotifSettingChannelDefault,
- MUserWithNotificationSetting
+ MUserWithNotificationSetting, MVideoFullLight
} from '@server/typings/models'
enum ScopeNames {
@Column
autoPlayNextVideo: boolean
+ @AllowNull(false)
+ @Default(true)
+ @Is('UserAutoPlayNextVideoPlaylist', value => throwIfNotValid(value, isUserAutoPlayNextVideoPlaylistValid, 'auto play next video for playlists boolean'))
+ @Column
+ autoPlayNextVideoPlaylist: boolean
+
@AllowNull(true)
@Default(null)
@Is('UserVideoLanguages', value => throwIfNotValid(value, isUserVideoLanguages, 'video languages'))
.then(u => u.map(u => u.username))
}
+ canGetVideo (video: MVideoFullLight) {
+ 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)
}
videosHistoryEnabled: this.videosHistoryEnabled,
autoPlayVideo: this.autoPlayVideo,
autoPlayNextVideo: this.autoPlayNextVideo,
+ autoPlayNextVideoPlaylist: this.autoPlayNextVideoPlaylist,
videoLanguages: this.videoLanguages,
role: this.role,