Fix bug where slave devices were being shown in private group chats

pull/83/head
Mikunj 5 years ago
parent 99046145a3
commit ecc40368cb

@ -4,10 +4,16 @@ final class NewClosedGroupVC : UIViewController, UITableViewDataSource, UITableV
private lazy var contacts: [String] = {
var result: [String] = []
TSContactThread.enumerateCollectionObjects { object, _ in
guard let thread = object as? TSContactThread, thread.isContactFriend else { return }
let hexEncodedPublicKey = thread.contactIdentifier()
result.append(hexEncodedPublicKey)
let storage = OWSPrimaryStorage.shared()
storage.dbReadConnection.read { transaction in
TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in
guard let thread = object as? TSContactThread, thread.isContactFriend else { return }
let hexEncodedPublicKey = thread.contactIdentifier()
// We shouldn't be able to add slave devices to groups
if (storage.getMasterHexEncodedPublicKey(for: hexEncodedPublicKey, in: transaction) == nil) {
result.append(hexEncodedPublicKey)
}
}
}
func getDisplayName(for hexEncodedPublicKey: String) -> String {
return UserDisplayNameUtilities.getPrivateChatDisplayName(for: hexEncodedPublicKey) ?? "Unknown Contact"

@ -10,10 +10,12 @@ public enum GroupUtilities {
}
public static func getClosedGroupMembers(_ closedGroup: TSGroupThread, with transaction: YapDatabaseReadTransaction) -> [String] {
let storage = OWSPrimaryStorage.shared()
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
var linkedDeviceHexEncodedPublicKeys = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: userHexEncodedPublicKey, in: transaction)
linkedDeviceHexEncodedPublicKeys.remove(userHexEncodedPublicKey) // Show the user as a member
return closedGroup.groupModel.groupMemberIds.filter { !linkedDeviceHexEncodedPublicKeys.contains($0) }
return closedGroup.groupModel.groupMemberIds.filter { member in
// Don't show any slave devices
return storage.getMasterHexEncodedPublicKey(for: member, in: transaction) == nil
}
}
public static func getClosedGroupMemberCount(_ closedGroup: TSGroupThread) -> Int {

Loading…
Cancel
Save