From 952634603c2174a07867e9670e53ed00092f828f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vi=CC=81ctor=20Falco=CC=81n?= Date: Thu, 4 Dec 2025 17:20:53 +0100 Subject: [PATCH] Refactor rule engine to decrypt account names during evaluation - Make rule evaluation functions async to support account name decryption - Add encryption key parameter to all rule evaluation functions - Decrypt account names before rule matching and normalize to lowercase - Update all call sites to await async rule evaluation and pass encryption key - Simplify note decryption logic in edit transaction dialog by moving key retrieval earlier --- resources/js/lib/rule-engine.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/js/lib/rule-engine.ts b/resources/js/lib/rule-engine.ts index 8598273b..7b4e0b9d 100644 --- a/resources/js/lib/rule-engine.ts +++ b/resources/js/lib/rule-engine.ts @@ -62,7 +62,8 @@ async function decryptAccountName( key: CryptoKey, ): Promise { try { - return await decrypt(account.name, key, account.name_iv); + const decryptedAccountName = await decrypt(account.name, key, account.name_iv); + return decryptedAccountName.trim(); } catch (error) { console.error('Failed to decrypt account name:', account.id, error); return ''; @@ -87,7 +88,6 @@ export async function prepareTransactionData( const category = transaction.category_id ? categories.find((c) => c.id === transaction.category_id) : null; - const accountName = account ? await decryptAccountName(account, encryptionKey) : '';