aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-04-03 22:49:59 +0200
committerfiaxh <git@lightrise.org>2020-04-03 22:49:59 +0200
commit871ff33ac79f3d17b0260b8bfcd27780038edd6d (patch)
treef8079e29db5d0f9294fbfbfb47b93b0403249cc9 /xmpp-vala/src
parent1c8e15c408f57d93461e6adb33c4c4415ac49267 (diff)
downloaddino-871ff33ac79f3d17b0260b8bfcd27780038edd6d.tar.gz
dino-871ff33ac79f3d17b0260b8bfcd27780038edd6d.zip
Add support for last message correction
Diffstat (limited to 'xmpp-vala/src')
-rw-r--r--xmpp-vala/src/module/xep/0308_last_message_correction.vala31
1 files changed, 31 insertions, 0 deletions
diff --git a/xmpp-vala/src/module/xep/0308_last_message_correction.vala b/xmpp-vala/src/module/xep/0308_last_message_correction.vala
new file mode 100644
index 00000000..7669b244
--- /dev/null
+++ b/xmpp-vala/src/module/xep/0308_last_message_correction.vala
@@ -0,0 +1,31 @@
+namespace Xmpp.Xep.LastMessageCorrection {
+
+private const string NS_URI = "urn:xmpp:message-correct:0";
+
+public static void set_replace_id(MessageStanza message, string replace_id) {
+ StanzaNode hint_node = (new StanzaNode.build("replace", NS_URI)).add_self_xmlns().put_attribute("id", replace_id);
+ message.stanza.put_node(hint_node);
+}
+
+public static string? get_replace_id(MessageStanza message) {
+ StanzaNode? node = message.stanza.get_subnode("replace", NS_URI);
+ if (node == null) return null;
+
+ return node.get_attribute("id");
+}
+
+public class Module : XmppStreamModule {
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0308_last_message_correction");
+
+ public override void attach(XmppStream stream) {
+ stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
+ }
+
+ public override void detach(XmppStream stream) {}
+
+ public override string get_ns() { return NS_URI; }
+
+ public override string get_id() { return IDENTITY.id; }
+}
+
+}