mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Fix improperly caching notifyType
on Recipient
s (#965)
* fix: perform clear member roles before setting new roles to clear out old members * fix: hopefully add somewhere notifyType wasn't being carried over fixes #945
This commit is contained in:
parent
7d186c198e
commit
29124f36b6
@ -3,9 +3,9 @@ package org.thoughtcrime.securesms.database
|
|||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
|
||||||
import org.session.libsession.messaging.open_groups.GroupMember
|
import org.session.libsession.messaging.open_groups.GroupMember
|
||||||
import org.session.libsession.messaging.open_groups.GroupMemberRole
|
import org.session.libsession.messaging.open_groups.GroupMemberRole
|
||||||
|
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||||
|
|
||||||
class GroupMemberDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) {
|
class GroupMemberDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) {
|
||||||
|
|
||||||
@ -69,4 +69,16 @@ class GroupMemberDatabase(context: Context, helper: SQLCipherOpenHelper) : Datab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clearGroupMemberRoles(groupId: String) {
|
||||||
|
writableDatabase.beginTransaction()
|
||||||
|
try {
|
||||||
|
val query = "$GROUP_ID = ?"
|
||||||
|
val args = arrayOf(groupId)
|
||||||
|
writableDatabase.delete(TABLE_NAME, query, args)
|
||||||
|
writableDatabase.setTransactionSuccessful()
|
||||||
|
} finally {
|
||||||
|
writableDatabase.endTransaction()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -324,7 +324,11 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
|||||||
return getAllOpenGroups().values.firstOrNull { it.server == server && it.room == room }
|
return getAllOpenGroups().values.firstOrNull { it.server == server && it.room == room }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun addGroupMember(member: GroupMember) {
|
override fun clearGroupMemberRoles(groupId: String) {
|
||||||
|
DatabaseComponent.get(context).groupMemberDatabase().clearGroupMemberRoles(groupId)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addGroupMemberRole(member: GroupMember) {
|
||||||
DatabaseComponent.get(context).groupMemberDatabase().addGroupMember(member)
|
DatabaseComponent.get(context).groupMemberDatabase().addGroupMember(member)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ interface StorageProtocol {
|
|||||||
fun hasBackgroundGroupAddJob(groupJoinUrl: String): Boolean
|
fun hasBackgroundGroupAddJob(groupJoinUrl: String): Boolean
|
||||||
fun setOpenGroupServerMessageID(messageID: Long, serverID: Long, threadID: Long, isSms: Boolean)
|
fun setOpenGroupServerMessageID(messageID: Long, serverID: Long, threadID: Long, isSms: Boolean)
|
||||||
fun getOpenGroup(room: String, server: String): OpenGroup?
|
fun getOpenGroup(room: String, server: String): OpenGroup?
|
||||||
fun addGroupMember(member: GroupMember)
|
fun addGroupMemberRole(member: GroupMember)
|
||||||
|
fun clearGroupMemberRoles(groupId: String)
|
||||||
|
|
||||||
// Open Group Public Keys
|
// Open Group Public Keys
|
||||||
fun getOpenGroupPublicKey(server: String): String?
|
fun getOpenGroupPublicKey(server: String): String?
|
||||||
|
@ -134,18 +134,20 @@ class OpenGroupPoller(private val server: String, private val executorService: S
|
|||||||
storage.setUserCount(roomToken, server, pollInfo.activeUsers)
|
storage.setUserCount(roomToken, server, pollInfo.activeUsers)
|
||||||
|
|
||||||
// - Moderators
|
// - Moderators
|
||||||
|
storage.clearGroupMemberRoles(groupId)
|
||||||
|
|
||||||
pollInfo.details?.moderators?.forEach {
|
pollInfo.details?.moderators?.forEach {
|
||||||
storage.addGroupMember(GroupMember(groupId, it, GroupMemberRole.MODERATOR))
|
storage.addGroupMemberRole(GroupMember(groupId, it, GroupMemberRole.MODERATOR))
|
||||||
}
|
}
|
||||||
pollInfo.details?.hiddenModerators?.forEach {
|
pollInfo.details?.hiddenModerators?.forEach {
|
||||||
storage.addGroupMember(GroupMember(groupId, it, GroupMemberRole.HIDDEN_MODERATOR))
|
storage.addGroupMemberRole(GroupMember(groupId, it, GroupMemberRole.HIDDEN_MODERATOR))
|
||||||
}
|
}
|
||||||
// - Admins
|
// - Admins
|
||||||
pollInfo.details?.admins?.forEach {
|
pollInfo.details?.admins?.forEach {
|
||||||
storage.addGroupMember(GroupMember(groupId, it, GroupMemberRole.ADMIN))
|
storage.addGroupMemberRole(GroupMember(groupId, it, GroupMemberRole.ADMIN))
|
||||||
}
|
}
|
||||||
pollInfo.details?.hiddenAdmins?.forEach {
|
pollInfo.details?.hiddenAdmins?.forEach {
|
||||||
storage.addGroupMember(GroupMember(groupId, it, GroupMemberRole.HIDDEN_ADMIN))
|
storage.addGroupMemberRole(GroupMember(groupId, it, GroupMemberRole.HIDDEN_ADMIN))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +224,7 @@ public class Recipient implements RecipientModifiedListener {
|
|||||||
Recipient.this.profileSharing = result.profileSharing;
|
Recipient.this.profileSharing = result.profileSharing;
|
||||||
Recipient.this.unidentifiedAccessMode = result.unidentifiedAccessMode;
|
Recipient.this.unidentifiedAccessMode = result.unidentifiedAccessMode;
|
||||||
Recipient.this.forceSmsSelection = result.forceSmsSelection;
|
Recipient.this.forceSmsSelection = result.forceSmsSelection;
|
||||||
|
Recipient.this.notifyType = result.notifyType;
|
||||||
|
|
||||||
Recipient.this.participants.clear();
|
Recipient.this.participants.clear();
|
||||||
Recipient.this.participants.addAll(result.participants);
|
Recipient.this.participants.addAll(result.participants);
|
||||||
|
Loading…
Reference in New Issue
Block a user