Merge pull request #575 from mpretty-cyro/fix/config-message-bugs
Fixes for config message handling
This commit is contained in:
commit
d7bbd03dab
|
@ -30,6 +30,15 @@ public final class OpenGroupManagerV2 : NSObject {
|
||||||
|
|
||||||
// MARK: Adding & Removing
|
// MARK: Adding & Removing
|
||||||
public func add(room: String, server: String, publicKey: String, using transaction: Any) -> Promise<Void> {
|
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
|
let storage = Storage.shared
|
||||||
// Clear any existing data if needed
|
// Clear any existing data if needed
|
||||||
storage.removeLastMessageServerID(for: room, on: server, using: transaction)
|
storage.removeLastMessageServerID(for: room, on: server, using: transaction)
|
||||||
|
@ -38,7 +47,7 @@ public final class OpenGroupManagerV2 : NSObject {
|
||||||
// Store the public key
|
// Store the public key
|
||||||
storage.setOpenGroupPublicKey(for: server, to: publicKey, using: transaction)
|
storage.setOpenGroupPublicKey(for: server, to: publicKey, using: transaction)
|
||||||
let (promise, seal) = Promise<Void>.pending()
|
let (promise, seal) = Promise<Void>.pending()
|
||||||
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
|
||||||
transaction.addCompletionQueue(DispatchQueue.global(qos: .userInitiated)) {
|
transaction.addCompletionQueue(DispatchQueue.global(qos: .userInitiated)) {
|
||||||
// Get the group info
|
// Get the group info
|
||||||
OpenGroupAPIV2.getInfo(for: room, on: server).done(on: DispatchQueue.global(qos: .userInitiated)) { info in
|
OpenGroupAPIV2.getInfo(for: room, on: server).done(on: DispatchQueue.global(qos: .userInitiated)) { info in
|
||||||
|
|
|
@ -211,7 +211,7 @@ extension MessageReceiver {
|
||||||
// Contacts
|
// Contacts
|
||||||
for contactInfo in message.contacts {
|
for contactInfo in message.contacts {
|
||||||
let sessionID = contactInfo.publicKey!
|
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) }
|
if let profileKey = contactInfo.profileKey { contact.profileEncryptionKey = OWSAES256Key(data: profileKey) }
|
||||||
contact.profilePictureURL = contactInfo.profilePictureURL
|
contact.profilePictureURL = contactInfo.profilePictureURL
|
||||||
contact.name = contactInfo.displayName
|
contact.name = contactInfo.displayName
|
||||||
|
|
Loading…
Reference in New Issue