aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree/away.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-08-04 13:09:06 +0100
committerGravatar Sadie Powell2023-08-04 13:14:49 +0100
commit635feb1a9a3ece8f06e1ad620b7b5a1eb21f8a44 (patch)
treead84709d188e70bf3e8aab74d85c59e40a711e12 /src/modules/m_spanningtree/away.cpp
parentFix an inverted condition in the DNSBL module. (diff)
Rework how away state is stored internally.
This will be necessary for implementing pre-away as well as some changes for WATCH compatibility with Unreal.
Diffstat (limited to 'src/modules/m_spanningtree/away.cpp')
-rw-r--r--src/modules/m_spanningtree/away.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/modules/m_spanningtree/away.cpp b/src/modules/m_spanningtree/away.cpp
index edb59b21d..ec9f05041 100644
--- a/src/modules/m_spanningtree/away.cpp
+++ b/src/modules/m_spanningtree/away.cpp
@@ -30,22 +30,17 @@
CmdResult CommandAway::HandleRemote(::RemoteUser* u, Params& params)
{
+ const auto prevstate = u->away;
if (!params.empty())
{
- if (params.size() > 1)
- u->awaytime = ServerCommand::ExtractTS(params[0]);
- else
- u->awaytime = ServerInstance->Time();
-
- u->awaymsg = params.back();
- awayevprov.Call(&Away::EventListener::OnUserAway, u);
+ time_t awaytime = params.size() > 1 ? ServerCommand::ExtractTS(params[0]) : 0;
+ u->away.emplace(params.back(), awaytime);
+ awayevprov.Call(&Away::EventListener::OnUserAway, u, prevstate);
}
else
{
- const std::string awaymsg = u->awaymsg;
- u->awaytime = 0;
- u->awaymsg.clear();
- awayevprov.Call(&Away::EventListener::OnUserBack, u, awaymsg);
+ u->away.reset();
+ awayevprov.Call(&Away::EventListener::OnUserBack, u, prevstate);
}
return CmdResult::SUCCESS;
}
@@ -53,6 +48,6 @@ CmdResult CommandAway::HandleRemote(::RemoteUser* u, Params& params)
CommandAway::Builder::Builder(User* user)
: CmdBuilder(user, "AWAY")
{
- if (!user->awaymsg.empty())
- push_int(user->awaytime).push_last(user->awaymsg);
+ if (user->IsAway())
+ push_int(user->away->time).push_last(user->away->message);
}