Skip to content

Commit

Permalink
add enabled status for all current channels
Browse files Browse the repository at this point in the history
  • Loading branch information
rwhite27 committed May 13, 2024
1 parent 317f38e commit 5207bdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Dto/Notifications/UserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
10 changes: 8 additions & 2 deletions src/Mapper/Notifications/UserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5207bdc

Please sign in to comment.