degesch: process RPL_NAMREPLY modes properly

Updating information in "channel_user" when needed.
This commit is contained in:
Přemysl Eric Janouch 2015-06-03 22:31:03 +02:00
parent f6da19d5b0
commit 103831e274
1 changed files with 13 additions and 4 deletions

View File

@ -820,7 +820,7 @@ struct channel_user
LIST_HEADER (struct channel_user) LIST_HEADER (struct channel_user)
struct user *user; ///< Reference to user struct user *user; ///< Reference to user
char *modes; ///< Op/voice/... characters char *modes; ///< Ordered @+... characters
}; };
static struct channel_user * static struct channel_user *
@ -4478,16 +4478,25 @@ irc_process_names (struct server *s, struct channel *channel)
{ {
const char *item = updates->vector[i]; const char *item = updates->vector[i];
const char *nick = item + strspn (item, s->irc_chanuser_prefixes); const char *nick = item + strspn (item, s->irc_chanuser_prefixes);
char *modes = xstrndup (item, nick - item);
struct channel_user *channel_user = str_map_find (&map, nick); struct channel_user *channel_user = str_map_find (&map, nick);
if (!channel_user) if (!channel_user)
{ {
channel_user = channel_user_new (); channel_user = channel_user_new ();
channel_user->user = irc_get_or_make_user (s, nick); channel_user->user = irc_get_or_make_user (s, nick);
channel_user->modes = xstrdup (""); channel_user->modes = modes;
LIST_PREPEND (channel->users, channel_user); LIST_PREPEND (channel->users, channel_user);
} }
// If our idea of the user's modes disagrees with what the server's
// TODO: update the user's modes // sent us (the most powerful modes differ), use the latter one
else if (channel_user->modes[0] != modes[0])
{
free (channel_user->modes);
channel_user->modes = modes;
}
else
free (modes);
} }
// TODO: get rid of channel users missing from "updates": // TODO: get rid of channel users missing from "updates":