mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-18 06:11:55 +00:00
fix: remove user notifications for leaving group to prevent synced device issues, don't create thread in messages for new closed groups, includei nactive groups in the deletion queries for merging group configs
This commit is contained in:
@@ -321,7 +321,7 @@ object ConversationMenuHelper {
|
||||
}
|
||||
try {
|
||||
if (isClosedGroup) {
|
||||
MessageSender.leave(groupPublicKey!!, true)
|
||||
MessageSender.leave(groupPublicKey!!, notifyUser = false)
|
||||
} else {
|
||||
Toast.makeText(context, R.string.ConversationActivity_error_leaving_group, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
@@ -133,12 +133,12 @@ public class GroupDatabase extends Database implements LokiOpenGroupDatabaseProt
|
||||
return new Reader(cursor);
|
||||
}
|
||||
|
||||
public List<GroupRecord> getAllGroups() {
|
||||
public List<GroupRecord> getAllGroups(boolean includeInactive) {
|
||||
Reader reader = getGroups();
|
||||
GroupRecord record;
|
||||
List<GroupRecord> groups = new LinkedList<>();
|
||||
while ((record = reader.getNext()) != null) {
|
||||
if (record.isActive()) { groups.add(record); }
|
||||
if (record.isActive() || includeInactive) { groups.add(record); }
|
||||
}
|
||||
reader.close();
|
||||
return groups;
|
||||
|
@@ -497,7 +497,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
val toAddCommunities = communities.filter { it.community.fullUrl() !in existingCommunities.map { it.value.joinURL } }
|
||||
val existingJoinUrls = existingCommunities.values.map { it.joinURL }
|
||||
|
||||
val existingClosedGroups = getAllGroups().filter { it.isClosedGroup }
|
||||
val existingClosedGroups = getAllGroups(includeInactive = true).filter { it.isClosedGroup }
|
||||
val lgcIds = lgc.map { it.sessionId }
|
||||
val toDeleteClosedGroups = existingClosedGroups.filter { group ->
|
||||
GroupUtil.doubleDecodeGroupId(group.encodedId) !in lgcIds
|
||||
@@ -513,6 +513,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
if (threadId == null) {
|
||||
Log.w("Loki-DBG", "Existing group had no thread to delete")
|
||||
} else {
|
||||
Log.d("Loki-DBG", "Deleting group for thread $threadId")
|
||||
ClosedGroupManager.silentlyRemoveGroup(context,threadId,GroupUtil.doubleDecodeGroupId(deleteGroup.encodedId), deleteGroup.encodedId, localUserPublicKey, delete = true)
|
||||
}
|
||||
}
|
||||
@@ -954,8 +955,8 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
OpenGroupManager.updateOpenGroup(openGroup, context)
|
||||
}
|
||||
|
||||
override fun getAllGroups(): List<GroupRecord> {
|
||||
return DatabaseComponent.get(context).groupDatabase().allGroups
|
||||
override fun getAllGroups(includeInactive: Boolean): List<GroupRecord> {
|
||||
return DatabaseComponent.get(context).groupDatabase().getAllGroups(includeInactive)
|
||||
}
|
||||
|
||||
override fun addOpenGroup(urlAsString: String): OpenGroupApi.RoomInfo? {
|
||||
|
@@ -535,7 +535,6 @@ public class ThreadDatabase extends Database {
|
||||
// edge case where we set the last seen time for a conversation before it loads messages (joining community for example)
|
||||
MmsSmsDatabase mmsSmsDatabase = DatabaseComponent.get(context).mmsSmsDatabase();
|
||||
if (mmsSmsDatabase.getConversationCount(threadId) <= 0) return false;
|
||||
Log.d("Loki-DBG", "setLastSeen "+threadId+" @ "+timestamp);
|
||||
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
|
||||
@@ -559,7 +558,6 @@ public class ThreadDatabase extends Database {
|
||||
db.execSQL(reflectUpdates, new Object[]{threadId});
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
Log.d("Loki-DBG", "Updated last seen to "+timestamp);
|
||||
notifyConversationListListeners();
|
||||
return true;
|
||||
}
|
||||
@@ -800,7 +798,6 @@ public class ThreadDatabase extends Database {
|
||||
public boolean markAllAsRead(long threadId, boolean isGroupRecipient, long lastSeenTime) {
|
||||
MmsSmsDatabase mmsSmsDatabase = DatabaseComponent.get(context).mmsSmsDatabase();
|
||||
if (mmsSmsDatabase.getConversationCount(threadId) <= 0) return false;
|
||||
Log.d("Loki-DBG", "markAllAsRead "+threadId+" @ "+lastSeenTime);
|
||||
List<MarkedMessageInfo> messages = setRead(threadId, lastSeenTime);
|
||||
if (isGroupRecipient) {
|
||||
for (MarkedMessageInfo message: messages) {
|
||||
|
@@ -16,11 +16,11 @@ object ClosedGroupManager {
|
||||
|
||||
fun silentlyRemoveGroup(context: Context, threadId: Long, groupPublicKey: String, groupID: String, userPublicKey: String, delete: Boolean = true) {
|
||||
val storage = MessagingModuleConfiguration.shared.storage
|
||||
// Mark the group as inactive
|
||||
storage.setActive(groupID, false)
|
||||
storage.removeClosedGroupPublicKey(groupPublicKey)
|
||||
// Remove the key pairs
|
||||
storage.removeAllClosedGroupEncryptionKeyPairs(groupPublicKey)
|
||||
// Mark the group as inactive
|
||||
storage.setActive(groupID, false)
|
||||
storage.removeMember(groupID, Address.fromSerialized(userPublicKey))
|
||||
// Notify the PN server
|
||||
PushNotificationAPI.performOperation(PushNotificationAPI.ClosedGroupOperation.Unsubscribe, groupPublicKey, userPublicKey)
|
||||
|
@@ -302,7 +302,7 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() {
|
||||
isLoading = true
|
||||
loaderContainer.fadeIn()
|
||||
val promise: Promise<Any, Exception> = if (!members.contains(Recipient.from(this, Address.fromSerialized(userPublicKey), false))) {
|
||||
MessageSender.explicitLeave(groupPublicKey!!, true)
|
||||
MessageSender.explicitLeave(groupPublicKey!!, false)
|
||||
} else {
|
||||
task {
|
||||
if (hasNameChanged) {
|
||||
|
@@ -236,7 +236,7 @@ object ConfigurationMessageUtilities {
|
||||
GroupInfo.CommunityGroupInfo(baseInfo, if (isPinned) 1 else 0)
|
||||
}
|
||||
|
||||
val allLgc = storage.getAllGroups().filter { it.isClosedGroup && it.isActive }.mapNotNull { group ->
|
||||
val allLgc = storage.getAllGroups(includeInactive = false).filter { it.isClosedGroup }.mapNotNull { group ->
|
||||
val groupAddress = Address.fromSerialized(group.encodedId)
|
||||
val groupPublicKey = GroupUtil.doubleDecodeGroupID(groupAddress.serialize()).toHexString()
|
||||
val recipient = storage.getRecipientSettings(groupAddress) ?: return@mapNotNull null
|
||||
|
Reference in New Issue
Block a user