From ee9795d8f466706e06b2fdbc9beca2f8ecbf5d08 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sat, 25 Apr 2020 16:12:08 +0200 Subject: Handle if Items/InfoResult are null --- xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala | 4 ++++ xmpp-vala/src/module/xep/0030_service_discovery/module.vala | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'xmpp-vala/src/module/xep/0030_service_discovery') diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala b/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala index 233a0c06..105da893 100644 --- a/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala +++ b/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala @@ -26,6 +26,10 @@ public class ItemsResult { } public static ItemsResult? create_from_iq(Iq.Stanza iq) { + if (iq.type_ != Iq.Stanza.TYPE_RESULT) return null; + + if (iq.stanza.get_subnode("query", NS_URI_ITEMS) == null) return null; + return new ItemsResult.from_iq(iq); } } diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala index 708d5311..f21146f1 100644 --- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala +++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala @@ -46,11 +46,11 @@ public class Module : XmppStreamModule, Iq.Handler { if (flag.has_entity_feature(jid, feature) == null) { InfoResult? info_result = yield request_info(stream, jid); - stream.get_flag(Flag.IDENTITY).set_entity_features(info_result.iq.from, info_result != null ? info_result.features : null); - stream.get_flag(Flag.IDENTITY).set_entity_identities(info_result.iq.from, info_result != null ? info_result.identities : null); + stream.get_flag(Flag.IDENTITY).set_entity_features(jid, info_result != null ? info_result.features : null); + stream.get_flag(Flag.IDENTITY).set_entity_identities(jid, info_result != null ? info_result.identities : null); } - return flag.has_entity_feature(jid, feature); + return flag.has_entity_feature(jid, feature) ?? false; } public async Gee.Set? get_entity_identities(XmppStream stream, Jid jid) { -- cgit v1.2.3-70-g09d2