Simplify event encryption decoration

This commit is contained in:
Andy Uhnak
2023-03-16 16:40:53 +00:00
parent 99dbbd9d70
commit 16f74e84c8
5 changed files with 37 additions and 36 deletions
@@ -187,7 +187,7 @@
// Always show a warning badge if there was a decryption error.
if (event.decryptionError)
{
return EventEncryptionDecorationDecryptionError;
return EventEncryptionDecorationRed;
}
// Unencrypted message events should show a warning unless they're pending local echoes
@@ -199,29 +199,20 @@
return EventEncryptionDecorationNone;
}
return EventEncryptionDecorationNotEncrypted;
return EventEncryptionDecorationRed;
}
// The encryption is in a good state.
// Only show a warning badge if there are trust issues.
if (event.sender)
// Only show a warning badge if there are decryption trust issues.
switch (event.decryptionDecoration.color)
{
MXUserTrustLevel *userTrustLevel = [session.crypto trustLevelForUser:event.sender];
MXDeviceInfo *deviceInfo = [session.crypto eventDeviceInfo:event];
if (userTrustLevel.isVerified && !deviceInfo.trustLevel.isVerified)
{
return EventEncryptionDecorationUntrustedDevice;
}
case MXEventDecryptionDecorationColorRed:
return EventEncryptionDecorationRed;
case MXEventDecryptionDecorationColorGrey:
return EventEncryptionDecorationGrey;
case MXEventDecryptionDecorationColorNone:
return EventEncryptionDecorationNone;
}
if (event.isUntrusted)
{
return EventEncryptionDecorationUnsafeKey;
}
// Everything was fine
return EventEncryptionDecorationNone;
}
@end