degesch: refactoring
This commit is contained in:
parent
7f57bed563
commit
4bac248c50
27
degesch.c
27
degesch.c
|
@ -2809,12 +2809,21 @@ irc_make_channel (struct server *s, char *name)
|
|||
return channel;
|
||||
}
|
||||
|
||||
static void
|
||||
irc_remove_user_from_channel (struct user *user, struct channel *channel)
|
||||
static struct channel_user *
|
||||
irc_channel_get_user (struct channel *channel, struct user *user)
|
||||
{
|
||||
LIST_FOR_EACH (struct channel_user, iter, channel->users)
|
||||
if (iter->user == user)
|
||||
irc_channel_unlink_user (channel, iter);
|
||||
return iter;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
irc_remove_user_from_channel (struct user *user, struct channel *channel)
|
||||
{
|
||||
struct channel_user *channel_user = irc_channel_get_user (channel, user);
|
||||
if (channel_user)
|
||||
irc_channel_unlink_user (channel, channel_user);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -3966,16 +3975,10 @@ mode_processor_do_user (struct mode_processor *self)
|
|||
{
|
||||
const char *nickname;
|
||||
struct user *user;
|
||||
struct channel_user *channel_user;
|
||||
if (!(nickname = mode_processor_next_param (self))
|
||||
|| !(user = str_map_find (&self->s->irc_users, nickname)))
|
||||
return;
|
||||
|
||||
// TODO: factor out, also use in unlink_user or whatever
|
||||
struct channel_user *channel_user = NULL;
|
||||
LIST_FOR_EACH (struct channel_user, iter, self->channel->users)
|
||||
if (iter->user == user)
|
||||
channel_user = iter;
|
||||
if (!channel_user)
|
||||
|| !(user = str_map_find (&self->s->irc_users, nickname))
|
||||
|| !(channel_user = irc_channel_get_user (self->channel, user)))
|
||||
return;
|
||||
|
||||
const char *all_prefixes = self->s->irc_chanuser_prefixes;
|
||||
|
|
Loading…
Reference in New Issue