From 25fb9fbcd9796eeade977667197e25870dfd43ba Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Sat, 1 Aug 2026 15:43:54 +0300 Subject: [PATCH] Clear all account's blocking related records when account is deleted --- app/src/main/kotlin/com/tutpro/baresip/AccountsScreen.kt | 2 ++ app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt | 2 ++ app/src/main/kotlin/com/tutpro/baresip/BlockRule.kt | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/app/src/main/kotlin/com/tutpro/baresip/AccountsScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/AccountsScreen.kt index b1ac81a3..56226f3a 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AccountsScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AccountsScreen.kt @@ -159,6 +159,8 @@ fun AccountsContent(contentPadding: PaddingValues, navController: NavController) lastAction.value = { CallHistoryNew.clear(aor) Message.clearMessagesOfAor(aor) + Blocked.clear(aor) + BlockRule.clear(aor) ua.remove() Api.ua_destroy(ua.uap) Account.saveAccounts() diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 4a23930c..be212e24 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -870,6 +870,8 @@ class BaresipService: Service() { Log.d(TAG, "Removing Mobile account on API < 29") CallHistoryNew.clear(ua.account.aor) Message.clearMessagesOfAor(ua.account.aor) + Blocked.clear(ua.account.aor) + BlockRule.clear(ua.account.aor) Api.ua_destroy(uap) Account.saveAccounts() return diff --git a/app/src/main/kotlin/com/tutpro/baresip/BlockRule.kt b/app/src/main/kotlin/com/tutpro/baresip/BlockRule.kt index 2873224d..23b2cad0 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BlockRule.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BlockRule.kt @@ -23,6 +23,11 @@ class BlockRule( return BaresipService.blockRules.any { it.aor == aor && it.pattern == pattern } } + fun clear(aor: String) { + BaresipService.blockRules.removeAll { it.aor == aor } + save() + } + fun save() { Log.d(TAG, "Saving ${BaresipService.blockRules.size} block rules") val file = File(BaresipService.filesPath + "/blocking")