From c98602bf19c3b3fa4966dd4fe4f990e5977e163a Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 8 Mar 2025 14:44:32 +0000 Subject: [PATCH] Fix various webcpanel bugs relating to nickname protection. --- modules/webcpanel/pages/nickserv/info.cpp | 12 +++++++----- modules/webcpanel/templates/nickserv/info.html | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/webcpanel/pages/nickserv/info.cpp b/modules/webcpanel/pages/nickserv/info.cpp index be8b110f5..9846f6b9c 100644 --- a/modules/webcpanel/pages/nickserv/info.cpp +++ b/modules/webcpanel/pages/nickserv/info.cpp @@ -58,7 +58,7 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str } if (na->nc->HasExt("PROTECT") != !!message.post_data.count("protect")) { - if (!na->nc->HasExt("PROTECT")) + if (na->nc->HasExt("PROTECT")) { na->nc->Shrink("PROTECT"); na->nc->Shrink("PROTECT_AFTER"); @@ -75,20 +75,22 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str auto minprotect = block.Get("minprotect", "10s"); auto maxprotect = block.Get("maxprotect", "10m"); - auto secs = Anope::TryConvert(message.post_data["greet"]); + auto secs = Anope::TryConvert(message.post_data["protect_after"]); if (!secs) - replacements["ERRORS"] = "Protection after seconds are not valid"; + replacements["ERRORS"] = "Protection delay must be a number of seconds"; else if (*secs < minprotect || *secs > maxprotect) { replacements["ERRORS"] = Anope::printf("Protection delay must be between %ld and %ld seconds.", minprotect, maxprotect); } - else + else if (!na->nc->HasExt("PROTECT_AFTER") || *secs != *na->nc->GetExt("PROTECT_AFTER")) { na->nc->Extend("PROTECT_AFTER", *secs); replacements["MESSAGES"] = "Protect after updated"; } } + else if (na->nc->HasExt("PROTECT") && !message.post_data.count("protect_after")) + na->nc->Shrink("PROTECT_AFTER"); if (na->nc->HasExt("NS_KEEP_MODES") != !!message.post_data.count("keepmodes")) { if (!na->nc->HasExt("NS_KEEP_MODES")) @@ -133,7 +135,7 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str replacements["PROTECT"]; auto *protectafter = na->nc->GetExt("PROTECT_AFTER"); if (protectafter) - replacements["PROTECT_AFTER"] = *protectafter; + replacements["PROTECT_AFTER"] = Anope::ToString(*protectafter); } if (na->nc->HasExt("NS_KEEP_MODES")) replacements["KEEPMODES"]; diff --git a/modules/webcpanel/templates/nickserv/info.html b/modules/webcpanel/templates/nickserv/info.html index 794598196..fa279ac99 100644 --- a/modules/webcpanel/templates/nickserv/info.html +++ b/modules/webcpanel/templates/nickserv/info.html @@ -65,7 +65,7 @@ - Protect after: + Protection delay: