Error handling messages and Info Messages

pull/1/head
Frederic Jacobs 10 years ago
parent dde6fc0a7f
commit d90d27995c

@ -12,7 +12,7 @@
@implementation TSErrorMessage
- (instancetype)initWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread failedMessageType:(TSErrorMessageType)errorMessageType{
self = [super initWithTimestamp:timestamp inThread:thread messageBody:@"Placeholder for error message." attachements:nil];
self = [super initWithTimestamp:timestamp inThread:thread messageBody:nil attachements:nil];
if (self) {
_errorType = errorMessageType;
@ -21,6 +21,28 @@
return self;
}
- (NSString*)description{
switch (_errorType) {
case TSErrorMessageNoSession:
return @"No available session for contact";
case TSErrorMessageMissingKeyId:
return @"Received a message with unknown PreKey";
case TSErrorMessageInvalidMessage:
return @"Received a corrupted message";
case TSErrorMessageInvalidVersion:
return @"Received a message not compatible with this version";
case TSErrorMessageDuplicateMessage:
return @"Received a duplicated message";
case TSErrorMessageInvalidKeyException:
return @"The recipient's key is not valid.";
case TSErrorMessageWrongTrustedIdentityKey:
return @"Your contact's identity key changed. Tap to verify and accept new key";
default:
return @"An unknown error occured";
break;
}
}
+ (instancetype)userNotRegisteredErrorMessageInThread:(TSThread*)thread{
return [[self alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] inThread:thread];
}

@ -11,7 +11,8 @@
@interface TSInfoMessage : TSMessage
typedef NS_ENUM(NSInteger, TSInfoMessageType){
TSInfoMessageTypeSessionDidEnd
TSInfoMessageTypeSessionDidEnd,
TSInfoMessageTypeUnsupportedMessage
};
@property TSInfoMessageType messageType;

@ -20,4 +20,17 @@
return self;
}
- (NSString *)description{
switch (_messageType) {
case TSInfoMessageTypeSessionDidEnd:
return @"Secure session ended.";
case TSInfoMessageTypeUnsupportedMessage:
return @"Media messages are currently not supported.";
default:
break;
}
return @"Unknown Info Message Type";
}
@end

@ -180,6 +180,13 @@
} else if (content.attachments.count > 0) {
DDLogVerbose(@"Received push media message (attachement) ...");
[self handleReceivedMediaMessage:incomingMessage withContent:content];
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
TSInfoMessage *message = [[TSInfoMessage alloc] initWithTimestamp:incomingMessage.timestamp
inThread:[TSContactThread threadWithContactId:incomingMessage.source transaction:transaction]
messageType:TSInfoMessageTypeUnsupportedMessage];
[message saveWithTransaction:transaction];
}];
} else {
DDLogVerbose(@"Received push text message...");
[self handleReceivedTextMessage:incomingMessage withContent:content];
@ -231,7 +238,7 @@
}
- (void)processException:(NSException*)exception pushSignal:(IncomingPushMessageSignal*)signal{
NSLog(@"Got exception: %@", exception.description);
DDLogError(@"Got exception: %@", exception.description);
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
TSErrorMessage *errorMessage = [[TSErrorMessage alloc] initWithTimestamp:signal.timestamp inThread:[TSContactThread threadWithContactId:signal.source transaction:transaction] failedMessageType:TSErrorMessageNoSession];
[errorMessage saveWithTransaction:transaction];

@ -165,6 +165,7 @@ typedef enum : NSUInteger {
-(void)initializeCollectionViewLayout
{
if (self.collectionView){
[self.collectionView.collectionViewLayout setMessageBubbleFont:[UIFont ows_lightFontWithSize:16.0f]];
self.collectionView.showsVerticalScrollIndicator = NO;
@ -174,7 +175,7 @@ typedef enum : NSUInteger {
self.collectionView.collectionViewLayout.incomingAvatarViewSize = CGSizeZero;
self.collectionView.collectionViewLayout.outgoingAvatarViewSize = CGSizeZero;
}
}
#pragma mark - Fingerprints

Loading…
Cancel
Save