From ee3289029d61da12013e0f5a3e4faf2d07543a0e Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 25 Jun 2014 11:02:19 -0400 Subject: 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 --- modules/commands/hs_request.cpp | 72 ++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 29 deletions(-) (limited to 'modules/commands/hs_request.cpp') 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") : 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("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 *req = na->GetExt("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("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"); } 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") : NULL; - if (req) + if (!na) { - na->Shrink("hostrequest"); + source.Reply(_("\002{0}\002 isn't registered."), nick); + return; + } - if (Config->GetModule(this->owner)->Get("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"); + 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"); + + if (Config->GetModule(this->owner)->Get("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 -- cgit