From 83ed9ba24b85bd47ef3b2e90d4634a19b258d3a0 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Thu, 2 Jul 2020 17:53:28 +0200 Subject: [PATCH] message.c: Put plugin handler code in helper function --- src/xmpp/message.c | 21 ++++++++++++++------- 1 file 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 gboolean +_handled_by_plugin(xmpp_stanza_t *const stanza) +{ + char *text; + size_t text_size; + + xmpp_stanza_to_text(stanza, &text, &text_size); + gboolean cont = plugins_on_message_stanza_receive(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"); - 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); + 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);