File tree Expand file tree Collapse file tree
app/src/main/java/to/bitkit/repositories Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -401,11 +401,31 @@ class PubkyRepo @Inject constructor(
401401 val session = requireNotNull(keychain.loadString(Keychain .Key .PAYKIT_SESSION .name)) {
402402 " No session available"
403403 }
404+ deleteAllContacts(session)
404405 pubkyService.sessionDelete(session, Env .profilePath)
405406 }
406407 signOut().getOrThrow()
407408 }
408409
410+ private suspend fun deleteAllContacts (session : String ) {
411+ val contactPaths = runCatching {
412+ pubkyService.sessionList(session, Env .contactsBasePath)
413+ }.getOrElse {
414+ if (it.isMissingPubkyDirectory()) return
415+ throw it
416+ }
417+ contactPaths.forEach { path ->
418+ val contactKey = path.substringAfterLast(" /" )
419+ runCatching {
420+ pubkyService.sessionDelete(session, " ${Env .contactsBasePath}$contactKey " )
421+ }.onFailure {
422+ Logger .warn(" Failed to delete contact '$contactKey '" , it, context = TAG )
423+ }
424+ }
425+ _contacts .update { emptyList() }
426+ Logger .info(" Deleted all contacts" , context = TAG )
427+ }
428+
409429 @Suppress(" LongParameterList" )
410430 private suspend fun writeProfile (
411431 sessionSecret : String ,
You can’t perform that action at this time.
0 commit comments