From e7bc68ad4d02b8e5f6ba26c0e917abf4d9ab2ccc Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 23 Apr 2020 13:53:44 +0200 Subject: Handle entity hash in server features node, make ServiceDiscovery request_info/items async, add caching has_entity_feature --- libdino/src/service/entity_capabilities_storage.vala | 2 ++ libdino/src/service/message_processor.vala | 16 ++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'libdino/src/service') diff --git a/libdino/src/service/entity_capabilities_storage.vala b/libdino/src/service/entity_capabilities_storage.vala index b1f5405b..12b5d022 100644 --- a/libdino/src/service/entity_capabilities_storage.vala +++ b/libdino/src/service/entity_capabilities_storage.vala @@ -16,6 +16,8 @@ public class EntityCapabilitiesStorage : Xep.EntityCapabilities.Storage, Object } public void store_features(string entity, Gee.List features) { + if (features_cache.contains(entity)) return; + foreach (string feature in features) { db.entity_feature.insert() .value(db.entity_feature.entity, entity) diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala index 6bc4fc9e..266482ac 100644 --- a/libdino/src/service/message_processor.vala +++ b/libdino/src/service/message_processor.vala @@ -386,24 +386,20 @@ public class MessageProcessor : StreamInteractionModule, Object { return Entities.Message.Type.GROUPCHAT_PM; } } else { - SourceFunc callback = determine_message_type.callback; XmppStream stream = stream_interactor.get_stream(account); - if (stream != null) stream.get_module(Xep.ServiceDiscovery.Module.IDENTITY).get_entity_categories(stream, message.counterpart.bare_jid, (stream, identities) => { + if (stream != null) { + Gee.Set? identities = yield stream.get_module(Xep.ServiceDiscovery.Module.IDENTITY).get_entity_identities(stream, message.counterpart.bare_jid); if (identities == null) { - message.type_ = Entities.Message.Type.CHAT; - Idle.add((owned) callback); - return; + return Entities.Message.Type.CHAT; } foreach (Xep.ServiceDiscovery.Identity identity in identities) { if (identity.category == Xep.ServiceDiscovery.Identity.CATEGORY_CONFERENCE) { - message.type_ = Entities.Message.Type.GROUPCHAT_PM; + return Entities.Message.Type.GROUPCHAT_PM; } else { - message.type_ = Entities.Message.Type.CHAT; + return Entities.Message.Type.CHAT; } } - Idle.add((owned) callback); - }); - yield; + } } } return Entities.Message.Type.CHAT; -- cgit v1.2.3-70-g09d2