aboutsummaryrefslogtreecommitdiff
path: root/libdino
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2025-10-25 15:55:43 +0200
committerfiaxh <git@lightrise.org>2025-11-01 12:35:12 +0100
commitd7872109b33451716309d084d651aedd14ec3c04 (patch)
tree009de84a9ff4e834ae6afd52aa73adcf353d060c /libdino
parent1742cbd80980fbe1b0b29f2d2f123d75c4346200 (diff)
Store occupant ids for all incoming MUC messages
Diffstat (limited to 'libdino')
-rw-r--r--libdino/src/service/message_processor.vala11
1 files changed, 11 insertions, 0 deletions
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala
index cfbcadda..b9e64923 100644
--- a/libdino/src/service/message_processor.vala
+++ b/libdino/src/service/message_processor.vala
@@ -156,6 +156,7 @@ public class MessageProcessor : StreamInteractionModule, Object {
new_message.counterpart = counterpart_override ?? (new_message.direction == Entities.Message.DIRECTION_SENT ? message.to : message.from);
new_message.ourpart = new_message.direction == Entities.Message.DIRECTION_SENT ? message.from : message.to;
+ // Parse server stanza-id
Xmpp.MessageArchiveManagement.MessageFlag? mam_message_flag = Xmpp.MessageArchiveManagement.MessageFlag.get_flag(message);
EntityInfo entity_info = stream_interactor.get_module(EntityInfo.IDENTITY);
if (mam_message_flag != null && mam_message_flag.mam_id != null) {
@@ -175,6 +176,7 @@ public class MessageProcessor : StreamInteractionModule, Object {
}
}
+ // Parse times
if (mam_message_flag != null) new_message.local_time = mam_message_flag.server_time;
DateTime now = new DateTime.from_unix_utc(new DateTime.now_utc().to_unix()); // Remove milliseconds. They are not stored in the db and might lead to ordering issues when compared with times from the db.
if (new_message.local_time == null || new_message.local_time.compare(now) > 0) new_message.local_time = now;
@@ -185,6 +187,15 @@ public class MessageProcessor : StreamInteractionModule, Object {
new_message.type_ = yield determine_message_type(account, message, new_message);
+ // Parse occupant ids (in MUCs)
+ if (message.type_ == Xmpp.MessageStanza.TYPE_GROUPCHAT) {
+ bool muc_supports_occupant_ids = entity_info.has_feature_cached(account, message.from.bare_jid, Xmpp.Xep.OccupantIds.NS_URI);
+ string? occupant_id = OccupantIds.get_occupant_id(message.stanza);
+ if (muc_supports_occupant_ids && occupant_id != null) {
+ new_message.occupant_db_id = stream_interactor.get_module(OccupantIdStore.IDENTITY).cache_occupant_id(account, occupant_id, message.from);
+ }
+ }
+
return new_message;
}