diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2018-10-05 15:17:34 +0200 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2018-10-13 11:53:42 +0200 |
commit | 64cc5e8575fda47b281ae20abf0020e27fc8ce7c (patch) | |
tree | c3ec40b03d3fdc5d3beee9ff089384c894d9efe9 /server/models/account | |
parent | 0e5ff97f6fdf9a4cebe5a15f5a390380465803ad (diff) | |
download | PeerTube-64cc5e8575fda47b281ae20abf0020e27fc8ce7c.tar.gz PeerTube-64cc5e8575fda47b281ae20abf0020e27fc8ce7c.tar.zst PeerTube-64cc5e8575fda47b281ae20abf0020e27fc8ce7c.zip |
add webtorrent opt-out settings
- add a key in localstorage to remember the opt-out
- add a user setting
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/user.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 39654cfcf..5fe7d7e7d 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts | |||
@@ -31,7 +31,8 @@ import { | |||
31 | isUserRoleValid, | 31 | isUserRoleValid, |
32 | isUserUsernameValid, | 32 | isUserUsernameValid, |
33 | isUserVideoQuotaDailyValid, | 33 | isUserVideoQuotaDailyValid, |
34 | isUserVideoQuotaValid | 34 | isUserVideoQuotaValid, |
35 | isUserWebTorrentPolicyValid | ||
35 | } from '../../helpers/custom-validators/users' | 36 | } from '../../helpers/custom-validators/users' |
36 | import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' | 37 | import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' |
37 | import { OAuthTokenModel } from '../oauth/oauth-token' | 38 | import { OAuthTokenModel } from '../oauth/oauth-token' |
@@ -39,8 +40,9 @@ import { getSort, throwIfNotValid } from '../utils' | |||
39 | import { VideoChannelModel } from '../video/video-channel' | 40 | import { VideoChannelModel } from '../video/video-channel' |
40 | import { AccountModel } from './account' | 41 | import { AccountModel } from './account' |
41 | import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' | 42 | import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' |
43 | import { WebTorrentPolicyType } from '../../../shared/models/users/user-webtorrent-policy.type' | ||
42 | import { values } from 'lodash' | 44 | import { values } from 'lodash' |
43 | import { NSFW_POLICY_TYPES } from '../../initializers' | 45 | import { NSFW_POLICY_TYPES, WEBTORRENT_POLICY_TYPES } from '../../initializers' |
44 | import { clearCacheByUserId } from '../../lib/oauth-model' | 46 | import { clearCacheByUserId } from '../../lib/oauth-model' |
45 | 47 | ||
46 | enum ScopeNames { | 48 | enum ScopeNames { |
@@ -108,6 +110,11 @@ export class UserModel extends Model<UserModel> { | |||
108 | nsfwPolicy: NSFWPolicyType | 110 | nsfwPolicy: NSFWPolicyType |
109 | 111 | ||
110 | @AllowNull(false) | 112 | @AllowNull(false) |
113 | @Is('UserWebTorrentPolicy', value => throwIfNotValid(value, isUserWebTorrentPolicyValid, 'WebTorrent policy')) | ||
114 | @Column(DataType.ENUM(values(WEBTORRENT_POLICY_TYPES))) | ||
115 | webTorrentPolicy: WebTorrentPolicyType | ||
116 | |||
117 | @AllowNull(false) | ||
111 | @Default(true) | 118 | @Default(true) |
112 | @Is('UserAutoPlayVideo', value => throwIfNotValid(value, isUserAutoPlayVideoValid, 'auto play video boolean')) | 119 | @Is('UserAutoPlayVideo', value => throwIfNotValid(value, isUserAutoPlayVideoValid, 'auto play video boolean')) |
113 | @Column | 120 | @Column |
@@ -355,6 +362,7 @@ export class UserModel extends Model<UserModel> { | |||
355 | email: this.email, | 362 | email: this.email, |
356 | emailVerified: this.emailVerified, | 363 | emailVerified: this.emailVerified, |
357 | nsfwPolicy: this.nsfwPolicy, | 364 | nsfwPolicy: this.nsfwPolicy, |
365 | webTorrentPolicy: this.webTorrentPolicy, | ||
358 | autoPlayVideo: this.autoPlayVideo, | 366 | autoPlayVideo: this.autoPlayVideo, |
359 | role: this.role, | 367 | role: this.role, |
360 | roleLabel: USER_ROLE_LABELS[ this.role ], | 368 | roleLabel: USER_ROLE_LABELS[ this.role ], |