degesch: remove people from channels when leaving
This commit is contained in:
parent
c52f353894
commit
d05b610636
28
degesch.c
28
degesch.c
|
@ -2462,6 +2462,14 @@ irc_remove_user_from_channel (struct user *user, struct channel *channel)
|
|||
irc_channel_unlink_user (channel, iter);
|
||||
}
|
||||
|
||||
static void
|
||||
irc_left_channel (struct channel *channel)
|
||||
{
|
||||
// TODO: shouldn't we decrease reference count on the channel?
|
||||
LIST_FOR_EACH (struct channel_user, iter, channel->users)
|
||||
irc_channel_unlink_user (channel, iter);
|
||||
}
|
||||
|
||||
// --- Core functionality ------------------------------------------------------
|
||||
|
||||
// Most of the core IRC code comes from ZyklonB which is mostly blocking.
|
||||
|
@ -2755,6 +2763,12 @@ on_irc_disconnected (struct server *s)
|
|||
s->socket = -1;
|
||||
s->state = IRC_DISCONNECTED;
|
||||
|
||||
struct str_map_iter iter;
|
||||
str_map_iter_init (&iter, &s->irc_channels);
|
||||
struct channel *channel;
|
||||
while ((channel = str_map_iter_next (&iter)))
|
||||
irc_left_channel (channel);
|
||||
|
||||
user_unref (s->irc_user);
|
||||
s->irc_user = NULL;
|
||||
|
||||
|
@ -3388,7 +3402,12 @@ irc_handle_kick (struct server *s, const struct irc_message *msg)
|
|||
|
||||
// It would be is weird for this to be false
|
||||
if (user && channel)
|
||||
irc_remove_user_from_channel (user, channel);
|
||||
{
|
||||
if (irc_is_this_us (s, target))
|
||||
irc_left_channel (channel);
|
||||
else
|
||||
irc_remove_user_from_channel (user, channel);
|
||||
}
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
|
@ -3563,7 +3582,12 @@ irc_handle_part (struct server *s, const struct irc_message *msg)
|
|||
|
||||
// It would be is weird for this to be false
|
||||
if (user && channel)
|
||||
irc_remove_user_from_channel (user, channel);
|
||||
{
|
||||
if (irc_is_this_us (s, msg->prefix))
|
||||
irc_left_channel (channel);
|
||||
else
|
||||
irc_remove_user_from_channel (user, channel);
|
||||
}
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue