feat: [notification] 알림설정 soundType API 연동
- getGroupedSettings()에서 soundType 반환 (settings.sound_type) - updateGroupedSettings()에서 soundType 저장 (settings JSON) - UpdateGroupedSettingRequest에 soundType 검증 추가 (default/sam_voice/mute)
This commit is contained in:
@@ -265,15 +265,18 @@ public function getGroupedSettings(): array
|
||||
|
||||
if ($settings->has($type)) {
|
||||
$setting = $settings->get($type);
|
||||
$soundType = $setting->settings['sound_type'] ?? 'default';
|
||||
$groupData[$camelKey] = [
|
||||
'enabled' => $setting->push_enabled,
|
||||
'email' => $setting->email_enabled,
|
||||
'soundType' => $soundType,
|
||||
];
|
||||
} else {
|
||||
// 기본값
|
||||
$groupData[$camelKey] = [
|
||||
'enabled' => false,
|
||||
'email' => false,
|
||||
'soundType' => 'default',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -330,6 +333,17 @@ public function updateGroupedSettings(array $data): array
|
||||
|
||||
if (isset($groupData[$camelKey])) {
|
||||
$itemData = $groupData[$camelKey];
|
||||
|
||||
// 기존 settings JSON을 유지하면서 sound_type만 업데이트
|
||||
$existing = NotificationSetting::where('tenant_id', $tenantId)
|
||||
->where('user_id', $userId)
|
||||
->where('notification_type', $type)
|
||||
->first();
|
||||
$existingSettings = $existing?->settings ?? [];
|
||||
if (isset($itemData['soundType'])) {
|
||||
$existingSettings['sound_type'] = $itemData['soundType'];
|
||||
}
|
||||
|
||||
NotificationSetting::updateOrCreate(
|
||||
[
|
||||
'tenant_id' => $tenantId,
|
||||
@@ -342,6 +356,7 @@ public function updateGroupedSettings(array $data): array
|
||||
'sms_enabled' => false,
|
||||
'in_app_enabled' => $itemData['enabled'] ?? false,
|
||||
'kakao_enabled' => false,
|
||||
'settings' => $existingSettings ?: null,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user