From 2d8d5b058b0d14736c925ac3710be2004b86e58b Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Wed, 23 Nov 2016 21:14:44 +0000 Subject: [PATCH] echo-message should work for clients that aren't in the target channel Move the echo part to the end of the channel membership loop so that it works even if the user isn't on the channel. --- ircd/send.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/ircd/send.c b/ircd/send.c index 29f30858..4e593a26 100644 --- a/ircd/send.c +++ b/ircd/send.c @@ -528,7 +528,7 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p, if(!MyClient(source_p) && (IsIOError(target_p->from) || target_p->from == one)) continue; - if(MyClient(source_p) && !IsCapable(source_p, CLICAP_ECHO_MESSAGE) && target_p == one) + if(MyClient(source_p) && target_p == one) continue; if(type && ((msptr->flags & type) == 0)) @@ -568,6 +568,25 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p, } } + /* source client may not be on the channel, send echo separately */ + if(MyClient(source_p) && IsCapable(source_p, CLICAP_ECHO_MESSAGE)) + { + target_p = one; + + if (target_p->localClient->caps != current_capmask) + { + /* reset the linebuf */ + rb_linebuf_donebuf(&rb_linebuf_local); + rb_linebuf_newbuf(&rb_linebuf_local); + + /* render the new linebuf and attach it */ + linebuf_put_msgbuf(&msgbuf, &rb_linebuf_local, target_p->localClient->caps, "%s", buf); + current_capmask = target_p->localClient->caps; + } + + _send_linebuf(target_p, &rb_linebuf_local); + } + rb_linebuf_donebuf(&rb_linebuf_local); rb_linebuf_donebuf(&rb_linebuf_id); } @@ -628,7 +647,7 @@ sendto_channel_opmod(struct Client *one, struct Client *source_p, if(!MyClient(source_p) && (IsIOError(target_p->from) || target_p->from == one)) continue; - if(MyClient(source_p) && !IsCapable(source_p, CLICAP_ECHO_MESSAGE) && target_p == one) + if(MyClient(source_p) && target_p == one) continue; if((msptr->flags & CHFL_CHANOP) == 0) @@ -658,6 +677,14 @@ sendto_channel_opmod(struct Client *one, struct Client *source_p, _send_linebuf(target_p, &rb_linebuf_local); } + /* source client may not be on the channel, send echo separately */ + if(MyClient(source_p) && IsCapable(source_p, CLICAP_ECHO_MESSAGE)) + { + target_p = one; + + _send_linebuf(target_p, &rb_linebuf_local); + } + rb_linebuf_donebuf(&rb_linebuf_local); rb_linebuf_donebuf(&rb_linebuf_old); rb_linebuf_donebuf(&rb_linebuf_new);