2014-07-10 16:11:09 +02:00
|
|
|
/*
|
|
|
|
* This is the source code of Telegram for iOS v. 1.1
|
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
*
|
|
|
|
* Copyright Peter Iakovlev, 2013.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import "TGPreparedContactMessage.h"
|
|
|
|
|
|
|
|
#import "TGMessage.h"
|
|
|
|
|
|
|
|
@implementation TGPreparedContactMessage
|
|
|
|
|
2015-10-01 18:19:52 +02:00
|
|
|
- (instancetype)initWithUid:(int32_t)uid firstName:(NSString *)firstName lastName:(NSString *)lastName phoneNumber:(NSString *)phoneNumber replyMessage:(TGMessage *)replyMessage
|
2014-07-10 16:11:09 +02:00
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self != nil)
|
|
|
|
{
|
|
|
|
_uid = uid;
|
|
|
|
_firstName = firstName;
|
|
|
|
_lastName = lastName;
|
|
|
|
_phoneNumber = phoneNumber;
|
2015-10-01 18:19:52 +02:00
|
|
|
_replyMessage = replyMessage;
|
2014-07-10 16:11:09 +02:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2015-10-01 18:19:52 +02:00
|
|
|
- (instancetype)initWithFirstName:(NSString *)firstName lastName:(NSString *)lastName phoneNumber:(NSString *)phoneNumber replyMessage:(TGMessage *)replyMessage
|
2014-07-10 16:11:09 +02:00
|
|
|
{
|
2015-10-01 18:19:52 +02:00
|
|
|
return [self initWithUid:0 firstName:firstName lastName:lastName phoneNumber:phoneNumber replyMessage:replyMessage];
|
2014-07-10 16:11:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (TGMessage *)message
|
|
|
|
{
|
|
|
|
TGMessage *message = [[TGMessage alloc] init];
|
|
|
|
message.mid = self.mid;
|
|
|
|
message.date = self.date;
|
2015-10-01 18:19:52 +02:00
|
|
|
message.isBroadcast = self.isBroadcast;
|
|
|
|
message.messageLifetime = self.messageLifetime;
|
|
|
|
|
|
|
|
NSMutableArray *attachments = [[NSMutableArray alloc] init];
|
2014-07-10 16:11:09 +02:00
|
|
|
|
|
|
|
TGContactMediaAttachment *contactAttachment = [[TGContactMediaAttachment alloc] init];
|
|
|
|
contactAttachment.uid = _uid;
|
|
|
|
contactAttachment.firstName = _firstName;
|
|
|
|
contactAttachment.lastName = _lastName;
|
|
|
|
contactAttachment.phoneNumber = _phoneNumber;
|
2015-10-01 18:19:52 +02:00
|
|
|
[attachments addObject:contactAttachment];
|
|
|
|
|
|
|
|
if (_replyMessage != nil)
|
|
|
|
{
|
|
|
|
TGReplyMessageMediaAttachment *replyMedia = [[TGReplyMessageMediaAttachment alloc] init];
|
|
|
|
replyMedia.replyMessageId = _replyMessage.mid;
|
|
|
|
replyMedia.replyMessage = _replyMessage;
|
|
|
|
[attachments addObject:replyMedia];
|
|
|
|
}
|
2014-07-10 16:11:09 +02:00
|
|
|
|
2015-10-01 18:19:52 +02:00
|
|
|
message.mediaAttachments = attachments;
|
2014-07-10 16:11:09 +02:00
|
|
|
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|