fix: register fcm token on enabling push notification

This commit is contained in:
Abdalhamid Alhamad
2024-12-24 13:00:54 +03:00
parent 3719498c2f
commit bb8cc33d53
5 changed files with 31 additions and 13 deletions

View File

@ -1,19 +1,24 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsBoolean, IsOptional } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsBoolean, IsOptional, IsString, ValidateIf } from 'class-validator';
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
export class UpdateNotificationsSettingsRequestDto {
@ApiProperty()
@IsBoolean()
@IsBoolean({ message: i18n('validation.isBoolean', { path: 'general', property: 'customer.isEmailEnabled' }) })
@IsOptional()
isEmailEnabled!: boolean;
@ApiProperty()
@IsBoolean()
@IsBoolean({ message: i18n('validation.isBoolean', { path: 'general', property: 'customer.isPushEnabled' }) })
@IsOptional()
isPushEnabled!: boolean;
@ApiProperty()
@IsBoolean()
@IsBoolean({ message: i18n('validation.isBoolean', { path: 'general', property: 'customer.isSmsEnabled' }) })
@IsOptional()
isSmsEnabled!: boolean;
@ApiPropertyOptional()
@IsString({ message: i18n('validation.isString', { path: 'general', property: 'customer.fcmToken' }) })
@ValidateIf((o) => o.isPushEnabled)
fcmToken?: string;
}