fix: null value checked on user_settings.properties

This commit is contained in:
Mir Arif Hasan
2022-12-19 23:56:50 +06:00
parent 83437ae4ba
commit 5c032e84be
2 changed files with 11 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import * as E from 'fp-ts/Either';
import { stringToJson } from 'src/utils';
import { UserSettings } from './user-settings.model';
import {
USER_SETTINGS_INVALID_PROPERTIES,
USER_SETTINGS_NOT_FOUND,
USER_SETTINGS_UPDATE_FAILED,
} from 'src/errors';
@@ -38,6 +39,8 @@ export class UserSettingsService {
}
async createUserSettings(user: User, properties: string) {
if (!properties) return E.left(USER_SETTINGS_INVALID_PROPERTIES);
const jsonProperties = stringToJson(properties);
if (E.isLeft(jsonProperties)) return E.left(jsonProperties.left);
@@ -59,6 +62,8 @@ export class UserSettingsService {
}
async updateUserSettings(user: User, properties: string) {
if (!properties) return E.left(USER_SETTINGS_INVALID_PROPERTIES);
const jsonProperties = stringToJson(properties);
if (E.isLeft(jsonProperties)) return E.left(jsonProperties.left);