aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-05-09 23:50:44 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-05-09 23:50:44 +0200
commitd05b610636e813af44fc06821a07aeb8e1b2b332 (patch)
tree460082272bef28fe472efc139d7495739cb34c0b
parentc52f3538945d16e2cfcabb8d080005867f256ba2 (diff)
downloadxK-d05b610636e813af44fc06821a07aeb8e1b2b332.tar.gz
xK-d05b610636e813af44fc06821a07aeb8e1b2b332.tar.xz
xK-d05b610636e813af44fc06821a07aeb8e1b2b332.zip
degesch: remove people from channels when leaving
-rw-r--r--degesch.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/degesch.c b/degesch.c
index 0f4cd6e..58b68a4 100644
--- a/degesch.c
+++ b/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)
{