about summary refs log tree commit diff stats
path: root/src/xmpp/stanza.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-10-28 15:57:53 +0100
committerMichael Vetter <jubalh@iodoru.org>2021-01-28 14:44:53 +0100
commitdb65255a5a3c39dd7ad70b45c3610ec4fb02aac8 (patch)
treefb322a37c22054f0ea5acc665c214751c436e7fd /src/xmpp/stanza.c
parent69e35e86b206e8c887907c84da4e32a01cedab04 (diff)
downloadprofani-tty-db65255a5a3c39dd7ad70b45c3610ec4fb02aac8.tar.gz
wip: add rsm after we get the first couple of mam messages
Diffstat (limited to 'src/xmpp/stanza.c')
-rw-r--r--src/xmpp/stanza.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index fbbbfc9c..06615aa9 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -2615,7 +2615,7 @@ stanza_attach_correction(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* con
 }
 
 xmpp_stanza_t*
-stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate)
+stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate, const char *const lastid)
 {
     char* id = connection_create_stanza_id();
     xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
@@ -2674,6 +2674,23 @@ stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const s
 
     xmpp_stanza_add_child(field_start, value_start);
 
+    // 4.3.2 set/rsm
+    xmpp_stanza_t *after, *after_text, *set;
+    if (lastid) {
+        set = xmpp_stanza_new(ctx);
+        xmpp_stanza_set_name(set, STANZA_TYPE_SET);
+        xmpp_stanza_set_ns(set, STANZA_NS_RSM);
+
+        after = xmpp_stanza_new(ctx);
+        xmpp_stanza_set_name(after, STANZA_NAME_AFTER);
+
+        after_text = xmpp_stanza_new(ctx);
+        xmpp_stanza_set_text(after_text, lastid);
+
+        xmpp_stanza_add_child(after, after_text);
+        xmpp_stanza_add_child(set, after);
+    }
+
     // add and release
     xmpp_stanza_add_child(iq, query);
     xmpp_stanza_add_child(query, x);
@@ -2681,6 +2698,14 @@ stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const s
     xmpp_stanza_add_child(x, field_with);
     xmpp_stanza_add_child(x, field_start);
 
+    if (lastid) {
+        xmpp_stanza_add_child(query, after);
+
+        xmpp_stanza_release(after_text);
+        xmpp_stanza_release(after);
+        xmpp_stanza_release(set);
+    }
+
     xmpp_stanza_release(mam_text);
     xmpp_stanza_release(with_text);
     xmpp_stanza_release(date_text);