1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

add webtorrent opt-out settings

- add a key in localstorage to remember the opt-out
- add a user setting
This commit is contained in:
Rigel Kent 2018-10-05 15:17:34 +02:00
parent 0e5ff97f6f
commit 64cc5e8575
No known key found for this signature in database
GPG key ID: EA12971B0E438F36
13 changed files with 97 additions and 6 deletions

View file

@ -31,7 +31,8 @@ import {
isUserRoleValid,
isUserUsernameValid,
isUserVideoQuotaDailyValid,
isUserVideoQuotaValid
isUserVideoQuotaValid,
isUserWebTorrentPolicyValid
} from '../../helpers/custom-validators/users'
import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto'
import { OAuthTokenModel } from '../oauth/oauth-token'
@ -39,8 +40,9 @@ import { getSort, throwIfNotValid } from '../utils'
import { VideoChannelModel } from '../video/video-channel'
import { AccountModel } from './account'
import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type'
import { WebTorrentPolicyType } from '../../../shared/models/users/user-webtorrent-policy.type'
import { values } from 'lodash'
import { NSFW_POLICY_TYPES } from '../../initializers'
import { NSFW_POLICY_TYPES, WEBTORRENT_POLICY_TYPES } from '../../initializers'
import { clearCacheByUserId } from '../../lib/oauth-model'
enum ScopeNames {
@ -107,6 +109,11 @@ export class UserModel extends Model<UserModel> {
@Column(DataType.ENUM(values(NSFW_POLICY_TYPES)))
nsfwPolicy: NSFWPolicyType
@AllowNull(false)
@Is('UserWebTorrentPolicy', value => throwIfNotValid(value, isUserWebTorrentPolicyValid, 'WebTorrent policy'))
@Column(DataType.ENUM(values(WEBTORRENT_POLICY_TYPES)))
webTorrentPolicy: WebTorrentPolicyType
@AllowNull(false)
@Default(true)
@Is('UserAutoPlayVideo', value => throwIfNotValid(value, isUserAutoPlayVideoValid, 'auto play video boolean'))
@ -355,6 +362,7 @@ export class UserModel extends Model<UserModel> {
email: this.email,
emailVerified: this.emailVerified,
nsfwPolicy: this.nsfwPolicy,
webTorrentPolicy: this.webTorrentPolicy,
autoPlayVideo: this.autoPlayVideo,
role: this.role,
roleLabel: USER_ROLE_LABELS[ this.role ],