Sketch out "contact share" model.
This commit is contained in:
parent
6005747856
commit
4b8a2fa8a3
2
Pods
2
Pods
|
@ -1 +1 @@
|
|||
Subproject commit e67a14d7af8c1e54e2e68aa4488a7528eb99e896
|
||||
Subproject commit 7f6203376010de8838e21a2c22546f10fc24f712
|
|
@ -2948,6 +2948,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[ThreadUtil sendMessageWithAttachment:attachment
|
||||
inThread:thread
|
||||
quotedReplyModel:nil
|
||||
contactShare:nil
|
||||
messageSender:messageSender
|
||||
ignoreErrors:YES
|
||||
completion:nil];
|
||||
|
@ -3256,7 +3257,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
messageBody:randomText
|
||||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
break;
|
||||
}
|
||||
|
@ -3294,7 +3296,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
pointer.uniqueId,
|
||||
]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
break;
|
||||
}
|
||||
|
@ -3680,7 +3683,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
: 0)expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
DDLogError(@"%@ resurrectNewOutgoingMessages2 timestamp: %llu.", self.logTag, message.timestamp);
|
||||
[messages addObject:message];
|
||||
}
|
||||
|
@ -3745,7 +3749,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
messageBody:randomText
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
}
|
||||
{
|
||||
|
@ -3758,7 +3763,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
[message saveWithTransaction:transaction];
|
||||
[message updateWithFakeMessageState:TSOutgoingMessageStateSent transaction:transaction];
|
||||
[message updateWithSentRecipient:recipientId transaction:transaction];
|
||||
|
@ -3994,7 +4000,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:isVoiceMessage
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:quotedMessage];
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:nil];
|
||||
|
||||
if (attachmentId.length > 0 && filename.length > 0) {
|
||||
message.attachmentFilenameMap[attachmentId] = filename;
|
||||
|
@ -4081,7 +4088,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
messageBody:messageBody
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:0
|
||||
quotedMessage:quotedMessage];
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:nil];
|
||||
[message markAsReadNowWithSendReadReceipt:NO transaction:transaction];
|
||||
return message;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
#pragma mark -
|
||||
|
||||
@class OWSContactShare;
|
||||
@class OWSQuotedReplyModel;
|
||||
@class TSOutgoingMessage;
|
||||
|
||||
|
@ -71,6 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
+ (TSOutgoingMessage *)sendMessageWithAttachment:(SignalAttachment *)attachment
|
||||
inThread:(TSThread *)thread
|
||||
quotedReplyModel:(nullable OWSQuotedReplyModel *)quotedReplyModel
|
||||
contactShare:(nullable OWSContactShare *)contactShare
|
||||
messageSender:(OWSMessageSender *)messageSender
|
||||
ignoreErrors:(BOOL)ignoreErrors
|
||||
completion:(void (^_Nullable)(NSError *_Nullable error))completion;
|
||||
|
|
|
@ -107,6 +107,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return [self sendMessageWithAttachment:attachment
|
||||
inThread:thread
|
||||
quotedReplyModel:quotedReplyModel
|
||||
contactShare:nil
|
||||
messageSender:messageSender
|
||||
ignoreErrors:NO
|
||||
completion:completion];
|
||||
|
@ -115,6 +116,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
+ (TSOutgoingMessage *)sendMessageWithAttachment:(SignalAttachment *)attachment
|
||||
inThread:(TSThread *)thread
|
||||
quotedReplyModel:(nullable OWSQuotedReplyModel *)quotedReplyModel
|
||||
contactShare:(nullable OWSContactShare *)contactShare
|
||||
messageSender:(OWSMessageSender *)messageSender
|
||||
ignoreErrors:(BOOL)ignoreErrors
|
||||
completion:(void (^_Nullable)(NSError *_Nullable error))completion
|
||||
|
@ -139,7 +141,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:[attachment isVoiceMessage]
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:[quotedReplyModel buildQuotedMessage]];
|
||||
quotedMessage:[quotedReplyModel buildQuotedMessage]
|
||||
contactShare:contactShare];
|
||||
|
||||
[messageSender enqueueAttachment:attachment.dataSource
|
||||
contentType:attachment.mimeType
|
||||
|
|
|
@ -29,7 +29,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:transcript.expirationStartedAt
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:transcript.quotedMessage];
|
||||
quotedMessage:transcript.quotedMessage
|
||||
contactShare:transcript.contactShare];
|
||||
|
||||
// TODO: When written, desktop didn't yet support sending quotedMessages, so we didn't have a
|
||||
// good way to test the handling of transcripts with a quotedMessage. This assertion can be delete
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class OWSContactShare;
|
||||
@class OWSSignalServiceProtosAttachmentPointer;
|
||||
@class OWSSignalServiceProtosDataMessage;
|
||||
@class OWSSignalServiceProtosSyncMessageSent;
|
||||
|
@ -35,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property (nonatomic, readonly) NSArray<OWSSignalServiceProtosAttachmentPointer *> *attachmentPointerProtos;
|
||||
@property (nonatomic, readonly) TSThread *thread;
|
||||
@property (nonatomic, readonly) TSQuotedMessage *quotedMessage;
|
||||
@property (nonatomic, readonly) OWSContactShare *contactShare;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
//
|
||||
|
||||
#import "OWSIncomingSentMessageTranscript.h"
|
||||
#import "OWSContactShare.h"
|
||||
#import "OWSMessageManager.h"
|
||||
#import "OWSPrimaryStorage.h"
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
|
@ -46,6 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
_quotedMessage =
|
||||
[TSQuotedMessage quotedMessageForDataMessage:_dataMessage thread:_thread relay:relay transaction:transaction];
|
||||
_contactShare = [OWSContactShare contactShareMessageForDataMessage:_dataMessage transaction:transaction];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -38,7 +38,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
}
|
||||
|
||||
- (OWSSignalServiceProtosSyncMessageBuilder *)syncMessageBuilder
|
||||
|
|
|
@ -28,7 +28,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Mantle/MTLModel.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class OWSSignalServiceProtosDataMessage;
|
||||
@class TSAttachment;
|
||||
@class YapDatabaseReadWriteTransaction;
|
||||
|
||||
typedef NS_ENUM(NSUInteger, OWSContactSharePhoneType) {
|
||||
OWSContactSharePhoneType_Home = 1,
|
||||
OWSContactSharePhoneType_Mobile,
|
||||
OWSContactSharePhoneType_Work,
|
||||
OWSContactSharePhoneType_Custom,
|
||||
};
|
||||
|
||||
@interface OWSContactSharePhoneNumber : MTLModel
|
||||
|
||||
@property (nonatomic, readonly) OWSContactSharePhoneType phoneType;
|
||||
// Applies in the OWSContactSharePhoneType_Custom case.
|
||||
@property (nonatomic, readonly, nullable) NSString *label;
|
||||
|
||||
@property (nonatomic, readonly) NSString *phoneNumber;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
typedef NS_ENUM(NSUInteger, OWSContactShareEmailType) {
|
||||
OWSContactShareEmailType_Home = 1,
|
||||
OWSContactShareEmailType_Mobile,
|
||||
OWSContactShareEmailType_Work,
|
||||
OWSContactShareEmailType_Custom,
|
||||
};
|
||||
|
||||
@interface OWSContactShareEmail : MTLModel
|
||||
|
||||
@property (nonatomic, readonly) OWSContactShareEmailType emailType;
|
||||
// Applies in the OWSContactShareEmailType_Custom case.
|
||||
@property (nonatomic, readonly, nullable) NSString *label;
|
||||
|
||||
@property (nonatomic, readonly) NSString *email;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
typedef NS_ENUM(NSUInteger, OWSContactShareAddressType) {
|
||||
OWSContactShareAddressType_Home = 1,
|
||||
OWSContactShareAddressType_Work,
|
||||
OWSContactShareAddressType_Custom,
|
||||
};
|
||||
|
||||
@interface OWSContactShareAddress : MTLModel
|
||||
|
||||
@property (nonatomic, readonly) OWSContactShareAddressType addressType;
|
||||
// Applies in the OWSContactShareAddressType_Custom case.
|
||||
@property (nonatomic, readonly, nullable) NSString *label;
|
||||
|
||||
@property (nonatomic, readonly, nullable) NSString *street;
|
||||
@property (nonatomic, readonly, nullable) NSString *pobox;
|
||||
@property (nonatomic, readonly, nullable) NSString *neighborhood;
|
||||
@property (nonatomic, readonly, nullable) NSString *city;
|
||||
@property (nonatomic, readonly, nullable) NSString *region;
|
||||
@property (nonatomic, readonly, nullable) NSString *postcode;
|
||||
@property (nonatomic, readonly, nullable) NSString *country;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@interface OWSContactShare : MTLModel
|
||||
|
||||
@property (nonatomic, readonly, nullable) NSString *givenName;
|
||||
@property (nonatomic, readonly, nullable) NSString *familyName;
|
||||
@property (nonatomic, readonly, nullable) NSString *nameSuffix;
|
||||
@property (nonatomic, readonly, nullable) NSString *namePrefix;
|
||||
@property (nonatomic, readonly, nullable) NSString *middleName;
|
||||
|
||||
@property (nonatomic, readonly, nullable) NSArray<OWSContactSharePhoneNumber *> *phoneNumbers;
|
||||
@property (nonatomic, readonly, nullable) NSArray<OWSContactShareEmail *> *emails;
|
||||
@property (nonatomic, readonly, nullable) NSArray<OWSContactShareAddress *> *addresses;
|
||||
|
||||
// TODO: This is provisional.
|
||||
@property (nonatomic, readonly, nullable) TSAttachment *avatar;
|
||||
// "Profile" avatars should _not_ be saved to device contacts.
|
||||
@property (nonatomic, readonly) BOOL isProfileAvatar;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
+ (OWSContactShare *_Nullable)contactShareMessageForDataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,259 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSContactShare.h"
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
#import "TSAttachment.h"
|
||||
#import <YapDatabase/YapDatabaseTransaction.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSContactSharePhoneNumber ()
|
||||
|
||||
@property (nonatomic) OWSContactSharePhoneType phoneType;
|
||||
@property (nonatomic, nullable) NSString *label;
|
||||
|
||||
@property (nonatomic) NSString *phoneNumber;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSContactSharePhoneNumber
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@interface OWSContactShareEmail ()
|
||||
|
||||
@property (nonatomic) OWSContactShareEmailType emailType;
|
||||
@property (nonatomic, nullable) NSString *label;
|
||||
|
||||
@property (nonatomic) NSString *email;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSContactShareEmail
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@interface OWSContactShareAddress ()
|
||||
|
||||
@property (nonatomic) OWSContactShareAddressType addressType;
|
||||
@property (nonatomic, nullable) NSString *label;
|
||||
|
||||
@property (nonatomic, nullable) NSString *street;
|
||||
@property (nonatomic, nullable) NSString *pobox;
|
||||
@property (nonatomic, nullable) NSString *neighborhood;
|
||||
@property (nonatomic, nullable) NSString *city;
|
||||
@property (nonatomic, nullable) NSString *region;
|
||||
@property (nonatomic, nullable) NSString *postcode;
|
||||
@property (nonatomic, nullable) NSString *country;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSContactShareAddress
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@interface OWSContactShare ()
|
||||
|
||||
@property (nonatomic, nullable) NSString *givenName;
|
||||
@property (nonatomic, nullable) NSString *familyName;
|
||||
@property (nonatomic, nullable) NSString *nameSuffix;
|
||||
@property (nonatomic, nullable) NSString *namePrefix;
|
||||
@property (nonatomic, nullable) NSString *middleName;
|
||||
|
||||
@property (nonatomic, nullable) NSArray<OWSContactSharePhoneNumber *> *phoneNumbers;
|
||||
@property (nonatomic, nullable) NSArray<OWSContactShareEmail *> *emails;
|
||||
@property (nonatomic, nullable) NSArray<OWSContactShareAddress *> *addresses;
|
||||
|
||||
@property (nonatomic, nullable) TSAttachment *avatar;
|
||||
@property (nonatomic) BOOL isProfileAvatar;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSContactShare
|
||||
|
||||
+ (OWSContactShare *_Nullable)contactShareMessageForDataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
OWSAssert(dataMessage);
|
||||
|
||||
if (dataMessage.contact.count < 1) {
|
||||
return nil;
|
||||
}
|
||||
OWSAssert(dataMessage.contact.count == 1);
|
||||
OWSSignalServiceProtosDataMessageContact *contactProto = dataMessage.contact.firstObject;
|
||||
|
||||
OWSContactShare *contactShare = [OWSContactShare new];
|
||||
if (contactProto.hasName) {
|
||||
OWSSignalServiceProtosDataMessageContactName *nameProto = contactProto.name;
|
||||
|
||||
if (nameProto.hasGivenName) {
|
||||
contactShare.givenName = nameProto.givenName;
|
||||
}
|
||||
if (nameProto.hasFamilyName) {
|
||||
contactShare.familyName = nameProto.familyName;
|
||||
}
|
||||
if (nameProto.hasPrefix) {
|
||||
contactShare.namePrefix = nameProto.prefix;
|
||||
}
|
||||
if (nameProto.hasSuffix) {
|
||||
contactShare.nameSuffix = nameProto.suffix;
|
||||
}
|
||||
if (nameProto.hasMiddleName) {
|
||||
contactShare.middleName = nameProto.middleName;
|
||||
}
|
||||
}
|
||||
|
||||
NSMutableArray<OWSContactSharePhoneNumber *> *phoneNumbers = [NSMutableArray new];
|
||||
for (OWSSignalServiceProtosDataMessageContactPhone *phoneNumberProto in contactProto.number) {
|
||||
OWSContactSharePhoneNumber *_Nullable phoneNumber = [self phoneNumberForProto:phoneNumberProto];
|
||||
if (phoneNumber) {
|
||||
[phoneNumbers addObject:phoneNumber];
|
||||
}
|
||||
}
|
||||
contactShare.phoneNumbers = [phoneNumbers copy];
|
||||
|
||||
NSMutableArray<OWSContactShareEmail *> *emails = [NSMutableArray new];
|
||||
for (OWSSignalServiceProtosDataMessageContactEmail *emailProto in contactProto.email) {
|
||||
OWSContactShareEmail *_Nullable email = [self emailForProto:emailProto];
|
||||
if (email) {
|
||||
[emails addObject:email];
|
||||
}
|
||||
}
|
||||
contactShare.emails = [emails copy];
|
||||
|
||||
NSMutableArray<OWSContactShareAddress *> *addresses = [NSMutableArray new];
|
||||
for (OWSSignalServiceProtosDataMessageContactPostalAddress *addressProto in contactProto.address) {
|
||||
OWSContactShareAddress *_Nullable address = [self addressForProto:addressProto];
|
||||
if (address) {
|
||||
[addresses addObject:address];
|
||||
}
|
||||
}
|
||||
contactShare.addresses = [addresses copy];
|
||||
|
||||
return contactShare;
|
||||
}
|
||||
|
||||
+ (nullable OWSContactSharePhoneNumber *)phoneNumberForProto:
|
||||
(OWSSignalServiceProtosDataMessageContactPhone *)phoneNumberProto
|
||||
{
|
||||
OWSContactSharePhoneNumber *result = [OWSContactSharePhoneNumber new];
|
||||
result.phoneType = OWSContactSharePhoneType_Custom;
|
||||
if (phoneNumberProto.hasType) {
|
||||
switch (phoneNumberProto.type) {
|
||||
case OWSSignalServiceProtosDataMessageContactPhoneTypeHome:
|
||||
result.phoneType = OWSContactSharePhoneType_Home;
|
||||
break;
|
||||
case OWSSignalServiceProtosDataMessageContactPhoneTypeMobile:
|
||||
result.phoneType = OWSContactSharePhoneType_Mobile;
|
||||
break;
|
||||
case OWSSignalServiceProtosDataMessageContactPhoneTypeWork:
|
||||
result.phoneType = OWSContactSharePhoneType_Work;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (phoneNumberProto.hasLabel) {
|
||||
result.label = phoneNumberProto.label;
|
||||
}
|
||||
if (phoneNumberProto.hasValue) {
|
||||
result.phoneNumber = phoneNumberProto.value;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+ (nullable OWSContactShareEmail *)emailForProto:(OWSSignalServiceProtosDataMessageContactEmail *)emailProto
|
||||
{
|
||||
OWSContactShareEmail *result = [OWSContactShareEmail new];
|
||||
result.emailType = OWSContactShareEmailType_Custom;
|
||||
if (emailProto.hasType) {
|
||||
switch (emailProto.type) {
|
||||
case OWSSignalServiceProtosDataMessageContactEmailTypeHome:
|
||||
result.emailType = OWSContactShareEmailType_Home;
|
||||
break;
|
||||
case OWSSignalServiceProtosDataMessageContactEmailTypeMobile:
|
||||
result.emailType = OWSContactShareEmailType_Mobile;
|
||||
break;
|
||||
case OWSSignalServiceProtosDataMessageContactEmailTypeWork:
|
||||
result.emailType = OWSContactShareEmailType_Work;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (emailProto.hasLabel) {
|
||||
result.label = emailProto.label;
|
||||
}
|
||||
if (emailProto.hasValue) {
|
||||
result.email = emailProto.value;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+ (nullable OWSContactShareAddress *)addressForProto:
|
||||
(OWSSignalServiceProtosDataMessageContactPostalAddress *)addressProto
|
||||
{
|
||||
OWSContactShareAddress *result = [OWSContactShareAddress new];
|
||||
result.addressType = OWSContactShareAddressType_Custom;
|
||||
if (addressProto.hasType) {
|
||||
switch (addressProto.type) {
|
||||
case OWSSignalServiceProtosDataMessageContactPostalAddressTypeHome:
|
||||
result.addressType = OWSContactShareAddressType_Home;
|
||||
break;
|
||||
case OWSSignalServiceProtosDataMessageContactPostalAddressTypeWork:
|
||||
result.addressType = OWSContactShareAddressType_Work;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (addressProto.hasLabel) {
|
||||
result.label = addressProto.label;
|
||||
}
|
||||
if (addressProto.hasStreet) {
|
||||
result.street = addressProto.street;
|
||||
}
|
||||
if (addressProto.hasPobox) {
|
||||
result.pobox = addressProto.pobox;
|
||||
}
|
||||
if (addressProto.hasNeighborhood) {
|
||||
result.neighborhood = addressProto.neighborhood;
|
||||
}
|
||||
if (addressProto.hasCity) {
|
||||
result.city = addressProto.city;
|
||||
}
|
||||
if (addressProto.hasRegion) {
|
||||
result.region = addressProto.region;
|
||||
}
|
||||
if (addressProto.hasPostcode) {
|
||||
result.postcode = addressProto.postcode;
|
||||
}
|
||||
if (addressProto.hasCountry) {
|
||||
result.country = addressProto.country;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -34,7 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
|
||||
if (self) {
|
||||
_block = block;
|
||||
|
|
|
@ -19,7 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
}
|
||||
|
||||
- (BOOL)shouldBeSaved
|
||||
|
|
|
@ -65,7 +65,8 @@ NSUInteger TSErrorMessageSchemaVersion = 1;
|
|||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -49,7 +49,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
messageBody:(nullable NSString *)body
|
||||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage NS_DESIGNATED_INITIALIZER;
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContactShare *)contactShare NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContactShare *)contactShare
|
||||
{
|
||||
self = [super initMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
|
@ -51,7 +52,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
quotedMessage:quotedMessage];
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -34,7 +34,8 @@ typedef NS_ENUM(NSInteger, TSInfoMessageType) {
|
|||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage NS_UNAVAILABLE;
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContactShare *)contactShare NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -52,7 +52,8 @@ NSUInteger TSInfoMessageSchemaVersion = 1;
|
|||
attachmentIds:@[]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
|
|
|
@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* Abstract message class.
|
||||
*/
|
||||
|
||||
@class OWSContactShare;
|
||||
@class TSAttachment;
|
||||
@class TSAttachmentStream;
|
||||
@class TSQuotedMessage;
|
||||
|
@ -24,6 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property (nonatomic, readonly) uint64_t expiresAt;
|
||||
@property (nonatomic, readonly) BOOL isExpiringMessage;
|
||||
@property (nonatomic, readonly, nullable) TSQuotedMessage *quotedMessage;
|
||||
@property (nonatomic, readonly, nullable) OWSContactShare *contactShare;
|
||||
|
||||
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE;
|
||||
|
||||
|
@ -33,7 +35,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
attachmentIds:(NSArray<NSString *> *)attachmentIds
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage NS_DESIGNATED_INITIALIZER;
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContactShare *)contactShare NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#import "MIMETypeUtil.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "NSString+SSK.h"
|
||||
#import "OWSContactShare.h"
|
||||
#import "TSAttachment.h"
|
||||
#import "TSAttachmentStream.h"
|
||||
#import "TSQuotedMessage.h"
|
||||
|
@ -65,6 +66,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContactShare *)contactShare
|
||||
{
|
||||
self = [super initInteractionWithTimestamp:timestamp inThread:thread];
|
||||
|
||||
|
@ -81,6 +83,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
[self updateExpiresAt];
|
||||
_receivedAtTimestamp = [NSDate ows_millisecondTimeStamp];
|
||||
_quotedMessage = quotedMessage;
|
||||
_contactShare = contactShare;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,8 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
|
|||
expireStartedAt:(uint64_t)expireStartedAt
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage NS_DESIGNATED_INITIALIZER;
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContactShare *)contactShare NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -242,7 +242,8 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:quotedMessage];
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:nil];
|
||||
}
|
||||
|
||||
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
|
||||
|
@ -256,7 +257,8 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:groupMetaMessage
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
|
@ -268,6 +270,7 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
|
|||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
contactShare:(nullable OWSContactShare *)contactShare
|
||||
{
|
||||
self = [super initMessageWithTimestamp:timestamp
|
||||
inThread:thread
|
||||
|
@ -275,7 +278,8 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
|
|||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:expireStartedAt
|
||||
quotedMessage:quotedMessage];
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#import "OWSAttachmentsProcessor.h"
|
||||
#import "OWSBlockingManager.h"
|
||||
#import "OWSCallMessageHandler.h"
|
||||
#import "OWSContactShare.h"
|
||||
#import "OWSDevice.h"
|
||||
#import "OWSDisappearingConfigurationUpdateInfoMessage.h"
|
||||
#import "OWSDisappearingMessagesConfiguration.h"
|
||||
|
@ -996,6 +997,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
relay:envelope.relay
|
||||
transaction:transaction];
|
||||
|
||||
OWSContactShare *_Nullable contactShare =
|
||||
[OWSContactShare contactShareMessageForDataMessage:dataMessage transaction:transaction];
|
||||
|
||||
DDLogDebug(@"%@ incoming message from: %@ for group: %@ with timestamp: %lu",
|
||||
self.logTag,
|
||||
envelopeAddress(envelope),
|
||||
|
@ -1010,7 +1014,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:dataMessage.expireTimer
|
||||
quotedMessage:quotedMessage];
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
|
||||
[self finalizeIncomingMessage:incomingMessage
|
||||
thread:oldGroupThread
|
||||
|
@ -1044,6 +1049,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
thread:thread
|
||||
relay:envelope.relay
|
||||
transaction:transaction];
|
||||
OWSContactShare *_Nullable contactShare =
|
||||
[OWSContactShare contactShareMessageForDataMessage:dataMessage transaction:transaction];
|
||||
|
||||
TSIncomingMessage *incomingMessage =
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithTimestamp:timestamp
|
||||
|
@ -1053,7 +1060,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:dataMessage.expireTimer
|
||||
quotedMessage:quotedMessage];
|
||||
quotedMessage:quotedMessage
|
||||
contactShare:contactShare];
|
||||
|
||||
[self finalizeIncomingMessage:incomingMessage
|
||||
thread:thread
|
||||
|
|
|
@ -1154,6 +1154,9 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
}
|
||||
|
||||
// We want the incoming message to appear after the outgoing message.
|
||||
//
|
||||
// TODO: We need to be careful to duplicate the attachments for
|
||||
// quoted message and contact share.
|
||||
TSIncomingMessage *incomingMessage =
|
||||
[[TSIncomingMessage alloc] initIncomingMessageWithTimestamp:(outgoingMessage.timestamp + 1)
|
||||
inThread:cThread
|
||||
|
@ -1162,7 +1165,8 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
messageBody:outgoingMessage.body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:outgoingMessage.expiresInSeconds
|
||||
quotedMessage:outgoingMessage.quotedMessage];
|
||||
quotedMessage:outgoingMessage.quotedMessage
|
||||
contactShare:outgoingMessage.contactShare];
|
||||
[incomingMessage saveWithTransaction:transaction];
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUnspecified
|
||||
quotedMessage:nil];
|
||||
quotedMessage:nil
|
||||
contactShare:nil];
|
||||
}
|
||||
|
||||
- (BOOL)shouldBeSaved
|
||||
|
|
Loading…
Reference in New Issue