diff options
author | Adam <Adam@anope.org> | 2014-06-25 11:02:19 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-06-25 11:02:19 -0400 |
commit | ee3289029d61da12013e0f5a3e4faf2d07543a0e (patch) | |
tree | df7391c321a913fc56db2d075292c0a6ddb0536d /modules/commands/hs_request.cpp | |
parent | fd9bb0ea7e3c8a39f1632c2ebbdc25d0fac192a0 (diff) |
Remove the rest of the 1.8 logic "let's write all of the command handler with no return statement!"
Fix if (something) else if (!something) tests
Remove returns at the bottom of void functions
Diffstat (limited to 'modules/commands/hs_request.cpp')
-rw-r--r-- | modules/commands/hs_request.cpp | 72 |
1 files changed, 43 insertions, 29 deletions
diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index 1d9207e05..d1fb0e640 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -185,23 +185,30 @@ class CommandHSActivate : public Command } const Anope::string &nick = params[0]; - NickServ::Nick *na = NickServ::FindNick(nick); - HostRequest *req = na ? na->GetExt<HostRequest>("hostrequest") : NULL; - if (req) - { - na->SetVhost(req->ident, req->host, source.GetNick(), req->time); - Event::OnSetVhost(&Event::SetVhost::OnSetVhost, na); - if (Config->GetModule(this->owner)->Get<bool>("memouser") && MemoServ::service) - MemoServ::service->Send(source.service->nick, na->nick, _("[auto memo] Your requested vHost has been approved."), true); + if (!na) + { + source.Reply(_("\002{0}\002 isn't registered."), nick); + return; + } - source.Reply(_("Vhost for \002{0}\002 has been activated."), na->nick); - Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host; - na->Shrink<HostRequest>("hostrequest"); + HostRequest *req = na->GetExt<HostRequest>("hostrequest"); + if (!req) + { + source.Reply(_("\002{0}\002 does not have a pending vhost request."), na->nick); + return; } - else - source.Reply(_("\002{0}\002 does not have a pending vhost request."), nick); + + na->SetVhost(req->ident, req->host, source.GetNick(), req->time); + Event::OnSetVhost(&Event::SetVhost::OnSetVhost, na); + + if (Config->GetModule(this->owner)->Get<bool>("memouser") && MemoServ::service) + MemoServ::service->Send(source.service->nick, na->nick, _("[auto memo] Your requested vHost has been approved."), true); + + source.Reply(_("Vhost for \002{0}\002 has been activated."), na->nick); + Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host; + na->Shrink<HostRequest>("hostrequest"); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -235,27 +242,34 @@ class CommandHSReject : public Command const Anope::string &reason = params.size() > 1 ? params[1] : ""; NickServ::Nick *na = NickServ::FindNick(nick); - HostRequest *req = na ? na->GetExt<HostRequest>("hostrequest") : NULL; - if (req) + if (!na) { - na->Shrink<HostRequest>("hostrequest"); + source.Reply(_("\002{0}\002 isn't registered."), nick); + return; + } - if (Config->GetModule(this->owner)->Get<bool>("memouser") && MemoServ::service) - { - Anope::string message; - if (!reason.empty()) - message = Anope::printf(_("[auto memo] Your requested vHost has been rejected. Reason: %s"), reason.c_str()); - else - message = _("[auto memo] Your requested vHost has been rejected."); + HostRequest *req = na->GetExt<HostRequest>("hostrequest"); + if (!req) + { + source.Reply(_("\002{0}\002 does not have a pending vhost request."), na->nick); + return; + } - MemoServ::service->Send(source.service->nick, nick, Language::Translate(source.GetAccount(), message.c_str()), true); - } + na->Shrink<HostRequest>("hostrequest"); + + if (Config->GetModule(this->owner)->Get<bool>("memouser") && MemoServ::service) + { + Anope::string message; + if (!reason.empty()) + message = Anope::printf(_("[auto memo] Your requested vHost has been rejected. Reason: %s"), reason.c_str()); + else + message = _("[auto memo] Your requested vHost has been rejected."); - source.Reply(_("Vhost for \002{0}\002 has been rejected."), na->nick); - Log(LOG_COMMAND, source, this) << "to reject vhost for " << nick << " (" << (!reason.empty() ? reason : "no reason") << ")"; + MemoServ::service->Send(source.service->nick, nick, Language::Translate(source.GetAccount(), message.c_str()), true); } - else - source.Reply(_("\002{0}\002 does not have a pending vhost request."), nick); + + source.Reply(_("Vhost for \002{0}\002 has been rejected."), na->nick); + Log(LOG_COMMAND, source, this) << "to reject vhost for " << nick << " (" << (!reason.empty() ? reason : "no reason") << ")"; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override |