diff options
author | fiaxh <git@lightrise.org> | 2020-04-25 16:12:08 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2020-04-25 16:15:43 +0200 |
commit | ee9795d8f466706e06b2fdbc9beca2f8ecbf5d08 (patch) | |
tree | 17f4ecdf43e0fe031e220d58d0cade7b70711440 /xmpp-vala/src/module/xep/0030_service_discovery | |
parent | 231df1bbbb683fa0c74f2f10743f7592e219eccd (diff) | |
download | dino-ee9795d8f466706e06b2fdbc9beca2f8ecbf5d08.tar.gz dino-ee9795d8f466706e06b2fdbc9beca2f8ecbf5d08.zip |
Handle if Items/InfoResult are null
Diffstat (limited to 'xmpp-vala/src/module/xep/0030_service_discovery')
-rw-r--r-- | xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala | 4 | ||||
-rw-r--r-- | xmpp-vala/src/module/xep/0030_service_discovery/module.vala | 6 |
2 files changed, 7 insertions, 3 deletions
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<Identity>? get_entity_identities(XmppStream stream, Jid jid) { |