summaryrefslogtreecommitdiff
path: root/src/mail.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mail.cpp')
-rw-r--r--src/mail.cpp56
1 files changed, 34 insertions, 22 deletions
diff --git a/src/mail.cpp b/src/mail.cpp
index 80a80d6d7..f8f6b0648 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1,28 +1,39 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2017 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2003-2017 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
#include "services.h"
#include "mail.h"
#include "config.h"
+#include "bots.h"
+#include "protocol.h"
+#include "modules/nickserv.h"
-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")), send_from(sf), mail_to(mailto), addr(a), subject(s), message(m), dont_quote_addresses(Config->GetBlock("mail")->Get<bool>("dontquoteaddresses")), success(false)
+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<Anope::string>("sendmailpath")), send_from(sf), mail_to(mailto), addr(a), subject(s), message(m), dont_quote_addresses(Config->GetBlock("mail")->Get<bool>("dontquoteaddresses")), success(false)
{
}
Mail::Message::~Message()
{
if (success)
- Log(LOG_NORMAL, "mail") << "Successfully delivered mail for " << mail_to << " (" << addr << ")";
+ Anope::Logger.Category("mail").Log(_("Successfully delivered mail for {0} ({1})"), mail_to, addr);
else
- Log(LOG_NORMAL, "mail") << "Error delivering mail for " << mail_to << " (" << addr << ")";
+ Anope::Logger.Category("mail").Log(_("Error delivering mail for {0} ({1})"), mail_to, addr);
}
void Mail::Message::Run()
@@ -50,7 +61,7 @@ void Mail::Message::Run()
SetExitState();
}
-bool Mail::Send(User *u, NickCore *nc, BotInfo *service, const Anope::string &subject, const Anope::string &message)
+bool Mail::Send(User *u, NickServ::Account *nc, ServiceBot *service, const Anope::string &subject, const Anope::string &message)
{
if (!nc || !service || subject.empty() || message.empty())
return false;
@@ -59,28 +70,29 @@ bool Mail::Send(User *u, NickCore *nc, BotInfo *service, const Anope::string &su
if (!u)
{
- if (!b->Get<bool>("usemail") || b->Get<const Anope::string>("sendfrom").empty())
+ if (!b->Get<bool>("usemail") || b->Get<Anope::string>("sendfrom").empty())
return false;
- else if (nc->email.empty())
+ else if (nc->GetEmail().empty())
return false;
- nc->lastmail = Anope::CurTime;
- Thread *t = new Mail::Message(b->Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message);
+ nc->SetLastMail(Anope::CurTime);
+ Thread *t = new Mail::Message(b->Get<Anope::string>("sendfrom"), nc->GetDisplay(), nc->GetEmail(), 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<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%d\002 seconds and retry."), b->Get<time_t>("delay") - (Anope::CurTime - u->lastmail));
- else if (nc->email.empty())
- u->SendMessage(service, _("E-mail for \002%s\002 is invalid."), nc->display.c_str());
+ else if (nc->GetEmail().empty())
+ u->SendMessage(service, _("E-mail for \002%s\002 is invalid."), nc->GetDisplay().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);
+ u->lastmail = Anope::CurTime;
+ nc->SetLastMail(Anope::CurTime);
+ Thread *t = new Mail::Message(b->Get<Anope::string>("sendfrom"), nc->GetDisplay(), nc->GetEmail(), subject, message);
t->Start();
return true;
}
@@ -89,14 +101,14 @@ 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)
+bool Mail::Send(NickServ::Account *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())
+ if (!b->Get<bool>("usemail") || b->Get<Anope::string>("sendfrom").empty() || !nc || nc->GetEmail().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);
+ nc->SetLastMail(Anope::CurTime);
+ Thread *t = new Mail::Message(b->Get<Anope::string>("sendfrom"), nc->GetDisplay(), nc->GetEmail(), subject, message);
t->Start();
return true;