about summary refs log tree commit diff stats
path: root/src/xmpp/message.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp/message.c')
-rw-r--r--src/xmpp/message.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 84c85471..78364ca2 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -1158,3 +1158,19 @@ _send_message_stanza(xmpp_stanza_t *const stanza)
     }
     xmpp_free(connection_get_ctx(), text);
 }
+
+bool message_is_sent_by_us(ProfMessage *message) {
+    // we check the </origin-id> for this we calculate a hash into it so we can detect
+    // whether this client sent it. See connection_create_stanza_id()
+    if (message->id != NULL) {
+        gsize tmp_len;
+        char *tmp = (char*)g_base64_decode(message->id, &tmp_len);
+
+        // our client sents at least 10 for the identifier + random message bytes
+        if ((tmp_len > 10) || (g_strcmp0(&tmp[10], connection_get_profanity_identifier()) == 0)) {
+            return TRUE;
+        }
+    }
+
+    return  FALSE;
+}