0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

send: implement tags support for sendto_channel_flags() too

This commit is contained in:
William Pitcock 2016-02-20 18:27:15 -06:00
parent adaa9ba989
commit 667fb62eec

View file

@ -497,7 +497,6 @@ void
sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
struct Channel *chptr, const char *pattern, ...)
{
static char buf[BUFSIZE];
va_list args;
buf_head_t rb_linebuf_local;
buf_head_t rb_linebuf_id;
@ -505,26 +504,20 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
struct membership *msptr;
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
unsigned int current_capmask = 0;
struct MsgBuf msgbuf;
rb_linebuf_newbuf(&rb_linebuf_local);
rb_linebuf_newbuf(&rb_linebuf_id);
current_serial++;
build_msgbuf_from(&msgbuf, source_p, NULL);
va_start(args, pattern);
vsnprintf(buf, sizeof(buf), pattern, args);
va_end(args);
if(IsServer(source_p))
rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
":%s %s", source_p->name, buf);
else
rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
":%s!%s@%s %s",
source_p->name, source_p->username,
source_p->host, buf);
rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s %s", use_id(source_p), buf);
linebuf_put_msgvbuf(&msgbuf, &rb_linebuf_local, NOCAPS, pattern, &args);
rb_linebuf_putmsg(&rb_linebuf_id, pattern, &args, ":%s ", use_id(source_p));
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head)
{
@ -555,9 +548,24 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
}
}
else
{
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_msgvbuf(&msgbuf, &rb_linebuf_local, target_p->localClient->caps, pattern, &args);
current_capmask = target_p->localClient->caps;
}
_send_linebuf(target_p, &rb_linebuf_local);
}
}
va_end(args);
rb_linebuf_donebuf(&rb_linebuf_local);
rb_linebuf_donebuf(&rb_linebuf_id);
}