1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Use Jid in groupchat message handler

This commit is contained in:
James Booth 2013-01-13 17:58:25 +00:00
parent ec75b5e04a
commit b768296a93
2 changed files with 8 additions and 12 deletions

View File

@ -1594,7 +1594,7 @@ static gboolean
_cmd_join(gchar **args, struct cmd_help_t help) _cmd_join(gchar **args, struct cmd_help_t help)
{ {
jabber_conn_status_t conn_status = jabber_get_connection_status(); jabber_conn_status_t conn_status = jabber_get_connection_status();
if (conn_status != JABBER_CONNECTED) { if (conn_status != JABBER_CONNECTED) {
cons_show("You are not currently connected."); cons_show("You are not currently connected.");
return TRUE; return TRUE;

View File

@ -527,10 +527,9 @@ _message_handler(xmpp_conn_t * const conn,
static int static int
_groupchat_message_handler(xmpp_stanza_t * const stanza) _groupchat_message_handler(xmpp_stanza_t * const stanza)
{ {
char *room = NULL;
char *nick = NULL;
char *message = NULL; char *message = NULL;
char *room_jid = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); char *room_jid = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
Jid *jid = jid_create(room_jid);
// handle room broadcasts // handle room broadcasts
if (jid_is_room(room_jid)) { if (jid_is_room(room_jid)) {
@ -540,8 +539,7 @@ _groupchat_message_handler(xmpp_stanza_t * const stanza)
if (subject != NULL) { if (subject != NULL) {
message = xmpp_stanza_get_text(subject); message = xmpp_stanza_get_text(subject);
if (message != NULL) { if (message != NULL) {
room = get_room_from_full_jid(room_jid); prof_handle_room_subject(jid->barejid, message);
prof_handle_room_subject(room, message);
} }
return 1; return 1;
@ -560,13 +558,12 @@ _groupchat_message_handler(xmpp_stanza_t * const stanza)
} }
} }
Jid *jid = jid_create(room_jid);
if (!jid_is_valid_room_form(jid)) { if (!jid_is_valid_room_form(jid)) {
log_error("Invalid room JID: %s", jid->str); log_error("Invalid room JID: %s", jid->str);
return 1; return 1;
} }
// room not active in profanity // room not active in profanity
if (!muc_room_is_active(jid)) { if (!muc_room_is_active(jid)) {
log_error("Message recieved for inactive chat room: %s", jid->str); log_error("Message recieved for inactive chat room: %s", jid->str);
@ -582,14 +579,13 @@ _groupchat_message_handler(xmpp_stanza_t * const stanza)
if (body != NULL) { if (body != NULL) {
char *message = xmpp_stanza_get_text(body); char *message = xmpp_stanza_get_text(body);
if (delayed) { if (delayed) {
prof_handle_room_history(room, nick, tv_stamp, message); prof_handle_room_history(jid->barejid, jid->resourcepart, tv_stamp, message);
} else { } else {
prof_handle_room_message(room, nick, message); prof_handle_room_message(jid->barejid, jid->resourcepart, message);
} }
} }
free(room); jid_destroy(jid);
free(nick);
return 1; return 1;
} }
@ -1034,7 +1030,7 @@ _presence_handler(xmpp_conn_t * const conn,
const char *jid = xmpp_conn_get_jid(jabber_conn.conn); const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE); char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
Jid *my_jid = jid_create(jid); Jid *my_jid = jid_create(jid);
Jid *from_jid = jid_create(from); Jid *from_jid = jid_create(from);