about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-07-02 17:53:28 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-07-02 17:53:28 +0200
commit83ed9ba24b85bd47ef3b2e90d4634a19b258d3a0 (patch)
treed31511562632df787b2aa36cd7ed0b7fea02d37f /src
parent6be5b51a46d1598ac12ddda88b36a2487bf523e0 (diff)
downloadprofani-tty-83ed9ba24b85bd47ef3b2e90d4634a19b258d3a0.tar.gz
message.c: Put plugin handler code in helper function
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/message.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 42507b91..4419f4ba 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -96,20 +96,27 @@ static xmpp_stanza_t* _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to,
 
 static GHashTable *pubsub_event_handlers;
 
-static int
-_message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata)
+static gboolean
+_handled_by_plugin(xmpp_stanza_t *const stanza)
 {
-    log_debug("Message stanza handler fired");
-
     char *text;
     size_t text_size;
+
     xmpp_stanza_to_text(stanza, &text, &text_size);
     gboolean cont = plugins_on_message_stanza_receive(text);
-    if (!cont) {
-        xmpp_free(connection_get_ctx(), text);
+    xmpp_free(connection_get_ctx(), text);
+
+    return !cont;
+}
+
+static int
+_message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata)
+{
+    log_debug("Message stanza handler fired");
+
+    if (_handled_by_plugin(stanza)) {
         return 1;
     }
-    xmpp_free(connection_get_ctx(), text);
 
     // type according to RFC 6121
     const char *type = xmpp_stanza_get_type(stanza);