Merge pull request #575 from mpretty-cyro/fix/config-message-bugs

Fixes for config message handling
This commit is contained in:
RyanZhao 2022-03-10 10:02:49 +11:00 committed by GitHub
commit d7bbd03dab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -30,6 +30,15 @@ public final class OpenGroupManagerV2 : NSObject {
// MARK: Adding & Removing
public func add(room: String, server: String, publicKey: String, using transaction: Any) -> Promise<Void> {
// If we are currently polling for this server and already have a TSGroupThread for this room the do nothing
let transaction = transaction as! YapDatabaseReadWriteTransaction
let groupId: Data = LKGroupUtilities.getEncodedOpenGroupIDAsData("\(server).\(room)")
if OpenGroupManagerV2.shared.pollers[server] != nil && TSGroupThread.fetch(uniqueId: TSGroupThread.threadId(fromGroupId: groupId), transaction: transaction) != nil {
SNLog("Ignoring join open group attempt (already joined)")
return Promise.value(())
}
let storage = Storage.shared
// Clear any existing data if needed
storage.removeLastMessageServerID(for: room, on: server, using: transaction)
@ -38,7 +47,7 @@ public final class OpenGroupManagerV2 : NSObject {
// Store the public key
storage.setOpenGroupPublicKey(for: server, to: publicKey, using: transaction)
let (promise, seal) = Promise<Void>.pending()
let transaction = transaction as! YapDatabaseReadWriteTransaction
transaction.addCompletionQueue(DispatchQueue.global(qos: .userInitiated)) {
// Get the group info
OpenGroupAPIV2.getInfo(for: room, on: server).done(on: DispatchQueue.global(qos: .userInitiated)) { info in

View File

@ -211,7 +211,7 @@ extension MessageReceiver {
// Contacts
for contactInfo in message.contacts {
let sessionID = contactInfo.publicKey!
let contact = Contact(sessionID: sessionID)
let contact = (Storage.shared.getContact(with: sessionID, using: transaction) ?? Contact(sessionID: sessionID))
if let profileKey = contactInfo.profileKey { contact.profileEncryptionKey = OWSAES256Key(data: profileKey) }
contact.profilePictureURL = contactInfo.profilePictureURL
contact.name = contactInfo.displayName