settings: Validate desktop_icon_display_count value in 'PATCH /settings'.

This commit is contained in:
Sahil Batra
2021-09-08 19:57:19 +05:30
committed by Tim Abbott
parent 2f61afea9f
commit de4c0d9fe9
2 changed files with 8 additions and 1 deletions

View File

@@ -1349,6 +1349,11 @@ class UserBaseSettings(models.Model):
DESKTOP_ICON_COUNT_DISPLAY_MESSAGES = 1
DESKTOP_ICON_COUNT_DISPLAY_NOTIFIABLE = 2
DESKTOP_ICON_COUNT_DISPLAY_NONE = 3
DESKTOP_ICON_COUNT_DISPLAY_CHOICES = [
DESKTOP_ICON_COUNT_DISPLAY_MESSAGES,
DESKTOP_ICON_COUNT_DISPLAY_NOTIFIABLE,
DESKTOP_ICON_COUNT_DISPLAY_NONE,
]
desktop_icon_count_display: int = models.PositiveSmallIntegerField(
default=DESKTOP_ICON_COUNT_DISPLAY_MESSAGES
)

View File

@@ -153,7 +153,9 @@ def json_change_settings(
pm_content_in_desktop_notifications: Optional[bool] = REQ(
json_validator=check_bool, default=None
),
desktop_icon_count_display: Optional[int] = REQ(json_validator=check_int, default=None),
desktop_icon_count_display: Optional[int] = REQ(
json_validator=check_int_in(UserProfile.DESKTOP_ICON_COUNT_DISPLAY_CHOICES), default=None
),
realm_name_in_notifications: Optional[bool] = REQ(json_validator=check_bool, default=None),
presence_enabled: Optional[bool] = REQ(json_validator=check_bool, default=None),
enter_sends: Optional[bool] = REQ(json_validator=check_bool, default=None),