Include contacts in configuration message
This commit is contained in:
parent
f488453140
commit
643bfbdb41
|
@ -9,6 +9,7 @@ extension ConfigurationMessage {
|
|||
var closedGroups: Set<ClosedGroup> = []
|
||||
var openGroups: Set<String> = []
|
||||
var contacts: Set<Contact> = []
|
||||
var contactCount = 0
|
||||
Storage.read { transaction in
|
||||
TSGroupThread.enumerateCollectionObjects(with: transaction) { object, _ in
|
||||
guard let thread = object as? TSGroupThread else { return }
|
||||
|
@ -28,6 +29,17 @@ extension ConfigurationMessage {
|
|||
default: break
|
||||
}
|
||||
}
|
||||
OWSUserProfile.enumerateCollectionObjects(with: transaction) { object, stop in
|
||||
guard let profile = object as? OWSUserProfile, let displayName = profile.profileName else { return }
|
||||
let publicKey = profile.recipientId
|
||||
let profilePictureURL = profile.avatarUrlPath
|
||||
let profileKey = profile.profileKey?.keyData
|
||||
let contact = ConfigurationMessage.Contact(publicKey: publicKey, displayName: displayName,
|
||||
profilePictureURL: profilePictureURL, profileKey: profileKey)
|
||||
contacts.insert(contact)
|
||||
guard contactCount < 200 else { stop.pointee = true; return }
|
||||
contactCount += 1
|
||||
}
|
||||
}
|
||||
return ConfigurationMessage(displayName: displayName, profilePictureURL: profilePictureURL, profileKey: profileKey,
|
||||
closedGroups: closedGroups, openGroups: openGroups, contacts: contacts)
|
||||
|
|
Loading…
Reference in New Issue