mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.8 KiB
Matlab
64 lines
1.8 KiB
Matlab
9 years ago
|
//
|
||
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||
|
//
|
||
9 years ago
|
|
||
|
#import "OWSIncomingSentMessageTranscript.h"
|
||
|
#import "OWSAttachmentsProcessor.h"
|
||
|
#import "OWSSignalServiceProtos.pb.h"
|
||
|
#import "TSMessagesManager.h"
|
||
|
#import "TSOutgoingMessage.h"
|
||
|
#import "TSThread.h"
|
||
|
|
||
|
// Thread finding imports
|
||
|
#import "TSContactThread.h"
|
||
|
#import "TSGroupModel.h"
|
||
|
#import "TSGroupThread.h"
|
||
|
|
||
|
NS_ASSUME_NONNULL_BEGIN
|
||
|
|
||
|
@implementation OWSIncomingSentMessageTranscript
|
||
|
|
||
|
- (instancetype)initWithProto:(OWSSignalServiceProtosSyncMessageSent *)sentProto relay:(NSString *)relay
|
||
|
{
|
||
|
self = [super init];
|
||
|
if (!self) {
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
_relay = relay;
|
||
|
_dataMessage = sentProto.message;
|
||
|
_recipientId = sentProto.destination;
|
||
|
_timestamp = sentProto.timestamp;
|
||
9 years ago
|
_expirationStartedAt = sentProto.expirationStartTimestamp;
|
||
|
_expirationDuration = sentProto.message.expireTimer;
|
||
|
_body = _dataMessage.body;
|
||
|
_groupId = _dataMessage.group.id;
|
||
|
_isGroupUpdate = _dataMessage.hasGroup && (_dataMessage.group.type == OWSSignalServiceProtosGroupContextTypeUpdate);
|
||
|
_isExpirationTimerUpdate = (_dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsExpirationTimerUpdate) != 0;
|
||
9 years ago
|
_isEndSessionMessage = (_dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsEndSession) != 0;
|
||
9 years ago
|
|
||
|
return self;
|
||
|
}
|
||
|
|
||
9 years ago
|
- (NSArray<OWSSignalServiceProtosAttachmentPointer *> *)attachmentPointerProtos
|
||
9 years ago
|
{
|
||
9 years ago
|
if (self.isGroupUpdate && self.dataMessage.group.hasAvatar) {
|
||
|
return @[ self.dataMessage.group.avatar ];
|
||
9 years ago
|
} else {
|
||
9 years ago
|
return self.dataMessage.attachments;
|
||
9 years ago
|
}
|
||
9 years ago
|
}
|
||
9 years ago
|
|
||
9 years ago
|
- (TSThread *)thread
|
||
|
{
|
||
|
if (self.dataMessage.hasGroup) {
|
||
|
return [TSGroupThread getOrCreateThreadWithGroupIdData:self.dataMessage.group.id];
|
||
9 years ago
|
} else {
|
||
9 years ago
|
return [TSContactThread getOrCreateThreadWithContactId:self.recipientId];
|
||
9 years ago
|
}
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
NS_ASSUME_NONNULL_END
|