From b706191a0e0270494a29eae2ccef729080aec993 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 15 Jan 2026 09:28:00 +0100 Subject: [PATCH] Refactor effect handling in enrichNotificationsWithCharacterNames to improve data parsing - Simplified the logic for processing notification effects by consolidating the JSON parsing into a single conditional check, enhancing code readability and maintainability. - Ensured consistent handling of effects regardless of their initial format, improving robustness in notification enrichment. --- backend/services/falukantService.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index 7b13dc1..031453d 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -5969,7 +5969,10 @@ async function enrichNotificationsWithCharacterNames(notifications) { // parse n.effects if present try { if (n.effects) { - const eff = typeof n.effects === 'string' && n.effects.trim().startsWith('{') ? JSON.parse(n.effects) : n.effects; + let eff = n.effects; + if (typeof eff === 'string') { + eff = JSON.parse(eff); + } collectIds(eff); } } catch (err) { /* ignore */ } @@ -6037,7 +6040,10 @@ async function enrichNotificationsWithCharacterNames(notifications) { try { if (n.effects) { - const eff = typeof n.effects === 'string' && n.effects.trim().startsWith('{') ? JSON.parse(n.effects) : n.effects; + let eff = n.effects; + if (typeof eff === 'string') { + eff = JSON.parse(eff); + } foundId = findFirstId(eff) || foundId; } } catch (err) { /* ignore */ }