mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-03 14:46:56 +02:00
Warn unknown devices: the dialog is a one time change to check unknown devices.
If the user presses cancel or ok, devices will be no more unknown
This commit is contained in:
@@ -3121,12 +3121,28 @@
|
||||
[event.roomId isEqualToString:self.roomDataSource.roomId]
|
||||
&& [event.sentError.domain isEqualToString:MXEncryptingErrorDomain]
|
||||
&& event.sentError.code == MXEncryptingErrorUnknownDeviceCode
|
||||
&& !currentAlert) // Show the alert once in case of resending several events
|
||||
&& !unknownDevices) // Show the alert once in case of resending several events
|
||||
{
|
||||
__weak __typeof(self) weakSelf = self;
|
||||
|
||||
[self dismissTemporarySubViews];
|
||||
|
||||
// List all unknown devices
|
||||
unknownDevices = [[MXUsersDevicesMap alloc] init];
|
||||
|
||||
NSArray<MXEvent*> *outgoingMsgs = self.roomDataSource.room.outgoingMessages;
|
||||
for (MXEvent *event in outgoingMsgs)
|
||||
{
|
||||
if (event.sentState == MXEventSentStateFailed
|
||||
&& [event.sentError.domain isEqualToString:MXEncryptingErrorDomain]
|
||||
&& event.sentError.code == MXEncryptingErrorUnknownDeviceCode)
|
||||
{
|
||||
MXUsersDevicesMap<MXDeviceInfo*> *eventUnknownDevices = event.sentError.userInfo[MXEncryptingErrorUnknownDeviceDevicesKey];
|
||||
|
||||
[unknownDevices addEntriesFromMap:eventUnknownDevices];
|
||||
}
|
||||
}
|
||||
|
||||
currentAlert = [[MXKAlert alloc] initWithTitle:[NSBundle mxk_localizedStringForKey:@"unknown_devices_alert_title"]
|
||||
message:[NSBundle mxk_localizedStringForKey:@"unknown_devices_alert"]
|
||||
style:MXKAlertStyleAlert];
|
||||
@@ -3134,13 +3150,18 @@
|
||||
currentAlert.cancelButtonIndex = [currentAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
typeof(self) self = weakSelf;
|
||||
self->currentAlert = nil;
|
||||
|
||||
// Acknowledge the existence of all devices
|
||||
[self.mainSession.crypto setDevicesKnown:self->unknownDevices complete:^{
|
||||
self->unknownDevices = nil;
|
||||
}];
|
||||
}];
|
||||
|
||||
[currentAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"unknown_devices_verify"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
typeof(self) self = weakSelf;
|
||||
self->currentAlert = nil;
|
||||
|
||||
[self showUnknownDevices];
|
||||
[self performSegueWithIdentifier:@"showUnknownDevices" sender:self];
|
||||
}];
|
||||
|
||||
currentAlert.mxkAccessibilityIdentifier = @"RoomVCUnknownDevicesAlert";
|
||||
@@ -3148,27 +3169,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showUnknownDevices
|
||||
{
|
||||
// List all unknown devices
|
||||
unknownDevices = [[MXUsersDevicesMap alloc] init];
|
||||
|
||||
NSArray<MXEvent*> *outgoingMsgs = self.roomDataSource.room.outgoingMessages;
|
||||
for (MXEvent *event in outgoingMsgs)
|
||||
{
|
||||
if (event.sentState == MXEventSentStateFailed
|
||||
&& [event.sentError.domain isEqualToString:MXEncryptingErrorDomain]
|
||||
&& event.sentError.code == MXEncryptingErrorUnknownDeviceCode)
|
||||
{
|
||||
MXUsersDevicesMap<MXDeviceInfo*> *eventUnknownDevices = event.sentError.userInfo[MXEncryptingErrorUnknownDeviceDevicesKey];
|
||||
|
||||
[unknownDevices addEntriesFromMap:eventUnknownDevices];
|
||||
}
|
||||
}
|
||||
|
||||
[self performSegueWithIdentifier:@"showUnknownDevices" sender:self];
|
||||
}
|
||||
|
||||
- (void)resendAllUnsentMessages
|
||||
{
|
||||
// List unsent event ids
|
||||
|
||||
Reference in New Issue
Block a user