Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified /writeUserSettings params #9124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mzparacha
Copy link
Contributor

@mzparacha mzparacha commented Sep 5, 2024

Link to Issue

Closes: #8393

Description of Changes

Simplified /writeUserSettings params, replacing key: string / value: string param pairs with proper param names

disable_rich_text: boolean
promotional_emails_enabled: boolean
email_notification_interval: string

"How We Fixed It"

N/A

Test Plan

  • Verify no regressions with /writeUserSettings request

Deployment Plan

N/A

Other Considerations

This PR doesn't aim to move the modified API to newer standards, its just about cleaning up the params which caused some confusion in an earlier PR.

@mzparacha mzparacha self-assigned this Sep 5, 2024
@github-actions github-actions bot marked this pull request as draft September 5, 2024 13:54
@mzparacha mzparacha marked this pull request as ready for review September 5, 2024 13:55
@mzparacha mzparacha force-pushed the malik.8393.cleanup.writeUserSetting branch from 1a04d8b to 4998787 Compare September 5, 2024 16:16
!(
typeof disable_rich_text !== 'boolean' ||
typeof promotional_emails_enabled !== 'boolean' ||
email_notification_interval
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic seems incorrect. If disable_rich_text !== 'boolean' is true then the conditional evaluates to false and an InvalidSetting error is not returned.

return next(new AppError(Errors.InvalidSetting));
}

return res.json({ status: 'Success', result: { key, value } });
if (typeof disable_rich_text === 'boolean') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stuff should be validated ahead of time and an error thrown earlier if the type is incorrect. If the conditionals are set up correct then Typescript should be able to automatically narrow down the type to Boolean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cleanup /writeUserSetting request params
2 participants