aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorAndréas Livet <andreas.livet@gmail.com>2017-12-19 10:45:49 +0100
committerChocobozzz <me@florianbigard.com>2017-12-19 10:45:49 +0100
commit7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd (patch)
tree56116e7e9f8467b78ed6dfc81827288915d31c8c /server/helpers/custom-validators
parent228077efd73485a2832bb6211c9fa923158c2112 (diff)
downloadPeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.tar.gz
PeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.tar.zst
PeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.zip
Enh #106 : Add an autoPlayVideo user attribute (#159)
Warning : I was not able to run the tests on my machine. It uses a different approach to handle databse connexion and didn't find where to configure it... - create a migration file to add a boolean column in user table - add autoPlayVideo attribute everywhere it is needed (both on client and server side) - add tests - add a way to configure this attribute in account-settings - use the attribute in video-watch component to actually autoplay or not the video
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/users.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts
index b5b5642d6..159c2a700 100644
--- a/server/helpers/custom-validators/users.ts
+++ b/server/helpers/custom-validators/users.ts
@@ -21,10 +21,18 @@ function isUserUsernameValid (value: string) {
21 return exists(value) && validator.matches(value, new RegExp(`^[a-z0-9._]{${min},${max}}$`)) 21 return exists(value) && validator.matches(value, new RegExp(`^[a-z0-9._]{${min},${max}}$`))
22} 22}
23 23
24function isUserDisplayNSFWValid (value: any) { 24function isBoolean (value: any) {
25 return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) 25 return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value))
26} 26}
27 27
28function isUserDisplayNSFWValid (value: any) {
29 return isBoolean(value)
30}
31
32function isUserAutoPlayVideoValid (value: any) {
33 return isBoolean(value)
34}
35
28function isUserRoleValid (value: any) { 36function isUserRoleValid (value: any) {
29 return exists(value) && validator.isInt('' + value) && UserRole[value] !== undefined 37 return exists(value) && validator.isInt('' + value) && UserRole[value] !== undefined
30} 38}
@@ -36,5 +44,6 @@ export {
36 isUserRoleValid, 44 isUserRoleValid,
37 isUserVideoQuotaValid, 45 isUserVideoQuotaValid,
38 isUserUsernameValid, 46 isUserUsernameValid,
39 isUserDisplayNSFWValid 47 isUserDisplayNSFWValid,
48 isUserAutoPlayVideoValid
40} 49}