<div *ngIf="formErrors.user.videoQuotaDaily" class="form-error">{{ formErrors.user.videoQuotaDaily }}</div>
</div>
+ <div class="form-group">
+ <ng-container formGroupName="history">
+ <ng-container formGroupName="videos">
+ <my-peertube-checkbox
+ inputName="videosHistoryEnabled" formControlName="enabled"
+ i18n-labelText labelText="Automatically enable video history for new users"
+ >
+ </my-peertube-checkbox>
+ </ng-container>
+ </ng-container>
+ </div>
</ng-container>
</div>
enabled: null
},
user: {
+ history: {
+ videos: {
+ enabled: null
+ }
+ },
videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR
},
blacklist: []
user:
+ history:
+ videos:
+ # Enable or disable video history by default for new users.
+ enabled: true
# Default value of maximum video bytes the user can upload (does not take into account transcoded files)
# Byte format is supported ("1GB" etc)
# -1 == unlimited
whitelist: []
blacklist: []
-user:
+user:
+ history:
+ videos:
+ # Enable or disable video history by default for new users.
+ enabled: true
# Default value of maximum video bytes the user can upload (does not take into account transcoded files)
# Byte format is supported ("1GB" etc)
# -1 == unlimited
enabled: CONFIG.CONTACT_FORM.ENABLED
},
user: {
+ history: {
+ videos: {
+ enabled: CONFIG.USER.HISTORY.VIDEOS.ENABLED
+ }
+ },
videoQuota: CONFIG.USER.VIDEO_QUOTA,
videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY
},
'open_telemetry.metrics.enabled', '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.video_quota', 'user.video_quota_daily',
+ 'user.history.videos.enabled', 'user.video_quota', 'user.video_quota_daily',
'video_channels.max_per_user',
'csp.enabled', 'csp.report_only', 'csp.report_uri',
'security.frameguard.enabled', 'security.powered_by_header.enabled',
}
},
USER: {
+ HISTORY: {
+ VIDEOS: {
+ get ENABLED () { return config.get<boolean>('user.history.videos.enabled') }
+ }
+ },
get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) },
get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) }
},
nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED,
+ videosHistoryEnabled: CONFIG.USER.HISTORY.VIDEOS.ENABLED,
+
autoPlayVideo: true,
role,
body('admin.email').isEmail(),
body('contactForm.enabled').isBoolean(),
+ body('user.history.videos.enabled').isBoolean(),
body('user.videoQuota').custom(isUserVideoQuotaValid),
body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid),
.custom(isVideoChannelUsernameValid),
body('videoQuota')
+ .optional()
.custom(isUserVideoQuotaValid),
+
body('videoQuotaDaily')
+ .optional()
.custom(isUserVideoQuotaDailyValid),
body('role')
enabled: false
},
user: {
+ history: {
+ videos: {
+ enabled: true
+ }
+ },
videoQuota: 5242881,
videoQuotaDaily: 318742
},
})
})
- it('Should fail without a videoQuota', async function () {
- const fields = omit(baseCorrectParams, [ 'videoQuota' ])
-
- await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
- })
-
- it('Should fail without a videoQuotaDaily', async function () {
- const fields = omit(baseCorrectParams, [ 'videoQuotaDaily' ])
-
- await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
- })
-
it('Should fail with an invalid videoQuota', async function () {
const fields = { ...baseCorrectParams, videoQuota: -5 }
})
})
+ describe('Default user attributes', function () {
+ it('Should create a user and register a user with the default config', async function () {
+ await server.config.updateCustomSubConfig({
+ newConfig: {
+ user: {
+ history: {
+ videos: {
+ enabled: true
+ }
+ },
+ videoQuota : -1,
+ videoQuotaDaily: -1
+ },
+ signup: {
+ enabled: true,
+ requiresApproval: false
+ }
+ }
+ })
+
+ const config = await server.config.getConfig()
+
+ expect(config.user.videoQuota).to.equal(-1)
+ expect(config.user.videoQuotaDaily).to.equal(-1)
+
+ const user1Token = await server.users.generateUserAndToken('user1')
+ const user1 = await server.users.getMyInfo({ token: user1Token })
+
+ const user = { displayName: 'super user 2', username: 'user2', password: 'super password' }
+ const channel = { name: 'my_user_2_channel', displayName: 'my channel' }
+ await server.registrations.register({ ...user, channel })
+ const user2Token = await server.login.getAccessToken(user)
+ const user2 = await server.users.getMyInfo({ token: user2Token })
+
+ for (const user of [ user1, user2 ]) {
+ expect(user.videosHistoryEnabled).to.be.true
+ expect(user.videoQuota).to.equal(-1)
+ expect(user.videoQuotaDaily).to.equal(-1)
+ }
+ })
+
+ it('Should update config and create a user and register a user with the new default config', async function () {
+ await server.config.updateCustomSubConfig({
+ newConfig: {
+ user: {
+ history: {
+ videos: {
+ enabled: false
+ }
+ },
+ videoQuota : 5242881,
+ videoQuotaDaily: 318742
+ },
+ signup: {
+ enabled: true,
+ requiresApproval: false
+ }
+ }
+ })
+
+ const user3Token = await server.users.generateUserAndToken('user3')
+ const user3 = await server.users.getMyInfo({ token: user3Token })
+
+ const user = { displayName: 'super user 4', username: 'user4', password: 'super password' }
+ const channel = { name: 'my_user_4_channel', displayName: 'my channel' }
+ await server.registrations.register({ ...user, channel })
+ const user4Token = await server.login.getAccessToken(user)
+ const user4 = await server.users.getMyInfo({ token: user4Token })
+
+ for (const user of [ user3, user4 ]) {
+ expect(user.videosHistoryEnabled).to.be.false
+ expect(user.videoQuota).to.equal(5242881)
+ expect(user.videoQuotaDaily).to.equal(318742)
+ }
+ })
+
+ })
+
after(async function () {
await cleanupTests([ server ])
})
expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(data.contactForm.enabled).to.be.true
+ expect(data.user.history.videos.enabled).to.be.true
expect(data.user.videoQuota).to.equal(5242880)
expect(data.user.videoQuotaDaily).to.equal(-1)
expect(data.contactForm.enabled).to.be.false
+ expect(data.user.history.videos.enabled).to.be.false
expect(data.user.videoQuota).to.equal(5242881)
expect(data.user.videoQuotaDaily).to.equal(318742)
enabled: false
},
user: {
+ history: {
+ videos: {
+ enabled: false
+ }
+ },
videoQuota: 5242881,
videoQuotaDaily: 318742
},
}
user: {
+ history: {
+ videos: {
+ enabled: boolean
+ }
+ }
videoQuota: number
videoQuotaDaily: number
}
isDefaultSearch: boolean
}
}
+
}
enabled: true
},
user: {
+ history: {
+ videos: {
+ enabled: true
+ }
+ },
videoQuota: 5242881,
videoQuotaDaily: 318742
},
username,
adminFlags,
password = 'password',
- videoQuota = 42000000,
- videoQuotaDaily = -1,
+ videoQuota,
+ videoQuotaDaily,
role = UserRole.USER
} = options
- username
- password
- email
- - videoQuota
- - videoQuotaDaily
- role
UpdateUser:
properties: