2
1

user-notifications.ts 851 B

1234567891011121314151617181920212223
  1. import { exists } from './misc'
  2. import * as validator from 'validator'
  3. import { UserNotificationType } from '../../../shared/models/users'
  4. import { UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model'
  5. function isUserNotificationTypeValid (value: any) {
  6. return exists(value) && validator.isInt('' + value) && UserNotificationType[value] !== undefined
  7. }
  8. function isUserNotificationSettingValid (value: any) {
  9. return exists(value) &&
  10. validator.isInt('' + value) && (
  11. value === UserNotificationSettingValue.NONE ||
  12. value === UserNotificationSettingValue.WEB ||
  13. value === UserNotificationSettingValue.EMAIL ||
  14. value === (UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL)
  15. )
  16. }
  17. export {
  18. isUserNotificationSettingValid,
  19. isUserNotificationTypeValid
  20. }