1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-23 21:45:30 +00:00

message.c: Check for message type

RFC 6121 allows only few types.
So we can also remove that check in _handle_chat().
This commit is contained in:
Michael Vetter 2020-07-02 17:40:58 +02:00
parent 19d9e80a79
commit 46a00317ee
2 changed files with 5 additions and 8 deletions

View File

@ -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) {

View File

@ -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"