add webtorrent opt-out settings
- add a key in localstorage to remember the opt-out - add a user setting
This commit is contained in:
parent
0e5ff97f6f
commit
64cc5e8575
13 changed files with 97 additions and 6 deletions
|
@ -15,6 +15,18 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label i18n for="webTorrentPolicy">Policy regarding P2P technologies</label>
|
||||||
|
|
||||||
|
<div class="peertube-select-container">
|
||||||
|
<select id="webTorrentPolicy" formControlName="webTorrentPolicy">
|
||||||
|
<option i18n value="enable">Enable WebTorrent</option>
|
||||||
|
<option i18n value="disable">Disable WebTorrent globally</option>
|
||||||
|
<option i18n value="disable_on_mobile" disabled>Disable WebTorrent on mobile devices (not yet available)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<my-peertube-checkbox
|
<my-peertube-checkbox
|
||||||
inputName="autoPlayVideo" formControlName="autoPlayVideo"
|
inputName="autoPlayVideo" formControlName="autoPlayVideo"
|
||||||
i18n-labelText labelText="Automatically plays video"
|
i18n-labelText labelText="Automatically plays video"
|
||||||
|
|
|
@ -29,12 +29,14 @@ export class MyAccountVideoSettingsComponent extends FormReactive implements OnI
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.buildForm({
|
this.buildForm({
|
||||||
nsfwPolicy: null,
|
nsfwPolicy: null,
|
||||||
|
webTorrentPolicy: null,
|
||||||
autoPlayVideo: null
|
autoPlayVideo: null
|
||||||
})
|
})
|
||||||
|
|
||||||
this.userInformationLoaded.subscribe(() => {
|
this.userInformationLoaded.subscribe(() => {
|
||||||
this.form.patchValue({
|
this.form.patchValue({
|
||||||
nsfwPolicy: this.user.nsfwPolicy,
|
nsfwPolicy: this.user.nsfwPolicy,
|
||||||
|
webTorrentPolicy: this.user.webTorrentPolicy,
|
||||||
autoPlayVideo: this.user.autoPlayVideo === true
|
autoPlayVideo: this.user.autoPlayVideo === true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -42,9 +44,11 @@ export class MyAccountVideoSettingsComponent extends FormReactive implements OnI
|
||||||
|
|
||||||
updateDetails () {
|
updateDetails () {
|
||||||
const nsfwPolicy = this.form.value['nsfwPolicy']
|
const nsfwPolicy = this.form.value['nsfwPolicy']
|
||||||
|
const webTorrentPolicy = this.form.value['webTorrentPolicy']
|
||||||
const autoPlayVideo = this.form.value['autoPlayVideo']
|
const autoPlayVideo = this.form.value['autoPlayVideo']
|
||||||
const details: UserUpdateMe = {
|
const details: UserUpdateMe = {
|
||||||
nsfwPolicy,
|
nsfwPolicy,
|
||||||
|
webTorrentPolicy,
|
||||||
autoPlayVideo
|
autoPlayVideo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { UserRight } from '../../../../../shared/models/users/user-right.enum'
|
||||||
import { hasUserRight, UserRole } from '../../../../../shared/models/users/user-role'
|
import { hasUserRight, UserRole } from '../../../../../shared/models/users/user-role'
|
||||||
import { User, UserConstructorHash } from '../../shared/users/user.model'
|
import { User, UserConstructorHash } from '../../shared/users/user.model'
|
||||||
import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
|
import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
|
||||||
|
import { WebTorrentPolicyType } from '../../../../../shared/models/users/user-webtorrent-policy.type'
|
||||||
|
|
||||||
export type TokenOptions = {
|
export type TokenOptions = {
|
||||||
accessToken: string
|
accessToken: string
|
||||||
|
@ -72,6 +73,7 @@ export class AuthUser extends User {
|
||||||
EMAIL: 'email',
|
EMAIL: 'email',
|
||||||
USERNAME: 'username',
|
USERNAME: 'username',
|
||||||
NSFW_POLICY: 'nsfw_policy',
|
NSFW_POLICY: 'nsfw_policy',
|
||||||
|
WEBTORRENT_POLICY: 'peertube-videojs-' + 'webtorrent_policy',
|
||||||
AUTO_PLAY_VIDEO: 'auto_play_video'
|
AUTO_PLAY_VIDEO: 'auto_play_video'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +89,7 @@ export class AuthUser extends User {
|
||||||
email: peertubeLocalStorage.getItem(this.KEYS.EMAIL),
|
email: peertubeLocalStorage.getItem(this.KEYS.EMAIL),
|
||||||
role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole,
|
role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole,
|
||||||
nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.NSFW_POLICY) as NSFWPolicyType,
|
nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.NSFW_POLICY) as NSFWPolicyType,
|
||||||
|
webTorrentPolicy: peertubeLocalStorage.getItem(this.KEYS.WEBTORRENT_POLICY) as WebTorrentPolicyType,
|
||||||
autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true'
|
autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true'
|
||||||
},
|
},
|
||||||
Tokens.load()
|
Tokens.load()
|
||||||
|
@ -101,6 +104,7 @@ export class AuthUser extends User {
|
||||||
peertubeLocalStorage.removeItem(this.KEYS.ID)
|
peertubeLocalStorage.removeItem(this.KEYS.ID)
|
||||||
peertubeLocalStorage.removeItem(this.KEYS.ROLE)
|
peertubeLocalStorage.removeItem(this.KEYS.ROLE)
|
||||||
peertubeLocalStorage.removeItem(this.KEYS.NSFW_POLICY)
|
peertubeLocalStorage.removeItem(this.KEYS.NSFW_POLICY)
|
||||||
|
peertubeLocalStorage.removeItem(this.KEYS.WEBTORRENT_POLICY)
|
||||||
peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO)
|
peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO)
|
||||||
peertubeLocalStorage.removeItem(this.KEYS.EMAIL)
|
peertubeLocalStorage.removeItem(this.KEYS.EMAIL)
|
||||||
Tokens.flush()
|
Tokens.flush()
|
||||||
|
@ -138,6 +142,7 @@ export class AuthUser extends User {
|
||||||
peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email)
|
peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email)
|
||||||
peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString())
|
peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString())
|
||||||
peertubeLocalStorage.setItem(AuthUser.KEYS.NSFW_POLICY, this.nsfwPolicy.toString())
|
peertubeLocalStorage.setItem(AuthUser.KEYS.NSFW_POLICY, this.nsfwPolicy.toString())
|
||||||
|
peertubeLocalStorage.setItem(AuthUser.KEYS.WEBTORRENT_POLICY, this.webTorrentPolicy.toString())
|
||||||
peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo))
|
peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo))
|
||||||
this.tokens.save()
|
this.tokens.save()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {
|
||||||
import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
|
import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
|
||||||
import { Account } from '@app/shared/account/account.model'
|
import { Account } from '@app/shared/account/account.model'
|
||||||
import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
|
import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
|
||||||
|
import { WebTorrentPolicyType } from '../../../../../shared/models/users/user-webtorrent-policy.type'
|
||||||
|
|
||||||
export type UserConstructorHash = {
|
export type UserConstructorHash = {
|
||||||
id: number,
|
id: number,
|
||||||
|
@ -18,6 +19,7 @@ export type UserConstructorHash = {
|
||||||
videoQuota?: number,
|
videoQuota?: number,
|
||||||
videoQuotaDaily?: number,
|
videoQuotaDaily?: number,
|
||||||
nsfwPolicy?: NSFWPolicyType,
|
nsfwPolicy?: NSFWPolicyType,
|
||||||
|
webTorrentPolicy?: WebTorrentPolicyType,
|
||||||
autoPlayVideo?: boolean,
|
autoPlayVideo?: boolean,
|
||||||
createdAt?: Date,
|
createdAt?: Date,
|
||||||
account?: AccountServerModel,
|
account?: AccountServerModel,
|
||||||
|
@ -32,6 +34,7 @@ export class User implements UserServerModel {
|
||||||
email: string
|
email: string
|
||||||
role: UserRole
|
role: UserRole
|
||||||
nsfwPolicy: NSFWPolicyType
|
nsfwPolicy: NSFWPolicyType
|
||||||
|
webTorrentPolicy: WebTorrentPolicyType
|
||||||
autoPlayVideo: boolean
|
autoPlayVideo: boolean
|
||||||
videoQuota: number
|
videoQuota: number
|
||||||
videoQuotaDaily: number
|
videoQuotaDaily: number
|
||||||
|
@ -52,6 +55,7 @@ export class User implements UserServerModel {
|
||||||
this.videoQuota = hash.videoQuota
|
this.videoQuota = hash.videoQuota
|
||||||
this.videoQuotaDaily = hash.videoQuotaDaily
|
this.videoQuotaDaily = hash.videoQuotaDaily
|
||||||
this.nsfwPolicy = hash.nsfwPolicy
|
this.nsfwPolicy = hash.nsfwPolicy
|
||||||
|
this.webTorrentPolicy = hash.webTorrentPolicy
|
||||||
this.autoPlayVideo = hash.autoPlayVideo
|
this.autoPlayVideo = hash.autoPlayVideo
|
||||||
this.createdAt = hash.createdAt
|
this.createdAt = hash.createdAt
|
||||||
this.blocked = hash.blocked
|
this.blocked = hash.blocked
|
||||||
|
|
|
@ -10,6 +10,15 @@ function getStoredVolume () {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getStoredWebTorrentPolicy () {
|
||||||
|
const value = getLocalStorage('webtorrent_policy')
|
||||||
|
if (value !== null && value !== undefined) {
|
||||||
|
if (value.toString() === 'disable') return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
function getStoredMute () {
|
function getStoredMute () {
|
||||||
const value = getLocalStorage('mute')
|
const value = getLocalStorage('mute')
|
||||||
if (value !== null && value !== undefined) return value === 'true'
|
if (value !== null && value !== undefined) return value === 'true'
|
||||||
|
@ -56,6 +65,7 @@ function getAverageBandwidthInStore () {
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getStoredVolume,
|
getStoredVolume,
|
||||||
|
getStoredWebTorrentPolicy,
|
||||||
getStoredMute,
|
getStoredMute,
|
||||||
getStoredTheater,
|
getStoredTheater,
|
||||||
saveVolumeInStore,
|
saveVolumeInStore,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { isMobile, timeToInt, videoFileMaxByResolution, videoFileMinByResolution
|
||||||
import * as CacheChunkStore from 'cache-chunk-store'
|
import * as CacheChunkStore from 'cache-chunk-store'
|
||||||
import { PeertubeChunkStore } from './peertube-chunk-store'
|
import { PeertubeChunkStore } from './peertube-chunk-store'
|
||||||
import {
|
import {
|
||||||
|
getStoredWebTorrentPolicy,
|
||||||
getAverageBandwidthInStore,
|
getAverageBandwidthInStore,
|
||||||
getStoredMute,
|
getStoredMute,
|
||||||
getStoredVolume,
|
getStoredVolume,
|
||||||
|
@ -64,6 +65,7 @@ class PeerTubePlugin extends Plugin {
|
||||||
private autoResolution = true
|
private autoResolution = true
|
||||||
private forbidAutoResolution = false
|
private forbidAutoResolution = false
|
||||||
private isAutoResolutionObservation = false
|
private isAutoResolutionObservation = false
|
||||||
|
private playerRefusedP2P = false
|
||||||
|
|
||||||
private videoViewInterval
|
private videoViewInterval
|
||||||
private torrentInfoInterval
|
private torrentInfoInterval
|
||||||
|
@ -97,6 +99,7 @@ class PeerTubePlugin extends Plugin {
|
||||||
if (volume !== undefined) this.player.volume(volume)
|
if (volume !== undefined) this.player.volume(volume)
|
||||||
const muted = getStoredMute()
|
const muted = getStoredMute()
|
||||||
if (muted !== undefined) this.player.muted(muted)
|
if (muted !== undefined) this.player.muted(muted)
|
||||||
|
this.playerRefusedP2P = getStoredWebTorrentPolicy() || false
|
||||||
|
|
||||||
this.initializePlayer()
|
this.initializePlayer()
|
||||||
this.runTorrentInfoScheduler()
|
this.runTorrentInfoScheduler()
|
||||||
|
@ -288,7 +291,8 @@ class PeerTubePlugin extends Plugin {
|
||||||
renderVideo(torrent.files[ 0 ], this.playerElement, renderVideoOptions, (err, renderer) => {
|
renderVideo(torrent.files[ 0 ], this.playerElement, renderVideoOptions, (err, renderer) => {
|
||||||
this.renderer = renderer
|
this.renderer = renderer
|
||||||
|
|
||||||
if (err) return this.fallbackToHttp(done)
|
console.log('value this.playerRefusedP2P', this.playerRefusedP2P)
|
||||||
|
if (err || this.playerRefusedP2P) return this.fallbackToHttp(done)
|
||||||
|
|
||||||
return this.tryToPlay(err => {
|
return this.tryToPlay(err => {
|
||||||
if (err) return done(err)
|
if (err) return done(err)
|
||||||
|
|
|
@ -327,6 +327,7 @@ async function updateMe (req: express.Request, res: express.Response, next: expr
|
||||||
if (body.password !== undefined) user.password = body.password
|
if (body.password !== undefined) user.password = body.password
|
||||||
if (body.email !== undefined) user.email = body.email
|
if (body.email !== undefined) user.email = body.email
|
||||||
if (body.nsfwPolicy !== undefined) user.nsfwPolicy = body.nsfwPolicy
|
if (body.nsfwPolicy !== undefined) user.nsfwPolicy = body.nsfwPolicy
|
||||||
|
if (body.webTorrentPolicy !== undefined) user.webTorrentPolicy = body.webTorrentPolicy
|
||||||
if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo
|
if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo
|
||||||
|
|
||||||
await sequelizeTypescript.transaction(async t => {
|
await sequelizeTypescript.transaction(async t => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'express-validator'
|
import 'express-validator'
|
||||||
import * as validator from 'validator'
|
import * as validator from 'validator'
|
||||||
import { UserRole } from '../../../shared'
|
import { UserRole } from '../../../shared'
|
||||||
import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers'
|
import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES, WEBTORRENT_POLICY_TYPES } from '../../initializers'
|
||||||
import { exists, isFileValid, isBooleanValid } from './misc'
|
import { exists, isFileValid, isBooleanValid } from './misc'
|
||||||
import { values } from 'lodash'
|
import { values } from 'lodash'
|
||||||
|
|
||||||
|
@ -42,6 +42,11 @@ function isUserNSFWPolicyValid (value: any) {
|
||||||
return exists(value) && nsfwPolicies.indexOf(value) !== -1
|
return exists(value) && nsfwPolicies.indexOf(value) !== -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const webTorrentPolicies = values(WEBTORRENT_POLICY_TYPES)
|
||||||
|
function isUserWebTorrentPolicyValid (value: any) {
|
||||||
|
return exists(value) && webTorrentPolicies.indexOf(value) !== -1
|
||||||
|
}
|
||||||
|
|
||||||
function isUserAutoPlayVideoValid (value: any) {
|
function isUserAutoPlayVideoValid (value: any) {
|
||||||
return isBooleanValid(value)
|
return isBooleanValid(value)
|
||||||
}
|
}
|
||||||
|
@ -78,6 +83,7 @@ export {
|
||||||
isUserUsernameValid,
|
isUserUsernameValid,
|
||||||
isUserEmailVerifiedValid,
|
isUserEmailVerifiedValid,
|
||||||
isUserNSFWPolicyValid,
|
isUserNSFWPolicyValid,
|
||||||
|
isUserWebTorrentPolicyValid,
|
||||||
isUserAutoPlayVideoValid,
|
isUserAutoPlayVideoValid,
|
||||||
isUserDisplayNameValid,
|
isUserDisplayNameValid,
|
||||||
isUserDescriptionValid,
|
isUserDescriptionValid,
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS }
|
||||||
// Do not use barrels, remain constants as independent as possible
|
// Do not use barrels, remain constants as independent as possible
|
||||||
import { buildPath, isTestInstance, parseDuration, parseBytes, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
|
import { buildPath, isTestInstance, parseDuration, parseBytes, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
|
||||||
import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
|
import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
|
||||||
|
import { WebTorrentPolicyType } from '../../shared/models/users/user-webtorrent-policy.type'
|
||||||
import { invert } from 'lodash'
|
import { invert } from 'lodash'
|
||||||
import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
|
import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
|
||||||
import * as bytes from 'bytes'
|
import * as bytes from 'bytes'
|
||||||
|
@ -16,7 +17,7 @@ let config: IConfig = require('config')
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
const LAST_MIGRATION_VERSION = 275
|
const LAST_MIGRATION_VERSION = 280
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -546,6 +547,12 @@ const NSFW_POLICY_TYPES: { [ id: string]: NSFWPolicyType } = {
|
||||||
DISPLAY: 'display'
|
DISPLAY: 'display'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const WEBTORRENT_POLICY_TYPES: { [ id: string]: WebTorrentPolicyType } = {
|
||||||
|
ENABLE: 'enable',
|
||||||
|
DISABLE: 'disable',
|
||||||
|
DISABLE_ON_MOBILE: 'disable_on_mobile'
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
// Express static paths (router)
|
// Express static paths (router)
|
||||||
|
@ -698,6 +705,7 @@ export {
|
||||||
FEEDS,
|
FEEDS,
|
||||||
JOB_TTL,
|
JOB_TTL,
|
||||||
NSFW_POLICY_TYPES,
|
NSFW_POLICY_TYPES,
|
||||||
|
WEBTORRENT_POLICY_TYPES,
|
||||||
TORRENT_MIMETYPE_EXT,
|
TORRENT_MIMETYPE_EXT,
|
||||||
STATIC_MAX_AGE,
|
STATIC_MAX_AGE,
|
||||||
STATIC_PATHS,
|
STATIC_PATHS,
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
import * as Sequelize from 'sequelize'
|
||||||
|
import { values } from 'lodash'
|
||||||
|
import { WEBTORRENT_POLICY_TYPES } from '../constants'
|
||||||
|
|
||||||
|
async function up (utils: {
|
||||||
|
transaction: Sequelize.Transaction
|
||||||
|
queryInterface: Sequelize.QueryInterface
|
||||||
|
sequelize: Sequelize.Sequelize
|
||||||
|
}): Promise<any> {
|
||||||
|
{
|
||||||
|
const data = {
|
||||||
|
type: Sequelize.ENUM(values(WEBTORRENT_POLICY_TYPES)),
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: 'enable'
|
||||||
|
}
|
||||||
|
|
||||||
|
await utils.queryInterface.addColumn('user', 'webTorrentPolicy', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function down (options) {
|
||||||
|
throw new Error('Not implemented.')
|
||||||
|
}
|
||||||
|
|
||||||
|
export { up, down }
|
|
@ -31,7 +31,8 @@ import {
|
||||||
isUserRoleValid,
|
isUserRoleValid,
|
||||||
isUserUsernameValid,
|
isUserUsernameValid,
|
||||||
isUserVideoQuotaDailyValid,
|
isUserVideoQuotaDailyValid,
|
||||||
isUserVideoQuotaValid
|
isUserVideoQuotaValid,
|
||||||
|
isUserWebTorrentPolicyValid
|
||||||
} from '../../helpers/custom-validators/users'
|
} from '../../helpers/custom-validators/users'
|
||||||
import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto'
|
import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto'
|
||||||
import { OAuthTokenModel } from '../oauth/oauth-token'
|
import { OAuthTokenModel } from '../oauth/oauth-token'
|
||||||
|
@ -39,8 +40,9 @@ import { getSort, throwIfNotValid } from '../utils'
|
||||||
import { VideoChannelModel } from '../video/video-channel'
|
import { VideoChannelModel } from '../video/video-channel'
|
||||||
import { AccountModel } from './account'
|
import { AccountModel } from './account'
|
||||||
import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type'
|
import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type'
|
||||||
|
import { WebTorrentPolicyType } from '../../../shared/models/users/user-webtorrent-policy.type'
|
||||||
import { values } from 'lodash'
|
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'
|
import { clearCacheByUserId } from '../../lib/oauth-model'
|
||||||
|
|
||||||
enum ScopeNames {
|
enum ScopeNames {
|
||||||
|
@ -107,6 +109,11 @@ export class UserModel extends Model<UserModel> {
|
||||||
@Column(DataType.ENUM(values(NSFW_POLICY_TYPES)))
|
@Column(DataType.ENUM(values(NSFW_POLICY_TYPES)))
|
||||||
nsfwPolicy: NSFWPolicyType
|
nsfwPolicy: NSFWPolicyType
|
||||||
|
|
||||||
|
@AllowNull(false)
|
||||||
|
@Is('UserWebTorrentPolicy', value => throwIfNotValid(value, isUserWebTorrentPolicyValid, 'WebTorrent policy'))
|
||||||
|
@Column(DataType.ENUM(values(WEBTORRENT_POLICY_TYPES)))
|
||||||
|
webTorrentPolicy: WebTorrentPolicyType
|
||||||
|
|
||||||
@AllowNull(false)
|
@AllowNull(false)
|
||||||
@Default(true)
|
@Default(true)
|
||||||
@Is('UserAutoPlayVideo', value => throwIfNotValid(value, isUserAutoPlayVideoValid, 'auto play video boolean'))
|
@Is('UserAutoPlayVideo', value => throwIfNotValid(value, isUserAutoPlayVideoValid, 'auto play video boolean'))
|
||||||
|
@ -355,6 +362,7 @@ export class UserModel extends Model<UserModel> {
|
||||||
email: this.email,
|
email: this.email,
|
||||||
emailVerified: this.emailVerified,
|
emailVerified: this.emailVerified,
|
||||||
nsfwPolicy: this.nsfwPolicy,
|
nsfwPolicy: this.nsfwPolicy,
|
||||||
|
webTorrentPolicy: this.webTorrentPolicy,
|
||||||
autoPlayVideo: this.autoPlayVideo,
|
autoPlayVideo: this.autoPlayVideo,
|
||||||
role: this.role,
|
role: this.role,
|
||||||
roleLabel: USER_ROLE_LABELS[ this.role ],
|
roleLabel: USER_ROLE_LABELS[ this.role ],
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import { NSFWPolicyType } from '../videos/nsfw-policy.type'
|
import { NSFWPolicyType } from '../videos/nsfw-policy.type'
|
||||||
|
import { WebTorrentPolicyType } from './user-webtorrent-policy.type'
|
||||||
|
|
||||||
export interface UserUpdateMe {
|
export interface UserUpdateMe {
|
||||||
displayName?: string
|
displayName?: string
|
||||||
description?: string
|
description?: string
|
||||||
nsfwPolicy?: NSFWPolicyType
|
nsfwPolicy?: NSFWPolicyType,
|
||||||
|
webTorrentPolicy?: WebTorrentPolicyType,
|
||||||
autoPlayVideo?: boolean
|
autoPlayVideo?: boolean
|
||||||
email?: string
|
email?: string
|
||||||
currentPassword?: string
|
currentPassword?: string
|
||||||
|
|
1
shared/models/users/user-webtorrent-policy.type.ts
Normal file
1
shared/models/users/user-webtorrent-policy.type.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export type WebTorrentPolicyType = 'enable' | 'disable' | 'disable_on_mobile'
|
Loading…
Add table
Reference in a new issue