2
0
Fork 0

raise poll choice limit to 20 and allow polls from 1 second to 1000 years

This commit is contained in:
notfire 2025-01-02 21:10:43 -05:00
commit a9bdf9c281
No known key found for this signature in database
GPG key ID: 3AFDACAAB4E56B16
2 changed files with 8 additions and 4 deletions

View file

@ -35,7 +35,7 @@ export default {
return this.pollLimits.max_option_chars
},
expiryUnits () {
const allUnits = ['minutes', 'hours', 'days']
const allUnits = ['seconds', 'minutes', 'hours', 'days', 'years']
const expiry = this.convertExpiryFromUnit
return allUnits.filter(
unit => this.pollLimits.max_expiration >= expiry(unit, 1)
@ -95,17 +95,21 @@ export default {
convertExpiryToUnit (unit, amount) {
// Note: we want seconds and not milliseconds
switch (unit) {
case 'seconds': return (1000 * amount) / DateUtils.SECOND
case 'minutes': return (1000 * amount) / DateUtils.MINUTE
case 'hours': return (1000 * amount) / DateUtils.HOUR
case 'days': return (1000 * amount) / DateUtils.DAY
case 'years': return (1000 * amount) / DateUtils.YEAR
}
},
convertExpiryFromUnit (unit, amount) {
// Note: we want seconds and not milliseconds
switch (unit) {
case 'seconds': return amount * DateUtils.SECOND / 1000
case 'minutes': return amount * DateUtils.MINUTE / 1000
case 'hours': return amount * DateUtils.HOUR / 1000
case 'days': return amount * DateUtils.DAY / 1000
case 'years': return amount * DateUtils.YEAR / 1000
}
},
expiryAmountChange () {

View file

@ -100,10 +100,10 @@ const defaultState = {
pollsAvailable: false,
pollLimits: {
max_options: 4,
max_options: 20,
max_option_chars: 255,
min_expiration: 60,
max_expiration: 60 * 60 * 24
min_expiration: 1,
max_expiration: 60 * 60 * 24 * 365 * 1000
}
}