mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
fix: open group comparison issues potentially, have to update some more outgoing message open group flags for visibility of details etc
This commit is contained in:
parent
1c7841333a
commit
dec179f4e7
@ -501,7 +501,9 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
|||||||
val communities = userGroups.allCommunityInfo()
|
val communities = userGroups.allCommunityInfo()
|
||||||
val lgc = userGroups.allLegacyGroupInfo()
|
val lgc = userGroups.allLegacyGroupInfo()
|
||||||
val allOpenGroups = getAllOpenGroups()
|
val allOpenGroups = getAllOpenGroups()
|
||||||
val toDeleteCommunities = allOpenGroups.filter { it.value.joinURL !in communities.map { it.community.fullUrl() } }
|
val toDeleteCommunities = allOpenGroups.filter {
|
||||||
|
Conversation.Community(BaseCommunityInfo(it.value.server, it.value.room, it.value.publicKey), 0, false).baseCommunityInfo.fullUrl() !in communities.map { it.community.fullUrl() }
|
||||||
|
}
|
||||||
|
|
||||||
val existingCommunities: Map<Long, OpenGroup> = allOpenGroups.filterKeys { it !in toDeleteCommunities.keys }
|
val existingCommunities: Map<Long, OpenGroup> = allOpenGroups.filterKeys { it !in toDeleteCommunities.keys }
|
||||||
val toAddCommunities = communities.filter { it.community.fullUrl() !in existingCommunities.map { it.value.joinURL } }
|
val toAddCommunities = communities.filter { it.community.fullUrl() !in existingCommunities.map { it.value.joinURL } }
|
||||||
@ -521,7 +523,6 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
|||||||
toDeleteClosedGroups.forEach { deleteGroup ->
|
toDeleteClosedGroups.forEach { deleteGroup ->
|
||||||
val threadId = getThreadId(deleteGroup.encodedId)
|
val threadId = getThreadId(deleteGroup.encodedId)
|
||||||
if (threadId != null) {
|
if (threadId != null) {
|
||||||
Log.d("Loki-DBG", "Deleting group for thread $threadId")
|
|
||||||
ClosedGroupManager.silentlyRemoveGroup(context,threadId,GroupUtil.doubleDecodeGroupId(deleteGroup.encodedId), deleteGroup.encodedId, localUserPublicKey, delete = true)
|
ClosedGroupManager.silentlyRemoveGroup(context,threadId,GroupUtil.doubleDecodeGroupId(deleteGroup.encodedId), deleteGroup.encodedId, localUserPublicKey, delete = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -529,7 +530,6 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
|||||||
toAddCommunities.forEach { toAddCommunity ->
|
toAddCommunities.forEach { toAddCommunity ->
|
||||||
val joinUrl = toAddCommunity.community.fullUrl()
|
val joinUrl = toAddCommunity.community.fullUrl()
|
||||||
if (!hasBackgroundGroupAddJob(joinUrl)) {
|
if (!hasBackgroundGroupAddJob(joinUrl)) {
|
||||||
Log.d("Loki-DBG", "Doesn't contain background job for open group, adding from config update")
|
|
||||||
JobQueue.shared.add(BackgroundGroupAddJob(joinUrl))
|
JobQueue.shared.add(BackgroundGroupAddJob(joinUrl))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,7 +550,6 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
|||||||
val existingGroup = existingClosedGroups.firstOrNull { GroupUtil.doubleDecodeGroupId(it.encodedId) == group.sessionId }
|
val existingGroup = existingClosedGroups.firstOrNull { GroupUtil.doubleDecodeGroupId(it.encodedId) == group.sessionId }
|
||||||
val existingThread = existingGroup?.let { getThreadId(existingGroup.encodedId) }
|
val existingThread = existingGroup?.let { getThreadId(existingGroup.encodedId) }
|
||||||
if (existingGroup != null) {
|
if (existingGroup != null) {
|
||||||
Log.d("Loki-DBG", "Existing closed group, don't add")
|
|
||||||
if (group.priority == PRIORITY_HIDDEN && existingThread != null) {
|
if (group.priority == PRIORITY_HIDDEN && existingThread != null) {
|
||||||
threadDb.deleteConversation(existingThread)
|
threadDb.deleteConversation(existingThread)
|
||||||
// TODO: stop polling here also
|
// TODO: stop polling here also
|
||||||
|
@ -9,7 +9,6 @@ import org.session.libsession.messaging.open_groups.OpenGroup
|
|||||||
import org.session.libsession.messaging.open_groups.OpenGroupApi
|
import org.session.libsession.messaging.open_groups.OpenGroupApi
|
||||||
import org.session.libsession.messaging.sending_receiving.pollers.OpenGroupPoller
|
import org.session.libsession.messaging.sending_receiving.pollers.OpenGroupPoller
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.session.libsignal.utilities.ThreadUtils
|
|
||||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||||
import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities
|
import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
@ -106,6 +105,7 @@ object OpenGroupManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WorkerThread
|
||||||
fun delete(server: String, room: String, context: Context) {
|
fun delete(server: String, room: String, context: Context) {
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
val configFactory = MessagingModuleConfiguration.shared.configFactory
|
val configFactory = MessagingModuleConfiguration.shared.configFactory
|
||||||
@ -133,11 +133,9 @@ object OpenGroupManager {
|
|||||||
storage.removeLastOutboxMessageId(server)
|
storage.removeLastOutboxMessageId(server)
|
||||||
val lokiThreadDB = DatabaseComponent.get(context).lokiThreadDatabase()
|
val lokiThreadDB = DatabaseComponent.get(context).lokiThreadDatabase()
|
||||||
lokiThreadDB.removeOpenGroupChat(threadID)
|
lokiThreadDB.removeOpenGroupChat(threadID)
|
||||||
ThreadUtils.queue {
|
storage.deleteConversation(threadID) // Must be invoked on a background thread
|
||||||
storage.deleteConversation(threadID) // Must be invoked on a background thread
|
GroupManager.deleteGroup(groupID, context) // Must be invoked on a background thread
|
||||||
GroupManager.deleteGroup(groupID, context) // Must be invoked on a background thread
|
ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(context)
|
||||||
ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(context)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
@ -650,7 +650,9 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
|||||||
// Delete the conversation
|
// Delete the conversation
|
||||||
val v2OpenGroup = DatabaseComponent.get(this@HomeActivity).lokiThreadDatabase().getOpenGroupChat(threadID)
|
val v2OpenGroup = DatabaseComponent.get(this@HomeActivity).lokiThreadDatabase().getOpenGroupChat(threadID)
|
||||||
if (v2OpenGroup != null) {
|
if (v2OpenGroup != null) {
|
||||||
OpenGroupManager.delete(v2OpenGroup.server, v2OpenGroup.room, this@HomeActivity)
|
withContext(Dispatchers.IO) {
|
||||||
|
OpenGroupManager.delete(v2OpenGroup.server, v2OpenGroup.room, this@HomeActivity)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
storage.deleteConversation(threadID)
|
storage.deleteConversation(threadID)
|
||||||
|
@ -60,7 +60,7 @@ class UserDetailsBottomSheet: BottomSheetDialogFragment() {
|
|||||||
profilePictureView.root.update(recipient)
|
profilePictureView.root.update(recipient)
|
||||||
nameTextViewContainer.visibility = View.VISIBLE
|
nameTextViewContainer.visibility = View.VISIBLE
|
||||||
nameTextViewContainer.setOnClickListener {
|
nameTextViewContainer.setOnClickListener {
|
||||||
if (recipient.isOpenGroupInboxRecipient) return@setOnClickListener
|
if (recipient.isOpenGroupInboxRecipient || recipient.isOpenGroupOutboxRecipient) return@setOnClickListener
|
||||||
nameTextViewContainer.visibility = View.INVISIBLE
|
nameTextViewContainer.visibility = View.INVISIBLE
|
||||||
nameEditTextContainer.visibility = View.VISIBLE
|
nameEditTextContainer.visibility = View.VISIBLE
|
||||||
nicknameEditText.text = null
|
nicknameEditText.text = null
|
||||||
@ -88,8 +88,12 @@ class UserDetailsBottomSheet: BottomSheetDialogFragment() {
|
|||||||
nameTextView.text = recipient.name ?: publicKey // Uses the Contact API internally
|
nameTextView.text = recipient.name ?: publicKey // Uses the Contact API internally
|
||||||
|
|
||||||
nameEditIcon.isVisible = threadRecipient.isContactRecipient
|
nameEditIcon.isVisible = threadRecipient.isContactRecipient
|
||||||
|
&& !threadRecipient.isOpenGroupInboxRecipient
|
||||||
|
&& !threadRecipient.isOpenGroupOutboxRecipient
|
||||||
|
|
||||||
publicKeyTextView.isVisible = !threadRecipient.isOpenGroupRecipient && !threadRecipient.isOpenGroupInboxRecipient
|
publicKeyTextView.isVisible = !threadRecipient.isOpenGroupRecipient
|
||||||
|
&& !threadRecipient.isOpenGroupInboxRecipient
|
||||||
|
&& !threadRecipient.isOpenGroupOutboxRecipient
|
||||||
messageButton.isVisible = !threadRecipient.isOpenGroupRecipient || IdPrefix.fromValue(publicKey) == IdPrefix.BLINDED
|
messageButton.isVisible = !threadRecipient.isOpenGroupRecipient || IdPrefix.fromValue(publicKey) == IdPrefix.BLINDED
|
||||||
publicKeyTextView.text = publicKey
|
publicKeyTextView.text = publicKey
|
||||||
publicKeyTextView.setOnLongClickListener {
|
publicKeyTextView.setOnLongClickListener {
|
||||||
|
@ -5,6 +5,7 @@ import android.os.Parcel
|
|||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.util.Pair
|
import android.util.Pair
|
||||||
import androidx.annotation.VisibleForTesting
|
import androidx.annotation.VisibleForTesting
|
||||||
|
import org.session.libsignal.utilities.IdPrefix
|
||||||
import org.session.libsignal.utilities.Util
|
import org.session.libsignal.utilities.Util
|
||||||
import org.session.libsignal.utilities.guava.Optional
|
import org.session.libsignal.utilities.guava.Optional
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
@ -26,6 +27,8 @@ class Address private constructor(address: String) : Parcelable, Comparable<Addr
|
|||||||
get() = GroupUtil.isOpenGroup(address)
|
get() = GroupUtil.isOpenGroup(address)
|
||||||
val isOpenGroupInbox: Boolean
|
val isOpenGroupInbox: Boolean
|
||||||
get() = GroupUtil.isOpenGroupInbox(address)
|
get() = GroupUtil.isOpenGroupInbox(address)
|
||||||
|
val isOpenGroupOutbox: Boolean
|
||||||
|
get() = address.startsWith(IdPrefix.BLINDED.value)
|
||||||
val isContact: Boolean
|
val isContact: Boolean
|
||||||
get() = !(isGroup || isOpenGroupInbox)
|
get() = !(isGroup || isOpenGroupInbox)
|
||||||
|
|
||||||
|
@ -442,6 +442,10 @@ public class Recipient implements RecipientModifiedListener {
|
|||||||
return address.isOpenGroup();
|
return address.isOpenGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOpenGroupOutboxRecipient() {
|
||||||
|
return address.isOpenGroupOutbox();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isOpenGroupInboxRecipient() {
|
public boolean isOpenGroupInboxRecipient() {
|
||||||
return address.isOpenGroupInbox();
|
return address.isOpenGroupInbox();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user