aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/reactions.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2023-01-29 23:06:01 +0100
committerfiaxh <git@lightrise.org>2023-01-30 22:54:55 +0100
commitb0b81b88c6948dcfd2b1b82a9fe7357316a3af1f (patch)
treeea44aed7431b955ef8b1636f74c8ebe42bacb099 /libdino/src/service/reactions.vala
parent10a2bce5122dcd1e6fef037633a26568bf27d4d1 (diff)
downloaddino-b0b81b88c6948dcfd2b1b82a9fe7357316a3af1f.tar.gz
dino-b0b81b88c6948dcfd2b1b82a9fe7357316a3af1f.zip
Always display reaction+reply buttons, disable if not possible
Diffstat (limited to 'libdino/src/service/reactions.vala')
-rw-r--r--libdino/src/service/reactions.vala23
1 files changed, 7 insertions, 16 deletions
diff --git a/libdino/src/service/reactions.vala b/libdino/src/service/reactions.vala
index be98293f..5deaabac 100644
--- a/libdino/src/service/reactions.vala
+++ b/libdino/src/service/reactions.vala
@@ -57,30 +57,21 @@ public class Dino.Reactions : StreamInteractionModule, Object {
}
}
- public async bool conversation_supports_reactions(Conversation conversation) {
+ public bool conversation_supports_reactions(Conversation conversation) {
if (conversation.type_ == Conversation.Type.CHAT) {
- Gee.List<Jid>? resources = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(conversation.counterpart, conversation.account);
- if (resources == null) return false;
-
- foreach (Jid full_jid in resources) {
- bool? has_feature = yield stream_interactor.get_module(EntityInfo.IDENTITY).has_feature(conversation.account, full_jid, Xep.Reactions.NS_URI);
- if (has_feature == true) {
- return true;
- }
- }
+ return true;
} else {
// The MUC server needs to 1) support stable stanza ids 2) either support occupant ids or be a private room (where we know real jids)
var entity_info = stream_interactor.get_module(EntityInfo.IDENTITY);
- bool server_supports_sid = (yield entity_info.has_feature(conversation.account, conversation.counterpart.bare_jid, Xep.UniqueStableStanzaIDs.NS_URI)) ||
- (yield entity_info.has_feature(conversation.account, conversation.counterpart.bare_jid, Xmpp.MessageArchiveManagement.NS_URI_2));
+ bool server_supports_sid = (entity_info.has_feature_cached(conversation.account, conversation.counterpart.bare_jid, Xep.UniqueStableStanzaIDs.NS_URI)) ||
+ (entity_info.has_feature_cached(conversation.account, conversation.counterpart.bare_jid, Xmpp.MessageArchiveManagement.NS_URI_2));
if (!server_supports_sid) return false;
- bool? supports_occupant_ids = yield entity_info.has_feature(conversation.account, conversation.counterpart, Xep.OccupantIds.NS_URI);
+ bool? supports_occupant_ids = entity_info.has_feature_cached(conversation.account, conversation.counterpart, Xep.OccupantIds.NS_URI);
if (supports_occupant_ids) return true;
return stream_interactor.get_module(MucManager.IDENTITY).is_private_room(conversation.account, conversation.counterpart);
}
- return false;
}
private void send_reactions(Conversation conversation, ContentItem content_item, Gee.List<string> reactions) throws SendError {
@@ -96,7 +87,7 @@ public class Dino.Reactions : StreamInteractionModule, Object {
reactions_module.send_reaction.begin(stream, conversation.counterpart, "groupchat", message_id, reactions);
// We save the reaction when it gets reflected back to us
} else if (conversation.type_ == Conversation.Type.GROUPCHAT_PM) {
- reactions_module.send_reaction(stream, conversation.counterpart, "chat", message_id, reactions);
+ reactions_module.send_reaction.begin(stream, conversation.counterpart, "chat", message_id, reactions);
} else if (conversation.type_ == Conversation.Type.CHAT) {
int64 now_millis = GLib.get_real_time () / 1000;
reactions_module.send_reaction.begin(stream, conversation.counterpart, "chat", message_id, reactions, (_, res) => {
@@ -240,7 +231,7 @@ public class Dino.Reactions : StreamInteractionModule, Object {
if (stanza.type_ == MessageStanza.TYPE_GROUPCHAT) {
// Apply the same restrictions for incoming reactions as we do on sending them
Conversation muc_conversation = stream_interactor.get_module(ConversationManager.IDENTITY).approx_conversation_for_stanza(from_jid, account.bare_jid, account, MessageStanza.TYPE_GROUPCHAT);
- bool muc_supports_reactions = yield conversation_supports_reactions(muc_conversation);
+ bool muc_supports_reactions = conversation_supports_reactions(muc_conversation);
if (!muc_supports_reactions) return;
}