git » sdk » commit a6bbed3

Get the conversation a message belongs to

author Stephen Paul Weber
2023-07-26 19:50:04 UTC
committer Stephen Paul Weber
2023-07-26 19:50:04 UTC
parent e30e052f2b2496434db47fa2bcc8a5d7f1b486af

Get the conversation a message belongs to

Use the bare Jabber ID of the "other side" as the conversation ID (works
for 1:1 and MUC at least)

xmpp/ChatMessage.hx +4 -0

diff --git a/xmpp/ChatMessage.hx b/xmpp/ChatMessage.hx
index e23ea24..9efbe97 100644
--- a/xmpp/ChatMessage.hx
+++ b/xmpp/ChatMessage.hx
@@ -73,6 +73,10 @@ class ChatMessage {
 		return this.timestamp = timestamp;
 	}
 
+	public function conversation():String {
+		return direction == MessageReceived ? JID.parse(from).asBare().asString() : JID.parse(to).asBare().asString();
+	}
+
 	public function isIncoming():Bool {
 		return direction == MessageReceived;
 	}