fix(xep): Fix crash when the device list node is empty
This commit is contained in:
parent
db77790bf4
commit
9eb94e5f48
@ -4,6 +4,10 @@ class UnknownOmemoError extends OmemoError {}
|
||||
|
||||
class InvalidAffixElementsException implements Exception {}
|
||||
|
||||
/// Internal exception that is returned when the device list cannot be
|
||||
/// fetched because the returned list is empty.
|
||||
class EmptyDeviceListException implements OmemoError {}
|
||||
|
||||
class OmemoNotSupportedForContactException extends OmemoError {}
|
||||
|
||||
class EncryptionFailedException implements Exception {}
|
||||
|
@ -535,7 +535,10 @@ class OmemoManager extends XmppManagerBase {
|
||||
final pm = getAttributes().getManagerById<PubSubManager>(pubsubManager)!;
|
||||
final result = await pm.getItems(jid.toBare(), omemoDevicesXmlns);
|
||||
if (result.isType<PubSubError>()) return Result(UnknownOmemoError());
|
||||
return Result(result.get<List<PubSubItem>>().first.payload);
|
||||
|
||||
final itemList = result.get<List<PubSubItem>>();
|
||||
if (itemList.isEmpty) return Result(EmptyDeviceListException());
|
||||
return Result(itemList.first.payload);
|
||||
}
|
||||
|
||||
/// Retrieves the OMEMO device list from [jid].
|
||||
|
Loading…
Reference in New Issue
Block a user