about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2019-03-13 18:39:31 +0140
committerPaul Fariello <paul@fariello.eu>2019-04-10 17:12:31 +0200
commit36ce21fc6d8104ef2145afbe3056747e49032ca4 (patch)
treed6d8a9dea78277364895700b1c30b2cd47f6bda0 /src
parentdbf96dcfc62d5bbfb1770a78a945d9822204d93f (diff)
downloadprofani-tty-36ce21fc6d8104ef2145afbe3056747e49032ca4.tar.gz
Add store hints for OMEMO encrypted messages
Store hints are required has some server might discard messages without
body. Here we ensure OMEMO messages are stored on server and delivered
to client when they connect back.

It's really important since it avoid libsignal to desynchronize
counters.
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/message.c2
-rw-r--r--src/xmpp/stanza.c12
-rw-r--r--src/xmpp/stanza.h1
3 files changed, 15 insertions, 0 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 6ca63b08..53190998 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -404,6 +404,8 @@ message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys,
         stanza_attach_state(ctx, message, state);
     }
 
+    stanza_attach_hints_store(ctx, message);
+
     if (request_receipt) {
         stanza_attach_receipt_request(ctx, message);
     }
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 61086f77..2b2ec0d8 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -396,6 +396,18 @@ stanza_attach_hints_no_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza)
 }
 
 xmpp_stanza_t*
+stanza_attach_hints_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza)
+{
+    xmpp_stanza_t *store = xmpp_stanza_new(ctx);
+    xmpp_stanza_set_name(store, "store");
+    xmpp_stanza_set_ns(store, STANZA_NS_HINTS);
+    xmpp_stanza_add_child(stanza, store);
+    xmpp_stanza_release(store);
+
+    return stanza;
+}
+
+xmpp_stanza_t*
 stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza)
 {
     xmpp_stanza_t *receipet_request = xmpp_stanza_new(ctx);
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index bc157e46..f392eeff 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -233,6 +233,7 @@ xmpp_stanza_t* stanza_attach_state(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const
 xmpp_stanza_t* stanza_attach_carbons_private(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
 xmpp_stanza_t* stanza_attach_hints_no_copy(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
 xmpp_stanza_t* stanza_attach_hints_no_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
+xmpp_stanza_t* stanza_attach_hints_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
 xmpp_stanza_t* stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
 xmpp_stanza_t* stanza_attach_x_oob_url(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const url);