mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-28 02:37:46 +00:00
Clear open group inbox messages
This commit is contained in:
parent
ee6f393c9a
commit
2494483afb
@ -12,10 +12,12 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import network.loki.messenger.R
|
||||
import network.loki.messenger.databinding.DialogClearAllDataBinding
|
||||
import org.session.libsession.messaging.open_groups.OpenGroupApi
|
||||
import org.session.libsession.snode.SnodeAPI
|
||||
import org.session.libsignal.utilities.Log
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog
|
||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||
import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities
|
||||
|
||||
class ClearAllDataDialog : BaseDialog() {
|
||||
@ -108,6 +110,10 @@ class ClearAllDataDialog : BaseDialog() {
|
||||
} else {
|
||||
// finish
|
||||
val result = try {
|
||||
val openGroups = DatabaseComponent.get(requireContext()).lokiThreadDatabase().getAllOpenGroups()
|
||||
openGroups.map { it.value.server }.toSet().forEach { server ->
|
||||
OpenGroupApi.deleteAllInboxMessages(server).get()
|
||||
}
|
||||
SnodeAPI.deleteAllMessages().get()
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
|
@ -953,5 +953,17 @@ object OpenGroupApi {
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteAllInboxMessages(server: String): Promise<Map<*, *>, java.lang.Exception> {
|
||||
val request = Request(
|
||||
verb = DELETE,
|
||||
room = null,
|
||||
server = server,
|
||||
endpoint = Endpoint.Inbox
|
||||
)
|
||||
return getResponseBody(request).map { response ->
|
||||
JsonUtil.fromJson(response, Map::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user