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:40:58 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-07-02 17:40:58 +0200
commit46a00317ee85be02fc9174315db24297079d5c4d (patch)
treecf6e96cdfcca8ec7369b91d0fa0652505cb6db8c /src
parent19d9e80a797893ecf5b57622f7c475d78b45f91c (diff)
downloadprofani-tty-46a00317ee85be02fc9174315db24297079d5c4d.tar.gz
message.c: Check for message type
RFC 6121 allows only few types.
So we can also remove that check in _handle_chat().
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/message.c12
-rw-r--r--src/xmpp/stanza.h1
2 files changed, 5 insertions, 8 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 9309e5c4..82d8c599 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -133,8 +133,8 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con
         _handle_groupchat(stanza);
     } else if (g_strcmp0(type, STANZA_TYPE_HEADLINE) == 0) {
         //TODO: implement headline
-    } else {
-        // type: chat, normal (default if none is set)
+    } else if (type == NULL || g_strcmp0(type, STANZA_TYPE_CHAT) != 0 || g_strcmp0(type, STANZA_TYPE_NORMAL) != 0 ) {
+        // type: chat, normal (==NULL)
 
         // XEP-0045: Multi-User Chat - invites - presence
         xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
@@ -171,6 +171,8 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con
         }
 
         _handle_chat(stanza, FALSE);
+    } else {
+        log_info("Received <message> without 'type': %s", text);
     }
 
     return 1;
@@ -1244,12 +1246,6 @@ out:
 static void
 _handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam)
 {
-    // ignore if type not chat or absent
-    const char *type = xmpp_stanza_get_type(stanza);
-    if (type == NULL || g_strcmp0(type, STANZA_TYPE_CHAT) != 0) {
-        return;
-    }
-
     // check if carbon message
     gboolean res = _handle_carbons(stanza);
     if (res) {
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index f0fef91a..37cc8dc9 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -135,6 +135,7 @@
 #define STANZA_TYPE_CHAT "chat"
 #define STANZA_TYPE_GROUPCHAT "groupchat"
 #define STANZA_TYPE_HEADLINE "headline"
+#define STANZA_TYPE_NORMAL "normal"
 #define STANZA_TYPE_UNAVAILABLE "unavailable"
 #define STANZA_TYPE_SUBSCRIBE "subscribe"
 #define STANZA_TYPE_SUBSCRIBED "subscribed"