1
0
mirror of https://github.com/anope/anope.git synced 2026-06-28 15:36:38 +02:00

Return references instead of pointers from the config system.

We used to return NULL from these methods but now we return an empty
block so this can never actually be null now.
This commit is contained in:
Sadie Powell
2025-03-02 14:51:02 +00:00
parent a5e5eb5eb0
commit f9911dde52
124 changed files with 811 additions and 809 deletions
+13 -13
View File
@@ -15,14 +15,14 @@
Mail::Message::Message(const Anope::string &sf, const Anope::string &mailto, const Anope::string &a, const Anope::string &s, const Anope::string &m)
: Thread()
, sendmail_path(Config->GetBlock("mail")->Get<const Anope::string>("sendmailpath", "/usr/sbin/sendmail -it"))
, sendmail_path(Config->GetBlock("mail").Get<const Anope::string>("sendmailpath", "/usr/sbin/sendmail -it"))
, send_from(sf)
, mail_to(mailto)
, addr(a)
, subject(s)
, message(m)
, content_type(Config->GetBlock("mail")->Get<const Anope::string>("content_type", "text/plain; charset=UTF-8"))
, dont_quote_addresses(Config->GetBlock("mail")->Get<bool>("dontquoteaddresses"))
, content_type(Config->GetBlock("mail").Get<const Anope::string>("content_type", "text/plain; charset=UTF-8"))
, dont_quote_addresses(Config->GetBlock("mail").Get<bool>("dontquoteaddresses"))
{
}
@@ -72,32 +72,32 @@ bool Mail::Send(User *u, NickCore *nc, BotInfo *service, const Anope::string &su
if (!nc || !service || subject.empty() || message.empty())
return false;
Configuration::Block *b = Config->GetBlock("mail");
Configuration::Block &b = Config->GetBlock("mail");
if (!u)
{
if (!b->Get<bool>("usemail") || b->Get<const Anope::string>("sendfrom").empty())
if (!b.Get<bool>("usemail") || b.Get<const Anope::string>("sendfrom").empty())
return false;
else if (nc->email.empty())
return false;
nc->lastmail = Anope::CurTime;
Thread *t = new Mail::Message(b->Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message);
Thread *t = new Mail::Message(b.Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message);
t->Start();
return true;
}
else
{
if (!b->Get<bool>("usemail") || b->Get<const Anope::string>("sendfrom").empty())
if (!b.Get<bool>("usemail") || b.Get<const Anope::string>("sendfrom").empty())
u->SendMessage(service, _("Services have been configured to not send mail."));
else if (Anope::CurTime - u->lastmail < b->Get<time_t>("delay"))
u->SendMessage(service, _("Please wait \002%lu\002 seconds and retry."), (unsigned long)b->Get<time_t>("delay") - (Anope::CurTime - u->lastmail));
else if (Anope::CurTime - u->lastmail < b.Get<time_t>("delay"))
u->SendMessage(service, _("Please wait \002%lu\002 seconds and retry."), (unsigned long)b.Get<time_t>("delay") - (Anope::CurTime - u->lastmail));
else if (nc->email.empty())
u->SendMessage(service, _("Email for \002%s\002 is invalid."), nc->display.c_str());
else
{
u->lastmail = nc->lastmail = Anope::CurTime;
Thread *t = new Mail::Message(b->Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message);
Thread *t = new Mail::Message(b.Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message);
t->Start();
return true;
}
@@ -108,12 +108,12 @@ bool Mail::Send(User *u, NickCore *nc, BotInfo *service, const Anope::string &su
bool Mail::Send(NickCore *nc, const Anope::string &subject, const Anope::string &message)
{
Configuration::Block *b = Config->GetBlock("mail");
if (!b->Get<bool>("usemail") || b->Get<const Anope::string>("sendfrom").empty() || !nc || nc->email.empty() || subject.empty() || message.empty())
Configuration::Block &b = Config->GetBlock("mail");
if (!b.Get<bool>("usemail") || b.Get<const Anope::string>("sendfrom").empty() || !nc || nc->email.empty() || subject.empty() || message.empty())
return false;
nc->lastmail = Anope::CurTime;
Thread *t = new Mail::Message(b->Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message);
Thread *t = new Mail::Message(b.Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message);
t->Start();
return true;