mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Bypass ratchet and network to discuss with self.
Closes #314 #305 #274 Reviewed-by: @FredericJacobs
This commit is contained in:
parent
07c539c844
commit
71320a690c
6 changed files with 47 additions and 18 deletions
|
@ -57,7 +57,6 @@ dispatch_queue_t sendingQueue() {
|
|||
dispatch_async(sendingQueue(), ^{
|
||||
if ([thread isKindOfClass:[TSGroupThread class]]) {
|
||||
TSGroupThread* groupThread = (TSGroupThread*)thread;
|
||||
|
||||
[self saveGroupMessage:message inThread:thread];
|
||||
__block NSArray* recipients;
|
||||
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
|
@ -65,7 +64,7 @@ dispatch_queue_t sendingQueue() {
|
|||
}];
|
||||
|
||||
for(TSRecipient *rec in recipients){
|
||||
// we don't need to send the message to ourselves, but otherwise we sends
|
||||
// we don't need to send the message to ourselves, but otherwise we send
|
||||
if( ![[rec uniqueId] isEqualToString:[SignalKeyingStorage.localNumber toE164]]){
|
||||
[self sendMessage:message
|
||||
toRecipient:rec
|
||||
|
@ -76,19 +75,28 @@ dispatch_queue_t sendingQueue() {
|
|||
|
||||
}
|
||||
else if([thread isKindOfClass:[TSContactThread class]]){
|
||||
[self saveMessage:message withState:TSOutgoingMessageStateAttemptingOut];
|
||||
|
||||
TSContactThread *contactThread = (TSContactThread*)thread;
|
||||
__block TSRecipient *recipient;
|
||||
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
recipient = [contactThread recipientWithTransaction:transaction];
|
||||
}];
|
||||
|
||||
[self saveMessage:message withState:TSOutgoingMessageStateAttemptingOut];
|
||||
|
||||
[self sendMessage:message
|
||||
toRecipient:recipient
|
||||
inThread:thread
|
||||
withAttemps:3];
|
||||
if(![contactThread.contactIdentifier isEqualToString:[SignalKeyingStorage.localNumber toE164]]) {
|
||||
__block TSRecipient *recipient;
|
||||
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
recipient = [contactThread recipientWithTransaction:transaction];
|
||||
}];
|
||||
|
||||
[self sendMessage:message
|
||||
toRecipient:recipient
|
||||
inThread:thread
|
||||
withAttemps:3];
|
||||
}
|
||||
else {
|
||||
// Special situation: if we are sending to ourselves in a single thread, we treat this as an incoming message
|
||||
[self handleMessageSent:message];
|
||||
[[TSMessagesManager sharedManager] handleSendToMyself:message];
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -23,4 +23,6 @@
|
|||
|
||||
- (void)handleReceivedMessage:(IncomingPushMessageSignal*)message withContent:(PushMessageContent*)content attachments:(NSArray*)attachments;
|
||||
|
||||
-(void)handleSendToMyself:(TSOutgoingMessage*)outgoingMessage;
|
||||
|
||||
@end
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#import "TSMessagesManager+attachments.h"
|
||||
#import "TSAttachmentPointer.h"
|
||||
|
||||
#import "SignalKeyingStorage.h"
|
||||
|
||||
#import "NSData+messagePadding.h"
|
||||
|
||||
#import "Environment.h"
|
||||
|
@ -227,6 +229,15 @@
|
|||
[self handleReceivedMessage:message withContent:content attachments:content.attachments];
|
||||
}
|
||||
|
||||
-(void)handleSendToMyself:(TSOutgoingMessage*)outgoingMessage {
|
||||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
TSContactThread *cThread = [TSContactThread getOrCreateThreadWithContactId:[SignalKeyingStorage.localNumber toE164] transaction:transaction];
|
||||
[cThread saveWithTransaction:transaction];
|
||||
TSIncomingMessage *incomingMessage = [[TSIncomingMessage alloc] initWithTimestamp:(outgoingMessage.timeStamp + 1) inThread:cThread messageBody:outgoingMessage.body attachments:outgoingMessage.attachments];
|
||||
[incomingMessage saveWithTransaction:transaction];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)handleReceivedMessage:(IncomingPushMessageSignal*)message withContent:(PushMessageContent*)content attachments:(NSArray*)attachments {
|
||||
uint64_t timeStamp = message.timestamp;
|
||||
NSString *body = content.body;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#import "PhoneNumberDirectoryFilter.h"
|
||||
#import "PhoneNumberUtil.h"
|
||||
#import "RecentCallManager.h"
|
||||
#import "SignalKeyingStorage.h"
|
||||
|
||||
#define INITIAL_BACKSPACE_TIMER_DURATION 0.5f
|
||||
#define BACKSPACE_TIME_DECREASE_AMMOUNT 0.1f
|
||||
|
@ -129,11 +130,17 @@
|
|||
}
|
||||
|
||||
-(void) initiateCallToPhoneNumber:(PhoneNumber*) phoneNumber {
|
||||
if (_contact) {
|
||||
[Environment.phoneManager initiateOutgoingCallToContact:_contact
|
||||
atRemoteNumber:phoneNumber];
|
||||
} else {
|
||||
[Environment.phoneManager initiateOutgoingCallToRemoteNumber:phoneNumber];
|
||||
if(![[phoneNumber toE164] isEqualToString:[SignalKeyingStorage.localNumber toE164]]) {
|
||||
if (_contact) {
|
||||
[Environment.phoneManager initiateOutgoingCallToContact:_contact
|
||||
atRemoteNumber:phoneNumber];
|
||||
} else {
|
||||
[Environment.phoneManager initiateOutgoingCallToRemoteNumber:phoneNumber];
|
||||
}
|
||||
}
|
||||
else {
|
||||
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"ERROR_CALL_ONESELF", @"") message:nil delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil, nil];
|
||||
[alertView show];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ typedef enum : NSUInteger {
|
|||
if (!isGroupConversation) {
|
||||
UIBarButtonItem * lockButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"lock"] style:UIBarButtonItemStylePlain target:self action:@selector(showFingerprint)];
|
||||
|
||||
if ([self isRedPhoneReachable]) {
|
||||
if ([self isRedPhoneReachable] && ![((TSContactThread*)_thread).contactIdentifier isEqualToString:[SignalKeyingStorage.localNumber toE164]]) {
|
||||
UIBarButtonItem * callButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"call_tab"] style:UIBarButtonItemStylePlain target:self action:@selector(callAction)];
|
||||
[callButton setImageInsets:UIEdgeInsetsMake(0, -10, 0, -50)];
|
||||
negativeSeparator.width = -8;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
"DIALER_NUMBER_PLUS" = "+";
|
||||
"DIALER_NUMBER_POUND" = "#";
|
||||
"DISABLING_BACKUP_FAILED" = "We encountered an issue while disabling the backup of your call log. Call logs might leak in your iTunes/iCloud backups.";
|
||||
"ERROR_CALL_ONESELF" = "You can't call yourself.";
|
||||
"ERROR_WAS_DETECTED_TITLE" = "Bummer!";
|
||||
"ERROR_WAS_DETECTED_SUBMIT" = "An bug was detected. Help us make Signal better by reporting this incident.";
|
||||
"END_CALL_BAD_INTERACTION_WITH_SERVER" = "Server Failed!";
|
||||
|
|
Loading…
Reference in a new issue