aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjgeboski <jgeboski@gmail.com>2015-01-16 16:50:24 -0300
committerdequis <dx@dxzone.com.ar>2015-01-16 16:50:24 -0300
commit885d294fad822b5275a68127ab2ab925d1df1a0e (patch)
tree9c7e1724bfd3b98f030779f166a0e652885f05b4
parenteabe6d4032eada515a1038838b64e34afc84b3e8 (diff)
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.
-rw-r--r--protocols/bee_chat.c12
1 files changed, 9 insertions, 3 deletions
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, ... )