mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 16:42:44 +02:00
Decorate events decrypted with untrusted sessions
This commit is contained in:
@@ -73,7 +73,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
_showEncryptionBadge = [self shouldShowWarningBadgeForEvent:event roomState:(MXRoomState*)roomState session:session];
|
||||
_encryptionDecoration = [self encryptionDecorationForEvent:event roomState:(MXRoomState*)roomState session:session];
|
||||
|
||||
[self updateLinkWithRoomState:roomState];
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
andLatestRoomState:latestRoomState
|
||||
error:&error];
|
||||
|
||||
_showEncryptionBadge = [self shouldShowWarningBadgeForEvent:event roomState:roomState session:session];
|
||||
_encryptionDecoration = [self encryptionDecorationForEvent:event roomState:roomState session:session];
|
||||
|
||||
[self updateLinkWithRoomState:roomState];
|
||||
}
|
||||
@@ -167,24 +167,24 @@
|
||||
self.link = url;
|
||||
}
|
||||
|
||||
- (BOOL)shouldShowWarningBadgeForEvent:(MXEvent*)event roomState:(MXRoomState*)roomState session:(MXSession*)session
|
||||
- (EventEncryptionDecoration)encryptionDecorationForEvent:(MXEvent*)event roomState:(MXRoomState*)roomState session:(MXSession*)session
|
||||
{
|
||||
// Warning badges are unnecessary in unencrypted rooms
|
||||
if (!roomState.isEncrypted)
|
||||
{
|
||||
return NO;
|
||||
return EventEncryptionDecorationNone;
|
||||
}
|
||||
|
||||
// Not all events are encrypted (e.g. state/reactions/redactions) and we only have encrypted cell subclasses for messages and attachments.
|
||||
if (event.eventType != MXEventTypeRoomMessage && !event.isMediaAttachment)
|
||||
{
|
||||
return NO;
|
||||
return EventEncryptionDecorationNone;
|
||||
}
|
||||
|
||||
// Always show a warning badge if there was a decryption error.
|
||||
if (event.decryptionError)
|
||||
{
|
||||
return YES;
|
||||
return EventEncryptionDecorationDecryptionError;
|
||||
}
|
||||
|
||||
// Unencrypted message events should show a warning unless they're pending local echoes
|
||||
@@ -193,10 +193,10 @@
|
||||
if (event.isLocalEvent
|
||||
|| event.contentHasBeenEdited) // Local echo for an edit is clear but uses a true event id, the one of the edited event
|
||||
{
|
||||
return NO;
|
||||
return EventEncryptionDecorationNone;
|
||||
}
|
||||
|
||||
return YES;
|
||||
return EventEncryptionDecorationNotEncrypted;
|
||||
}
|
||||
|
||||
// The encryption is in a good state.
|
||||
@@ -208,12 +208,17 @@
|
||||
|
||||
if (userTrustLevel.isVerified && !deviceInfo.trustLevel.isVerified)
|
||||
{
|
||||
return YES;
|
||||
return EventEncryptionDecorationUntrustedDevice;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.isUntrusted)
|
||||
{
|
||||
return EventEncryptionDecorationUnsafeKey;
|
||||
}
|
||||
|
||||
// Everything was fine
|
||||
return NO;
|
||||
return EventEncryptionDecorationNone;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user