about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/xmpp/message.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 0e4b0fe3..89bc422d 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -585,7 +585,36 @@ _receipt_received_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza
     return 1;
 }
 
-void _private_chat_handler(xmpp_stanza_t * const stanza, const char * const fulljid)
+void
+_receipt_request_handler(xmpp_stanza_t * const stanza)
+{
+    if (!prefs_get_boolean(PREF_RECEIPTS_SEND)) {
+        return;
+    }
+
+    char *id = xmpp_stanza_get_id(stanza);
+    if (!id) {
+        return;
+    }
+
+    xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
+    if (!receipts) {
+        return;
+    }
+
+    char *receipts_name = xmpp_stanza_get_name(receipts);
+    if (g_strcmp0(receipts_name, "request") != 0) {
+        return;
+    }
+
+    gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
+    Jid *jid = jid_create(from);
+    _message_send_receipt(jid->fulljid, id);
+    jid_destroy(jid);
+}
+
+void
+_private_chat_handler(xmpp_stanza_t * const stanza, const char * const fulljid)
 {
     xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
     if (!body) {
@@ -709,17 +738,7 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * con
 #endif
             }
 
-            // send receipt if configured
-            char *id = xmpp_stanza_get_id(stanza);
-            if (id && prefs_get_boolean(PREF_RECEIPTS_SEND)) {
-                xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
-                if (receipts) {
-                    char *receipts_name = xmpp_stanza_get_name(receipts);
-                    if (g_strcmp0(receipts_name, "request") == 0) {
-                        _message_send_receipt(jid->fulljid, id);
-                    }
-                }
-            }
+            _receipt_request_handler(stanza);
 
             xmpp_ctx_t *ctx = connection_get_ctx();
             xmpp_free(ctx, message);
lt;vc@akkartik.com> 2019-08-26 11:59:21 -0700 5592 - switch register names to lowercase' href='/akkartik/mu/commit/examples/ex5.subx?h=hlt&id=333525360b22f3d3ea31db46a4d2f1b4edbfebdb'>33352536 ^
6602c82f ^
ecfbbfb5 ^
9d27e966 ^
33352536 ^
9d27e966 ^
33352536 ^
9d27e966 ^
33352536 ^
9d27e966 ^
ecfbbfb5 ^
6602c82f ^
6030d7e2 ^
9d27e966 ^
33352536 ^
9d27e966 ^
33352536 ^
9d27e966 ^
33352536 ^
9d27e966 ^
33352536 ^
6030d7e2 ^
6602c82f ^
ecfbbfb5 ^

294a1520 ^
ee9a9237 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41