Add olm error stream
This commit is contained in:
parent
09edda1f9f
commit
c01f75bafa
|
@ -639,6 +639,10 @@ class Client {
|
||||||
final StreamController<MatrixException> onError =
|
final StreamController<MatrixException> onError =
|
||||||
StreamController.broadcast();
|
StreamController.broadcast();
|
||||||
|
|
||||||
|
/// Synchronization erros are coming here.
|
||||||
|
final StreamController<ToDeviceEventDecryptionError> onOlmError =
|
||||||
|
StreamController.broadcast();
|
||||||
|
|
||||||
/// This is called once, when the first sync has received.
|
/// This is called once, when the first sync has received.
|
||||||
final StreamController<bool> onFirstSync = StreamController.broadcast();
|
final StreamController<bool> onFirstSync = StreamController.broadcast();
|
||||||
|
|
||||||
|
@ -1134,11 +1138,18 @@ class Client {
|
||||||
if (toDeviceEvent.type == 'm.room.encrypted') {
|
if (toDeviceEvent.type == 'm.room.encrypted') {
|
||||||
try {
|
try {
|
||||||
toDeviceEvent = decryptToDeviceEvent(toDeviceEvent);
|
toDeviceEvent = decryptToDeviceEvent(toDeviceEvent);
|
||||||
} catch (e) {
|
} catch (e, s) {
|
||||||
print(
|
print(
|
||||||
'[LibOlm] Could not decrypt to device event from ${toDeviceEvent.sender}: ' +
|
'[LibOlm] Could not decrypt to device event from ${toDeviceEvent.sender} with content: ${toDeviceEvent.content}');
|
||||||
e.toString());
|
print(e);
|
||||||
print(toDeviceEvent.sender);
|
print(s);
|
||||||
|
onOlmError.add(
|
||||||
|
ToDeviceEventDecryptionError(
|
||||||
|
exception: e,
|
||||||
|
stackTrace: s,
|
||||||
|
toDeviceEvent: toDeviceEvent,
|
||||||
|
),
|
||||||
|
);
|
||||||
toDeviceEvent = ToDeviceEvent.fromJson(events[i]);
|
toDeviceEvent = ToDeviceEvent.fromJson(events[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,3 +24,17 @@ class ToDeviceEvent {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ToDeviceEventDecryptionError extends ToDeviceEvent {
|
||||||
|
Exception exception;
|
||||||
|
StackTrace stackTrace;
|
||||||
|
ToDeviceEventDecryptionError({
|
||||||
|
ToDeviceEvent toDeviceEvent,
|
||||||
|
this.exception,
|
||||||
|
this.stackTrace,
|
||||||
|
}) : super(
|
||||||
|
sender: toDeviceEvent.sender,
|
||||||
|
content: toDeviceEvent.content,
|
||||||
|
type: toDeviceEvent.type,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue