From 885d294fad822b5275a68127ab2ab925d1df1a0e Mon Sep 17 00:00:00 2001 From: jgeboski Date: Fri, 16 Jan 2015 16:50:24 -0300 Subject: bee-chat: create temporary users for unknown chat participants The imcb_chat_msg() function is unable to send messages to a chat with a user who was not previously added. This function should allow for the sending of messages with users who are not added. This is suitable for protocols which are sending messages to a chat from random users or a large amount of users which join and part frequently. --- protocols/bee_chat.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'protocols') diff --git a/protocols/bee_chat.c b/protocols/bee_chat.c index 1b741730..39110a10 100644 --- a/protocols/bee_chat.c +++ b/protocols/bee_chat.c @@ -84,6 +84,7 @@ void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t fl struct im_connection *ic = c->ic; bee_t *bee = ic->bee; bee_user_t *bu; + gboolean temp; char *s; /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ @@ -91,16 +92,21 @@ void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t fl return; bu = bee_user_by_handle( bee, ic, who ); + temp = ( bu == NULL ); + + if( temp ) + bu = bee_user_new( bee, ic, who, BEE_USER_ONLINE ); s = set_getstr( &ic->bee->set, "strip_html" ); if( ( g_strcasecmp( s, "always" ) == 0 ) || ( ( ic->flags & OPT_DOES_HTML ) && s ) ) strip_html( msg ); - if( bu && bee->ui->chat_msg ) + if( bee->ui->chat_msg ) bee->ui->chat_msg( bee, c, bu, msg, sent_at ); - else - imcb_chat_log( c, "Message from unknown participant %s: %s", who, msg ); + + if( temp ) + bee_user_free( bee, bu ); } void imcb_chat_log( struct groupchat *c, char *format, ... ) -- cgit v1.2.3