| @@ -52,22 +52,17 @@ | ||
| 52 | 52 | return $this->sendError($e->getMessage(), 400); |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | + /** | |
| 57 | + * Return the current user's board notification settings with safe defaults. | |
| 58 | + */ | |
| 56 | 59 | public function getBoardNotificationSettings($board_id) |
| 57 | 60 | { |
| 58 | 61 | $board_id = absint($board_id); |
| 59 | 62 | try { |
| 60 | 63 | $userId = get_current_user_id(); |
| 61 | - $currentSettings = []; | |
| 62 | - $boardSettings = $this->notificationService->getBoardNotificationSettingsOfUser($board_id, $userId); | |
| 63 | - if ($boardSettings && $boardSettings->preferences) { | |
| 64 | - $unserializedData = maybe_unserialize($boardSettings->preferences); | |
| 65 | - // Validate unserialized data is an array | |
| 66 | - if (is_array($unserializedData)) { | |
| 67 | - $currentSettings = $unserializedData; | |
| 68 | - } | |
| 69 | - } | |
| 64 | + $currentSettings = $this->notificationService->getBoardNotificationSettingsWithDefaults($board_id, $userId); | |
| 70 | 65 | |
| 71 | 66 | return $this->sendSuccess([ |
| 72 | 67 | 'currentSettings' => $currentSettings, |
| 73 | 68 | ], 200); |
| @@ -119,5 +114,5 @@ | ||
| 119 | 114 | } catch (\Exception $e) { |
| 120 | 115 | return $this->sendError($e->getMessage(), 400); |
| 121 | 116 | } |
| 122 | 117 | } |
| 123 | -} | |
| 118 | +} | |