mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
prevent exit email thread by exception because of invalid email, add date to email log string
This commit is contained in:
parent
8a143be842
commit
8538a42361
@ -57,7 +57,8 @@ bool EmailManager::init(const Poco::Util::LayeredConfiguration& cfg)
|
||||
|
||||
void EmailManager::addEmail(model::Email* email) {
|
||||
if (mDisableEmail) {
|
||||
std::string log_message = "Email should be sended to: ";
|
||||
std::string dateTimeString = Poco::DateTimeFormatter::format(Poco::DateTime(), "%d.%m.%y %H:%M:%S");
|
||||
std::string log_message = dateTimeString + " Email should be sended to: ";
|
||||
auto email_user = email->getUser();
|
||||
if (email_user && email_user->getModel()) {
|
||||
log_message += email_user->getModel()->getNameWithEmail();
|
||||
@ -131,14 +132,33 @@ int EmailManager::ThreadFunction()
|
||||
if (catalogs[lang_code].isNull()) {
|
||||
catalogs[lang_code] = lm->getFreeCatalog(lang_code);
|
||||
}
|
||||
bool email_sended = false;
|
||||
if (email->draft(&mailMessage, catalogs[lang_code])) {
|
||||
|
||||
try {
|
||||
mailClientSession.sendMessage(mailMessage);
|
||||
email_sended = true;
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
email_sended = false;
|
||||
errors.addError(new ParamError(function_name, "poco exception sending email", ex.displayText()));
|
||||
auto user = email->getUser();
|
||||
if (user && !user->getModel().isNull()) {
|
||||
errors.addError(new ParamError(function_name, "email", user->getModel()->getEmail()));
|
||||
}
|
||||
|
||||
errors.sendErrorsAsEmail();
|
||||
|
||||
}
|
||||
// add for debugging
|
||||
if (email->getUser()) {
|
||||
//printf("send email to %s\n", user_model->getEmail().data());
|
||||
auto user_model = email->getUser()->getModel();
|
||||
std::string log_message = "Email sended to: ";
|
||||
std::string dateTimeString = Poco::DateTimeFormatter::format(Poco::DateTime(), "%d.%m.%y %H:%M:%S");
|
||||
std::string log_message = dateTimeString + " Email sended to: ";
|
||||
if (!email_sended) {
|
||||
log_message = dateTimeString + " Email not sended to: ";
|
||||
}
|
||||
auto email_user = email->getUser();
|
||||
if (user_model) {
|
||||
log_message += email_user->getModel()->getNameWithEmail();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user