diff --git a/src/Dto/Notifications/UserSettings.php b/src/Dto/Notifications/UserSettings.php index 122c522e..e20d77fb 100644 --- a/src/Dto/Notifications/UserSettings.php +++ b/src/Dto/Notifications/UserSettings.php @@ -8,6 +8,9 @@ class UserSettings public string $name; public ?string $description = null; public int $notifications_types_id; - public int $is_enabled = 1; + // public int $is_enabled = 1; + public int $is_mail_enabled = 1; + public int $is_push_enabled = 1; + public int $is_realtime_enabled = 1; public array $channels; } diff --git a/src/Mapper/Notifications/UserSettings.php b/src/Mapper/Notifications/UserSettings.php index 5d2573b5..6f286d0c 100644 --- a/src/Mapper/Notifications/UserSettings.php +++ b/src/Mapper/Notifications/UserSettings.php @@ -22,12 +22,18 @@ class UserSettings extends CustomMapper */ public function mapToObject($userSettings, $userSettingsDto, array $context = []) { + $decodedChannels = !empty($userSettings->channels) && isJson($userSettings->channels) ? json_decode($userSettings->channels, true) : []; + + //decode channel json to determine if push. email or realtime are enabled $userSettingsDto->users_id = $userSettings->users_id; $userSettingsDto->notifications_types_id = $userSettings->notifications_types_id; $userSettingsDto->name = $userSettings->notification->name; $userSettingsDto->description = $userSettings->notification->description; - $userSettingsDto->is_enabled = $userSettings->is_enabled; - $userSettingsDto->channels = !empty($userSettings->channels) && isJson($userSettings->channels) ? json_decode($userSettings->channels, true) : []; + // $userSettingsDto->is_enabled = $userSettings->is_enabled; + $userSettingsDto->is_mail_enabled = array_key_exists("push",$decodedChannels); + $userSettingsDto->is_push_enabled = array_key_exists("email",$decodedChannels); + $userSettingsDto->is_realtime_enabled = array_key_exists("realtime",$decodedChannels); + $userSettingsDto->channels = $decodedChannels; return $userSettingsDto; }