Clear open group inbox messages

This commit is contained in:
charles 2022-12-16 11:18:09 +11:00
parent ee6f393c9a
commit 2494483afb
2 changed files with 18 additions and 0 deletions

View File

@ -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

View File

@ -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
}