pull/6788/merge
Khyvodul 2025-01-07 10:48:20 +08:00 committed by GitHub
commit f1b279496d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 35 additions and 9 deletions

View File

@ -256,6 +256,18 @@
</ng-container>
</ng-container>
</div>
<div class="form-group">
<my-peertube-checkbox
inputName="userPlaybackAutoStart" formControlName="playbackAutoStart"
i18n-labelText labelText="Enable playback automatic start by default for new users"
>
<ng-container ngProjectAs="description">
<span i18n>Video playback starts automatically when opening a video (can be overridden by user's settings)</span>
</ng-container>
</my-peertube-checkbox>
</div>
</ng-container>
</div>

View File

@ -219,7 +219,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
}
},
videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR
videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR,
playbackAutoStart: null
},
videoChannels: {
maxPerUser: MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR

View File

@ -107,6 +107,7 @@ export class UserLocalStorageService {
const defaultNSFWPolicy = htmlConfig.instance.defaultNSFWPolicy
const defaultP2PEnabled = htmlConfig.defaults.p2p.webapp.enabled
const defaultPlaybackAutoStart = htmlConfig.user.playbackAutoStart
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), defaultPlaybackAutoStart),
autoPlayNextVideo: getBoolOrDefault(this.localStorageService.getItem(UserLocalStorageKeys.AUTO_PLAY_NEXT_VIDEO), false),
autoPlayNextVideoPlaylist: getBoolOrDefault(this.localStorageService.getItem(UserLocalStorageKeys.AUTO_PLAY_VIDEO_PLAYLIST), true)
}

View File

@ -571,6 +571,9 @@ user:
default_channel_name: 'Main $1 channel' # The placeholder $1 is used to represent the user's username
# By default, playback starts automatically when opening a video for a new user or when anonymous
playback_auto_start: true
video_channels:
max_per_user: 20 # Allows each user to create up to 20 video channels.

View File

@ -109,6 +109,7 @@ export interface CustomConfig {
videoQuota: number
videoQuotaDaily: number
defaultChannelName: string
playbackAutoStart: boolean
}
videoChannels: {

View File

@ -285,6 +285,7 @@ export interface ServerConfig {
user: {
videoQuota: number
videoQuotaDaily: number
playbackAutoStart: boolean
}
videoChannels: {

View File

@ -236,6 +236,7 @@ describe('Test config defaults', function () {
expect(config.user.videoQuota).to.equal(-1)
expect(config.user.videoQuotaDaily).to.equal(-1)
expect(config.user.playbackAutoStart).to.equal(true)
const user1Token = await server.users.generateUserAndToken('user1')
const user1 = await server.users.getMyInfo({ token: user1Token })
@ -263,7 +264,8 @@ describe('Test config defaults', function () {
}
},
videoQuota : 5242881,
videoQuotaDaily: 318742
videoQuotaDaily: 318742,
playbackAutoStart: false
},
signup: {
enabled: true,
@ -285,6 +287,7 @@ describe('Test config defaults', function () {
expect(user.videosHistoryEnabled).to.be.false
expect(user.videoQuota).to.equal(5242881)
expect(user.videoQuotaDaily).to.equal(318742)
expect(user.autoPlayVideo).to.equal(false)
}
})

View File

@ -227,7 +227,8 @@ function buildNewCustomConfig (server: PeerTubeServer): CustomConfig {
},
videoQuota: 5242881,
videoQuotaDaily: 318742,
defaultChannelName: 'Main $1 channel'
defaultChannelName: 'Main $1 channel',
playbackAutoStart: true
},
videoChannels: {
maxPerUser: 24

View File

@ -313,7 +313,8 @@ function customConfig (): CustomConfig {
},
videoQuota: CONFIG.USER.VIDEO_QUOTA,
videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY,
defaultChannelName: CONFIG.USER.DEFAULT_CHANNEL_NAME
defaultChannelName: CONFIG.USER.DEFAULT_CHANNEL_NAME,
playbackAutoStart: CONFIG.USER.PLAYBACK_AUTO_START
},
videoChannels: {
maxPerUser: CONFIG.VIDEO_CHANNELS.MAX_PER_USER

View File

@ -23,7 +23,7 @@ function checkMissedConfig () {
'open_telemetry.metrics.prometheus_exporter.hostname', 'open_telemetry.metrics.prometheus_exporter.port',
'open_telemetry.tracing.enabled', 'open_telemetry.tracing.jaeger_exporter.endpoint',
'open_telemetry.metrics.http_request_duration.enabled',
'user.history.videos.enabled', 'user.video_quota', 'user.video_quota_daily',
'user.history.videos.enabled', 'user.video_quota', 'user.video_quota_daily', 'user.playback_auto_start',
'video_channels.max_per_user',
'csp.enabled', 'csp.report_only', 'csp.report_uri',
'security.frameguard.enabled', 'security.powered_by_header.enabled',

View File

@ -425,7 +425,8 @@ const CONFIG = {
},
get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) },
get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) },
get DEFAULT_CHANNEL_NAME () { return config.get<string>('user.default_channel_name') }
get DEFAULT_CHANNEL_NAME () { return config.get<string>('user.default_channel_name') },
get PLAYBACK_AUTO_START () { return config.has('user.playback_auto_start') ? config.get<boolean>('user.playback_auto_start') : true }
},
VIDEO_CHANNELS: {
get MAX_PER_USER () { return config.get<number>('video_channels.max_per_user') }

View File

@ -265,7 +265,8 @@ class ServerConfigManager {
},
user: {
videoQuota: CONFIG.USER.VIDEO_QUOTA,
videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY
videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY,
playbackAutoStart: CONFIG.USER.PLAYBACK_AUTO_START
},
videoChannels: {
maxPerUser: CONFIG.VIDEO_CHANNELS.MAX_PER_USER

View File

@ -65,7 +65,7 @@ function buildUser (options: {
p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED,
videosHistoryEnabled: CONFIG.USER.HISTORY.VIDEOS.ENABLED,
autoPlayVideo: true,
autoPlayVideo: CONFIG.USER.PLAYBACK_AUTO_START,
role,
emailVerified,