Skip to content
Snippets Groups Projects
Commit 70a17c87 authored by Pierre Nicolas's avatar Pierre Nicolas :joy: Committed by Adrien Béraud
Browse files

request: fix block request crash

- handle crash by catching the error properly
- call banRequest before removeRequest

GitLab: #1576
Change-Id: I425f0316178b619a23ad205581f620a22f44b4ec
parent 1b3b99c8
No related branches found
No related tags found
No related merge requests found
......@@ -256,8 +256,8 @@ class DRingService : Service() {
ACTION_TRUST_REQUEST_ACCEPT -> mConversationFacade.acceptRequest(path.accountId, path.conversationUri)
ACTION_TRUST_REQUEST_REFUSE -> mConversationFacade.discardRequest(path.accountId, path.conversationUri)
ACTION_TRUST_REQUEST_BLOCK -> {
mConversationFacade.discardRequest(path.accountId, path.conversationUri)
mConversationFacade.banConversation(path.accountId, path.conversationUri)
mConversationFacade.discardRequest(path.accountId, path.conversationUri)
}
}
}
......
......@@ -98,8 +98,8 @@ class TVContactPresenter @Inject constructor(
}
fun blockTrustRequest() {
mConversationService.discardRequest(mAccountId!!, mUri!!)
mConversationService.banConversation(mAccountId!!, mUri!!)
mConversationService.discardRequest(mAccountId!!, mUri!!)
view?.finishView()
}
}
\ No newline at end of file
......@@ -49,8 +49,8 @@ class ContactRequestsPresenter @Inject internal constructor(
}
fun banContact(item: Conversation) {
conversationFacade.discardRequest(item.accountId, item.uri)
conversationFacade.banConversation(item.accountId, item.uri)
conversationFacade.discardRequest(item.accountId, item.uri)
}
fun copyNumber(item: Conversation) {
......
......@@ -446,8 +446,8 @@ class ConversationPresenter @Inject constructor(
fun onBlockIncomingContactRequest() {
mConversation?.let { conversation ->
conversationFacade.discardRequest(conversation.accountId, conversation.uri)
conversationFacade.banConversation(conversation.accountId, conversation.uri)
conversationFacade.discardRequest(conversation.accountId, conversation.uri)
}
view?.goToHome()
}
......
......@@ -69,8 +69,8 @@ class ConversationFacade(
}
}
fun startConversation(accountId: String, contactId: Uri): Single<Conversation> = getAccountSubject(accountId)
.map { account: Account -> account.getByUri(contactId)!! }
fun startConversation(accountId: String, contactId: Uri): Single<Conversation> =
getAccountSubject(accountId).map { account: Account -> account.getByUri(contactId)!! }
fun getAccountSubject(accountId: String): Single<Account> = mAccountService.getAccountSingle(accountId)
.flatMap { account: Account -> loadSmartlist(account) }
......@@ -685,19 +685,17 @@ class ConversationFacade(
fun banConversation(accountId: String, conversationUri: Uri) {
if (conversationUri.isSwarm) {
startConversation(accountId, conversationUri)
.subscribe { conversation: Conversation ->
mDisposableBag.add(
startConversation(accountId, conversationUri).subscribe({ v: Conversation ->
try {
val contact = conversation.contact
val contact = v.contact
mAccountService.removeContact(accountId, contact!!.uri.rawRingId, true)
} catch (e: Exception) {
mAccountService.removeConversation(accountId, conversationUri)
}
}
//return mAccountService.removeConversation(accountId, conversationUri);
} else {
mAccountService.removeContact(accountId, conversationUri.rawRingId, true)
}
}, { e: Throwable -> Log.e(TAG, "Error banning conversation", e) })
)
} else mAccountService.removeContact(accountId, conversationUri.rawRingId, true)
}
fun createConversation(accountId: String, currentSelection: Collection<Contact>): Single<Conversation> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment