diff options
author | Sadie Powell <sadie@witchery.services> | 2025-02-14 21:47:33 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2025-02-14 21:47:33 +0000 |
commit | 69bc149f7fff0504c3942bef6f061f96046d5730 (patch) | |
tree | d5a36d53b20f3b666b118fd70cd8c0e86187d534 | |
parent | 3c340f550a195108b614774f65e1236748541a92 (diff) |
Reduce indentation in rpc_main.
-rw-r--r-- | modules/rpc/rpc_main.cpp | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/modules/rpc/rpc_main.cpp b/modules/rpc/rpc_main.cpp index ab48068c2..5e33447ff 100644 --- a/modules/rpc/rpc_main.cpp +++ b/modules/rpc/rpc_main.cpp @@ -85,44 +85,46 @@ private: void DoCommand(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) { Anope::string service = request.data.size() > 0 ? request.data[0] : ""; - Anope::string user = request.data.size() > 1 ? request.data[1] : ""; + Anope::string user = request.data.size() > 1 ? request.data[1] : ""; Anope::string command = request.data.size() > 2 ? request.data[2] : ""; if (service.empty() || user.empty() || command.empty()) - request.Error(-32602, "Invalid parameters"); - else { - BotInfo *bi = BotInfo::Find(service, true); - if (!bi) - request.Error(-32000, "Invalid service"); - else - { - NickAlias *na = NickAlias::Find(user); + request.Error(-32602, "Invalid parameters"); + return; + } - Anope::string out; + BotInfo *bi = BotInfo::Find(service, true); + if (!bi) + { + request.Error(-32000, "Invalid service"); + return; + } - struct RPCommandReply final - : CommandReply - { - Anope::string &str; + NickAlias *na = NickAlias::Find(user); - RPCommandReply(Anope::string &s) : str(s) { } + Anope::string out; - void SendMessage(BotInfo *source, const Anope::string &msg) override - { - str += msg + "\n"; - }; - } - reply(out); + struct RPCommandReply final + : CommandReply + { + Anope::string &str; - User *u = User::Find(user, true); - CommandSource source(user, u, na ? *na->nc : NULL, &reply, bi); - Command::Run(source, command); + RPCommandReply(Anope::string &s) : str(s) { } - if (!out.empty()) - request.Reply("return", out); - } + void SendMessage(BotInfo *source, const Anope::string &msg) override + { + str += msg + "\n"; + }; } + reply(out); + + User *u = User::Find(user, true); + CommandSource source(user, u, na ? *na->nc : NULL, &reply, bi); + Command::Run(source, command); + + if (!out.empty()) + request.Reply("return", out); } static bool DoCheckAuthentication(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) @@ -131,16 +133,15 @@ private: Anope::string password = request.data.size() > 1 ? request.data[1] : ""; if (username.empty() || password.empty()) - request.Error(-32602, "Invalid parameters"); - else { - auto *req = new RPCIdentifyRequest(me, request, client, iface, username, password); - FOREACH_MOD(OnCheckAuthentication, (NULL, req)); - req->Dispatch(); - return false; + request.Error(-32602, "Invalid parameters"); + return true; } - return true; + auto *req = new RPCIdentifyRequest(me, request, client, iface, username, password); + FOREACH_MOD(OnCheckAuthentication, (NULL, req)); + req->Dispatch(); + return false; } static void DoStats(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) @@ -266,8 +267,8 @@ private: static void DoNotice(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) { - Anope::string from = request.data.size() > 0 ? request.data[0] : ""; - Anope::string to = request.data.size() > 1 ? request.data[1] : ""; + Anope::string from = request.data.size() > 0 ? request.data[0] : ""; + Anope::string to = request.data.size() > 1 ? request.data[1] : ""; Anope::string message = request.data.size() > 2 ? request.data[2] : ""; BotInfo *bi = BotInfo::Find(from, true); |