|
|
|
|
@ -150,22 +150,30 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
|
|
|
|
|
|
|
|
|
|
if (self.attachment.isConvertibleToContactShare) {
|
|
|
|
|
NSData *data = self.attachment.data;
|
|
|
|
|
OWSContact *_Nullable contact = [OWSContacts contactForVCardData:data];
|
|
|
|
|
|
|
|
|
|
if (!contact) {
|
|
|
|
|
// This should never happen since we verify that the contact can be parsed when building the attachment.
|
|
|
|
|
OWSFail(@"%@ could not parse contact share.", self.logTag);
|
|
|
|
|
[self.shareViewDelegate shareViewWasCancelled];
|
|
|
|
|
Contact *_Nullable contact = [Contact contactWithVCardData:data];
|
|
|
|
|
OWSContact *_Nullable contactShareRecord = [OWSContacts contactForSystemContact:contact.cnContact];
|
|
|
|
|
if (!contactShareRecord) {
|
|
|
|
|
DDLogError(@"%@ Could not convert system contact.", self.logTag);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Populate avatar image.
|
|
|
|
|
BOOL isProfileAvatar = NO;
|
|
|
|
|
NSData *_Nullable avatarImageData = nil;
|
|
|
|
|
contact.isProfileAvatar = isProfileAvatar;
|
|
|
|
|
NSData *_Nullable avatarImageData = contact.imageData;
|
|
|
|
|
for (NSString *recipientId in contact.textSecureIdentifiers) {
|
|
|
|
|
if (avatarImageData) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
avatarImageData = [self.contactsManager profileImageDataForPhoneIdentifier:recipientId];
|
|
|
|
|
if (avatarImageData) {
|
|
|
|
|
isProfileAvatar = YES;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
contactShareRecord.isProfileAvatar = isProfileAvatar;
|
|
|
|
|
|
|
|
|
|
ContactShareViewModel *contactShare =
|
|
|
|
|
[[ContactShareViewModel alloc] initWithContactShareRecord:contact avatarImageData:avatarImageData];
|
|
|
|
|
[[ContactShareViewModel alloc] initWithContactShareRecord:contactShareRecord
|
|
|
|
|
avatarImageData:avatarImageData];
|
|
|
|
|
|
|
|
|
|
ApproveContactShareViewController *approvalVC =
|
|
|
|
|
[[ApproveContactShareViewController alloc] initWithContactShare:contactShare
|
|
|
|
|
|