feat: 6167 Add autoplay setting in the admin settings section (#6788)
* feat-6167: Add autoplay setting for new users in GUI admin section
* feat-6167: Add new localization for admin GUI
* Fix user configuration not taking default auto play setting into account when creating a new user
* Revert "feat-6167: Add new localization for admin GUI"
This reverts commit fcdb05c8ea
.
* Move autoplay in defaults section
---------
Co-authored-by: Chocobozzz <me@florianbigard.com>
This commit is contained in:
parent
e4b6021310
commit
1a568cc65c
|
@ -107,6 +107,7 @@ export class UserLocalStorageService {
|
|||
|
||||
const defaultNSFWPolicy = htmlConfig.instance.defaultNSFWPolicy
|
||||
const defaultP2PEnabled = htmlConfig.defaults.p2p.webapp.enabled
|
||||
const defaultAutoPlay = htmlConfig.defaults.player.autoPlay
|
||||
|
||||
return {
|
||||
nsfwPolicy: this.localStorageService.getItem<NSFWPolicyType>(UserLocalStorageKeys.NSFW_POLICY) || defaultNSFWPolicy,
|
||||
|
@ -114,7 +115,7 @@ export class UserLocalStorageService {
|
|||
theme: this.localStorageService.getItem(UserLocalStorageKeys.THEME) || 'instance-default',
|
||||
videoLanguages,
|
||||
|
||||
autoPlayVideo: getBoolOrDefault(this.localStorageService.getItem(UserLocalStorageKeys.AUTO_PLAY_VIDEO), true),
|
||||
autoPlayVideo: getBoolOrDefault(this.localStorageService.getItem(UserLocalStorageKeys.AUTO_PLAY_VIDEO), defaultAutoPlay),
|
||||
autoPlayNextVideo: getBoolOrDefault(this.localStorageService.getItem(UserLocalStorageKeys.AUTO_PLAY_NEXT_VIDEO), false),
|
||||
autoPlayNextVideoPlaylist: getBoolOrDefault(this.localStorageService.getItem(UserLocalStorageKeys.AUTO_PLAY_VIDEO_PLAYLIST), true)
|
||||
}
|
||||
|
|
|
@ -150,6 +150,10 @@ defaults:
|
|||
embed:
|
||||
enabled: true
|
||||
|
||||
player:
|
||||
# By default, playback starts automatically when opening a video
|
||||
auto_play: true
|
||||
|
||||
# From the project root directory
|
||||
storage:
|
||||
tmp: 'storage/tmp/' # Use to download data (imports etc), store uploaded files before and during processing...
|
||||
|
|
|
@ -148,6 +148,10 @@ defaults:
|
|||
embed:
|
||||
enabled: true
|
||||
|
||||
player:
|
||||
# By default, playback starts automatically when opening a video
|
||||
auto_play: true
|
||||
|
||||
# From the project root directory
|
||||
storage:
|
||||
tmp: '/var/www/peertube/storage/tmp/' # Use to download data (imports etc), store uploaded files before and during processing...
|
||||
|
|
|
@ -74,6 +74,10 @@ export interface ServerConfig {
|
|||
enabled: boolean
|
||||
}
|
||||
}
|
||||
|
||||
player: {
|
||||
autoPlay: boolean
|
||||
}
|
||||
}
|
||||
|
||||
webadmin: {
|
||||
|
|
|
@ -212,7 +212,50 @@ describe('Test config defaults', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('Default player value', function () {
|
||||
|
||||
before(async function () {
|
||||
const overrideConfig = {
|
||||
defaults: {
|
||||
player: {
|
||||
auto_play: false
|
||||
}
|
||||
},
|
||||
signup: {
|
||||
limit: 15
|
||||
}
|
||||
}
|
||||
|
||||
await server.kill()
|
||||
await server.run(overrideConfig)
|
||||
})
|
||||
|
||||
it('Should have appropriate autoplay config', async function () {
|
||||
const config = await server.config.getConfig()
|
||||
|
||||
expect(config.defaults.player.autoPlay).to.be.false
|
||||
})
|
||||
|
||||
it('Should create a user with this default setting', async function () {
|
||||
await server.users.create({ username: 'user_autoplay_1' })
|
||||
const userToken = await server.login.getAccessToken('user_autoplay_1')
|
||||
|
||||
const { autoPlayVideo } = await server.users.getMyInfo({ token: userToken })
|
||||
expect(autoPlayVideo).to.be.false
|
||||
})
|
||||
|
||||
it('Should register a user with this default setting', async function () {
|
||||
await server.registrations.register({ username: 'user_autoplay_2' })
|
||||
|
||||
const userToken = await server.login.getAccessToken('user_autoplay_2')
|
||||
|
||||
const { autoPlayVideo } = await server.users.getMyInfo({ token: userToken })
|
||||
expect(autoPlayVideo).to.be.false
|
||||
})
|
||||
})
|
||||
|
||||
describe('Default user attributes', function () {
|
||||
|
||||
it('Should create a user and register a user with the default config', async function () {
|
||||
await server.config.updateExistingConfig({
|
||||
newConfig: {
|
||||
|
|
|
@ -50,6 +50,7 @@ function checkMissedConfig () {
|
|||
'auto_blacklist.videos.of_users.enabled', 'trending.videos.interval_days',
|
||||
'client.videos.miniature.prefer_author_display_name', 'client.menu.login.redirect_on_single_external_auth',
|
||||
'defaults.publish.download_enabled', 'defaults.publish.comments_policy', 'defaults.publish.privacy', 'defaults.publish.licence',
|
||||
'defaults.player.auto_play',
|
||||
'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route',
|
||||
'instance.is_nsfw', 'instance.default_nsfw_policy', 'instance.robots', 'instance.securitytxt',
|
||||
'instance.server_country', 'instance.support.text', 'instance.social.external_link', 'instance.social.mastodon_link',
|
||||
|
|
|
@ -104,6 +104,9 @@ const CONFIG = {
|
|||
EMBED: {
|
||||
ENABLED: config.get<boolean>('defaults.p2p.embed.enabled')
|
||||
}
|
||||
},
|
||||
PLAYER: {
|
||||
get AUTO_PLAY () { return config.get<boolean>('defaults.player.auto_play') }
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -87,6 +87,9 @@ class ServerConfigManager {
|
|||
embed: {
|
||||
enabled: CONFIG.DEFAULTS.P2P.EMBED.ENABLED
|
||||
}
|
||||
},
|
||||
player: {
|
||||
autoPlay: CONFIG.DEFAULTS.PLAYER.AUTO_PLAY
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ function buildUser (options: {
|
|||
p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED,
|
||||
videosHistoryEnabled: CONFIG.USER.HISTORY.VIDEOS.ENABLED,
|
||||
|
||||
autoPlayVideo: true,
|
||||
autoPlayVideo: CONFIG.DEFAULTS.PLAYER.AUTO_PLAY,
|
||||
|
||||
role,
|
||||
emailVerified,
|
||||
|
|
Loading…
Reference in New Issue