mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-08 05:23:13 +02:00
Use IsLoggedIn() macro everywhere where possible.
Based on previous reports and patches from k4be in https://github.com/unrealircd/unrealircd/pull/129 Looks much cleaner now. This also filters out the edge case where user_account_login() could have been called when a user transitioned from "not logged in" to "unconfirmed account". It did not cause any issues AFAICT but it is not really expected either.
This commit is contained in:
@@ -70,7 +70,7 @@ int account_notify_account_login(Client *client, MessageTag *recv_mtags)
|
||||
CAP_ACCOUNT_NOTIFY, mtags,
|
||||
":%s ACCOUNT %s",
|
||||
client->name,
|
||||
!isdigit(*client->user->svid) ? client->user->svid : "*");
|
||||
IsLoggedIn(client) ? client->user->svid : "*");
|
||||
free_message_tags(mtags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ void mtag_add_account(Client *client, MessageTag *recv_mtags, MessageTag **mtag_
|
||||
{
|
||||
MessageTag *m;
|
||||
|
||||
if (client && client->user && (*client->user->svid != '*') && !isdigit(*client->user->svid))
|
||||
if (IsLoggedIn(client))
|
||||
{
|
||||
m = safe_alloc(sizeof(MessageTag));
|
||||
safe_strdup(m->name, "account");
|
||||
|
||||
@@ -221,7 +221,7 @@ void clear_user_invisible_announce(Channel *channel, Client *client, MessageTag
|
||||
|
||||
ircsnprintf(exjoinbuf, sizeof(exjoinbuf), ":%s!%s@%s JOIN %s %s :%s",
|
||||
client->name, client->user->username, GetHost(client), channel->chname,
|
||||
!isdigit(*client->user->svid) ? client->user->svid : "*",
|
||||
IsLoggedIn(client) ? client->user->svid : "*",
|
||||
client->info);
|
||||
|
||||
new_message_special(client, recv_mtags, &mtags, ":%s JOIN %s", client->name, channel->chname);
|
||||
@@ -343,7 +343,7 @@ int moded_chanmode(Client *client, Channel *channel, MessageTag *recv_mtags, cha
|
||||
sendto_one(user, mtags, ":%s!%s@%s JOIN %s %s :%s",
|
||||
i->client->name, i->client->user->username, GetHost(i->client),
|
||||
channel->chname,
|
||||
!isdigit(*i->client->user->svid) ? i->client->user->svid : "*",
|
||||
IsLoggedIn(i->client) ? i->client->user->svid : "*",
|
||||
i->client->info);
|
||||
} else {
|
||||
sendto_one(user, mtags, ":%s!%s@%s JOIN :%s", i->client->name, i->client->user->username, GetHost(i->client), channel->chname);
|
||||
|
||||
+2
-2
@@ -198,7 +198,7 @@ void _send_join_to_local_users(Client *client, Channel *channel, MessageTag *mta
|
||||
|
||||
ircsnprintf(exjoinbuf, sizeof(exjoinbuf), ":%s!%s@%s JOIN %s %s :%s",
|
||||
client->name, client->user->username, GetHost(client), channel->chname,
|
||||
!isdigit(*client->user->svid) ? client->user->svid : "*",
|
||||
IsLoggedIn(client) ? client->user->svid : "*",
|
||||
client->info);
|
||||
|
||||
for (lp = channel->members; lp; lp = lp->next)
|
||||
@@ -722,7 +722,7 @@ void _userhost_changed(Client *client)
|
||||
|
||||
ircsnprintf(exjoinbuf, sizeof(exjoinbuf), ":%s!%s@%s JOIN %s %s :%s",
|
||||
client->name, client->user->username, GetHost(client), channel->chname,
|
||||
!isdigit(*client->user->svid) ? client->user->svid : "*",
|
||||
IsLoggedIn(client) ? client->user->svid : "*",
|
||||
client->info);
|
||||
|
||||
modes = get_chmodes_for_user(client, flags);
|
||||
|
||||
+1
-1
@@ -689,7 +689,7 @@ nickkill2done:
|
||||
if (IsDead(client))
|
||||
return;
|
||||
|
||||
if (client->user->svid[0] != '0')
|
||||
if (IsLoggedIn(client))
|
||||
{
|
||||
user_account_login(recv_mtags, client);
|
||||
/* no need to check for kill upon user_account_login() here
|
||||
|
||||
+2
-1
@@ -69,8 +69,9 @@ int sasl_account_login(Client *client, MessageTag *mtags)
|
||||
{
|
||||
if (!MyConnect(client))
|
||||
return 0;
|
||||
|
||||
/* Notify user */
|
||||
if (client->user->svid[0] != '0')
|
||||
if (IsLoggedIn(client))
|
||||
{
|
||||
sendnumeric(client, RPL_LOGGEDIN,
|
||||
BadPtr(client->name) ? "*" : client->name,
|
||||
|
||||
+11
-1
@@ -406,8 +406,18 @@ void do_svsmode(Client *client, MessageTag *recv_mtags, int parc, char *parv[],
|
||||
case 'd':
|
||||
if (parv[3])
|
||||
{
|
||||
int was_logged_in = IsLoggedIn(target) ? 1 : 0;
|
||||
strlcpy(target->user->svid, parv[3], sizeof(target->user->svid));
|
||||
user_account_login(recv_mtags, target);
|
||||
if (!was_logged_in && !IsLoggedIn(target))
|
||||
{
|
||||
/* We don't care about users going from not logged in
|
||||
* to not logged in, which is something that can happen
|
||||
* from 0 to 123456, eg from no account to unconfirmed account.
|
||||
*/
|
||||
} else {
|
||||
/* LOGIN or LOGOUT (or account change) */
|
||||
user_account_login(recv_mtags, target);
|
||||
}
|
||||
if (MyConnect(target) && IsDead(target))
|
||||
return; /* was killed due to *LINE on ~a probably */
|
||||
}
|
||||
|
||||
+1
-3
@@ -4422,9 +4422,7 @@ void ban_target_to_tkl_layer(BanTarget ban_target, BanAction action, Client *cli
|
||||
|
||||
if (ban_target == BAN_TARGET_ACCOUNT)
|
||||
{
|
||||
if (client->user && client->user->svid &&
|
||||
strcmp(client->user->svid, "0") &&
|
||||
(*client->user->svid != ':'))
|
||||
if (IsLoggedIn(client) && (*client->user->svid != ':'))
|
||||
{
|
||||
/* Place a ban on ~a:Accountname */
|
||||
strlcpy(username, "~a:", sizeof(username));
|
||||
|
||||
+1
-1
@@ -328,7 +328,7 @@ CMD_FUNC(cmd_whois)
|
||||
* display services account name if it's actually a services account name and
|
||||
* not a legacy timestamp. --nenolod
|
||||
*/
|
||||
if (!isdigit(*target->user->svid))
|
||||
if (IsLoggedIn(target))
|
||||
sendnumeric(client, RPL_WHOISLOGGEDIN, name, target->user->svid);
|
||||
|
||||
/*
|
||||
|
||||
+2
-3
@@ -426,8 +426,7 @@ static int do_match(Client *client, Client *acptr, char *mask, struct who_format
|
||||
return 1;
|
||||
|
||||
/* match account */
|
||||
if (IsMatch(fmt, WMATCH_ACCOUNT) && !BadPtr(acptr->user->svid) &&
|
||||
!isdigit(*acptr->user->svid) && match_simple(mask, acptr->user->svid))
|
||||
if (IsMatch(fmt, WMATCH_ACCOUNT) && IsLoggedIn(acptr) && match_simple(mask, acptr->user->svid))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -813,7 +812,7 @@ static void do_who(Client *client, Client *acptr, Channel *channel, struct who_f
|
||||
(int)((MyUser(acptr) && !hide_idle_time(client, acptr)) ? (TStime() - acptr->local->last) : 0));
|
||||
}
|
||||
if (HasField(fmt, FIELD_ACCOUNT))
|
||||
append_format(str, sizeof str, &pos, " %s", (!isdigit(*acptr->user->svid)) ? acptr->user->svid : "0");
|
||||
append_format(str, sizeof str, &pos, " %s", IsLoggedIn(acptr) ? acptr->user->svid : "0");
|
||||
if (HasField(fmt, FIELD_OPLEVEL))
|
||||
append_format(str, sizeof str, &pos, " %s", (channel && is_skochanop(acptr, channel)) ? "999" : "n/a");
|
||||
if (HasField(fmt, FIELD_REPUTATION))
|
||||
|
||||
Reference in New Issue
Block a user