mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Exclude linked devices from group member options
This commit is contained in:
parent
998d03b258
commit
7610314165
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.loki.redesign.activities
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.util.AsyncLoader
|
import org.thoughtcrime.securesms.util.AsyncLoader
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus
|
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus
|
||||||
|
|
||||||
class CreateClosedGroupLoader(context: Context) : AsyncLoader<List<String>>(context) {
|
class CreateClosedGroupLoader(context: Context) : AsyncLoader<List<String>>(context) {
|
||||||
@ -10,6 +11,12 @@ class CreateClosedGroupLoader(context: Context) : AsyncLoader<List<String>>(cont
|
|||||||
override fun loadInBackground(): List<String> {
|
override fun loadInBackground(): List<String> {
|
||||||
val threadDatabase = DatabaseFactory.getThreadDatabase(context)
|
val threadDatabase = DatabaseFactory.getThreadDatabase(context)
|
||||||
val lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context)
|
val lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context)
|
||||||
|
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
|
val deviceLinks = DatabaseFactory.getLokiAPIDatabase(context).getPairingAuthorisations(userHexEncodedPublicKey)
|
||||||
|
val userLinkedDeviceHexEncodedPublicKeys = deviceLinks.flatMap {
|
||||||
|
listOf( it.primaryDevicePublicKey.toLowerCase(), it.secondaryDevicePublicKey.toLowerCase() )
|
||||||
|
}.toMutableSet()
|
||||||
|
userLinkedDeviceHexEncodedPublicKeys.add(userHexEncodedPublicKey.toLowerCase())
|
||||||
val cursor = threadDatabase.conversationList
|
val cursor = threadDatabase.conversationList
|
||||||
val reader = threadDatabase.readerFor(cursor)
|
val reader = threadDatabase.readerFor(cursor)
|
||||||
val result = mutableListOf<String>()
|
val result = mutableListOf<String>()
|
||||||
@ -17,7 +24,9 @@ class CreateClosedGroupLoader(context: Context) : AsyncLoader<List<String>>(cont
|
|||||||
val thread = reader.current
|
val thread = reader.current
|
||||||
if (thread.recipient.isGroupRecipient) { continue }
|
if (thread.recipient.isGroupRecipient) { continue }
|
||||||
if (lokiThreadDatabase.getFriendRequestStatus(thread.threadId) != LokiThreadFriendRequestStatus.FRIENDS) { continue }
|
if (lokiThreadDatabase.getFriendRequestStatus(thread.threadId) != LokiThreadFriendRequestStatus.FRIENDS) { continue }
|
||||||
result.add(thread.recipient.address.toString())
|
val hexEncodedPublicKey = thread.recipient.address.toString().toLowerCase()
|
||||||
|
if (userLinkedDeviceHexEncodedPublicKeys.contains(hexEncodedPublicKey)) { continue }
|
||||||
|
result.add(hexEncodedPublicKey)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user