adding more different emails, move emails in extra folder

This commit is contained in:
Dario 2020-02-04 18:09:32 +01:00
parent c51644b2e7
commit f00a408ad2
17 changed files with 111 additions and 20 deletions

View File

@ -26,6 +26,7 @@ FILE(GLOB SINGLETON_MANAGER "src/cpp/SingletonManager/*.h" "src/cpp/SingletonMan
FILE(GLOB LIB_SRC "src/cpp/lib/*.h" "src/cpp/lib/*.cpp")
FILE(GLOB MODEL "src/cpp/model/*.h" "src/cpp/model/*.cpp")
FILE(GLOB MODEL_TABLE "src/cpp/model/table/*.h" "src/cpp/model/table/*.cpp")
FILE(GLOB MODEL_EMAIL "src/cpp/model/email/*.h" "src/cpp/model/email/*.cpp")
FILE(GLOB CRYPTO "src/cpp/Crypto/*.h" "src/cpp/Crypto/*.cpp")
FILE(GLOB MAIN "src/cpp/*.cpp" "src/cpp/*.c" "src/cpp/*.h")
FILE(GLOB MYSQL "src/cpp/MySQL/*.cpp" "src/cpp/MySQL/*.h" "src/cpp/MySQL/Poco/*.h")
@ -35,7 +36,7 @@ FILE(GLOB TEST "src/cpp/test/*.cpp" "src/cpp/test/*.h")
SET(LOCAL_SRCS
${CONTROLLER} ${TINF} ${MAIN} ${HTTPInterface}
${JSONInterface} ${CRYPTO} ${MODEL} ${MODEL_TABLE}
${JSONInterface} ${CRYPTO} ${MODEL} ${MODEL_TABLE} ${MODEL_EMAIL}
${SINGLETON_MANAGER} ${LIB_SRC} ${MYSQL} ${TASKS}
${PROTO_GRADIDO}
)
@ -49,6 +50,7 @@ source_group("tinf" FILES ${TINF})
source_group("crypto" FILES ${CRYPTO})
source_group("tasks" FILES ${TASKS})
source_group("model\\table" FILES ${MODEL_TABLE})
source_group("model\\email" FILES ${MODEL_EMAIL})
source_group("model" FILES ${MODEL})
source_group("mysql" FILES ${MYSQL})
source_group("SingletonManager" FILES ${SINGLETON_MANAGER})

View File

@ -2,4 +2,7 @@ HTTPInterface/LoginPage.cpp
HTTPInterface/CheckEmailPage.cpp
HTTPInterface/ResetPassword.cpp
model/Session.cpp
model/Email.cpp
model/Email/Email.cpp
model/Email/EmailCustomReply.cpp
model/Email/EmailNotificationCreation.cpp
model/Email/EmailNotificationTransfer.cpp

View File

@ -82,8 +82,8 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
}*/
auto lastExternReferer = mSession->getLastReferer();
//lastExternReferer = "";
if(lastExternReferer != "") {
printf("last extern referer: %s\n", lastExternReferer.data());
if(lastExternReferer != "" && lastExternReferer.find("transaction-send-coins") == std::string::npos) {
//printf("last extern referer: %s\n", lastExternReferer.data());
response.redirect(lastExternReferer);
} else {
response.redirect(ServerConfig::g_php_serverPath + "state-balances/overview");

View File

@ -15,7 +15,7 @@
#include "../lib/MultithreadQueue.h"
#include "../tasks/Thread.h"
#include "../model/Email.h"
#include "../model/Email/Email.h"
class EmailManager : public UniLib::lib::Thread
{

View File

@ -6,7 +6,7 @@
#include "../lib/ErrorList.h"
#include "../model/Email.h"
#include "../model/Email/Email.h"
#include "EmailManager.h"

View File

@ -132,9 +132,11 @@ void SingletonTaskObserver::removeTask(DHASH id, TaskObserverType type)
}
}
else {
em->addError(new Error(funcName, "entry not found"));
em->addError(new ParamError(funcName, "existing entry count", mObserverEntrys.getNItems()));
em->sendErrorsAsEmail();
if (mObserverEntrys.getNItems() > 0) {
em->addError(new Error(funcName, "entry not found"));
em->addError(new ParamError(funcName, "existing entry count", mObserverEntrys.getNItems()));
em->sendErrorsAsEmail();
}
}
unlock();
}

View File

@ -1,8 +1,10 @@
#include "Email.h"
#include "../SingletonManager/EmailManager.h"
#include "../../SingletonManager/EmailManager.h"
#include "Poco/Net/MediaType.h"
#include "../TransactionBase.h"
namespace model {
const static char EmailText_emailVerification[] = {u8"\
@ -45,6 +47,17 @@ Bitte logge dich im Admin-Bereich um das Problem zu lösen.\n\
\n\
LG \n\
Gradido Login Server\
" };
const static char EmailText_notificationTransactionCreation[] = { u8"\
Hallo [first_name] [last_name],\n\
\n\
Für dich wurden soeben [amount] GDD geschöpft.\n\
\n\
Bitte antworte nicht auf diese E-Mail\n\
\n\
Mit freundlichen Grüßen\n\
Gradido Login-Server\n\
" };
Email::Email(AutoPtr<controller::EmailVerificationCode> emailVerification, AutoPtr<controller::User> user, EmailType type)
@ -207,7 +220,7 @@ Gradido Login Server\
result.replace(findPos, 6, link);
}
else {
addError(new Error(functionName, "no email placeholder found"));
//addError(new Error(functionName, "no email placeholder found"));
}
return result;
}
@ -226,4 +239,18 @@ Gradido Login Server\
}
return result;
}
std::string Email::replaceAmount(const char* src, Poco::Int64 gradido_cent)
{
std::string result = src;
static const char* functionName = "Email::replaceAmount";
int findPos = result.find("[amount]");
if (findPos != result.npos) {
result.replace(findPos, 8, TransactionBase::amountToString(gradido_cent));
}
else {
addError(new Error(functionName, "no amount placeholder found"));
}
return result;
}
}

View File

@ -12,12 +12,12 @@
#include "Poco/Net/MailMessage.h"
#include "../controller/EmailVerificationCode.h"
#include "../controller/User.h"
#include "../../controller/EmailVerificationCode.h"
#include "../../controller/User.h"
#include "../SingletonManager/LanguageManager.h"
#include "../../SingletonManager/LanguageManager.h"
#include "../lib/ErrorList.h"
#include "../../lib/ErrorList.h"
namespace model {
using namespace Poco;
@ -29,7 +29,9 @@ namespace model {
EMAIL_USER_VERIFICATION_CODE,
EMAIL_ADMIN_USER_VERIFICATION_CODE,
EMAIL_USER_RESET_PASSWORD,
EMAIL_ADMIN_RESET_PASSWORD_REQUEST_WITHOUT_MEMORIZED_PASSPHRASE
EMAIL_ADMIN_RESET_PASSWORD_REQUEST_WITHOUT_MEMORIZED_PASSPHRASE,
EMAIL_NOTIFICATION_TRANSACTION_CREATION,
EMAIL_NOTIFICATION_TRANSACTION_TRANSFER
};
class Email: public ErrorList
@ -44,12 +46,13 @@ namespace model {
inline EmailType getType() { return mType; }
inline controller::User* getUser() { if (!mUser.isNull()) return mUser.get(); return nullptr; }
bool draft(Net::MailMessage* mailMessage, LanguageCatalog* langCatalog);
virtual bool draft(Net::MailMessage* mailMessage, LanguageCatalog* langCatalog);
inline void addContent(Poco::Net::StringPartSource* str_content) { mAdditionalStringPartSrcs.push(str_content); }
protected:
std::string replaceUserNamesAndLink(const char* src, const std::string& first_name, const std::string& last_name, const std::string& link);
std::string replaceEmail(const char* src, const std::string& email);
std::string replaceAmount(const char* src, Poco::Int64 gradido_cent);
AutoPtr<controller::EmailVerificationCode> mEmailVerificationCode;
AutoPtr<controller::User> mUser;

View File

@ -0,0 +1,20 @@
#include "EmailCustomReply.h"
#include "../../SingletonManager/EmailManager.h"
#include "Poco/Net/MediaType.h"
namespace model {
using namespace Poco;
EmailCustomReply::EmailCustomReply(AutoPtr<controller::User> user, const std::string& replyString, EmailType type)
: Email(user, type), mReplyStr(replyString)
{
}
bool EmailCustomReply::addReplyStr(Net::MailMessage* mailMessage)
{
return false;
}
}

View File

@ -0,0 +1,33 @@
/*!
*
* \author: einhornimmond
*
* \date: 04.02.20
*
* \brief: store email with additional reply address
*/
#ifndef GRADIDO_LOGIN_SERVER_MODEL_EMAIL_CUSTOM_REPLY_INCLUDE
#define GRADIDO_LOGIN_SERVER_MODEL_EMAIL_CUSTOM_REPLY_INCLUDE
#include "Email.h"
namespace model {
using namespace Poco;
class EmailCustomReply : public Email
{
public:
EmailCustomReply(AutoPtr<controller::User> user, const std::string& replyString, EmailType type);
//bool draft(Net::MailMessage* mailMessage, LanguageCatalog* langCatalog);
bool addReplyStr(Net::MailMessage* mailMessage);
protected:
std::string mReplyStr;
};
}
#endif //GRADIDO_LOGIN_SERVER_MODEL_EMAIL_INCLUDE

View File

@ -4,7 +4,7 @@
#include "CPUTask.h"
#include "Poco/Net/MailMessage.h"
#include "../model/Email.h"
#include "../model/Email/Email.h"
/*
* @author: Dario Rekowski

View File

@ -118,6 +118,7 @@ int SigningTransaction::run() {
mm->releaseMemory(finalBase64Bin);
return -7;
}
addError(new Error("Signing transaction final", *finalBase64Bin));
// create json request

View File

@ -60,8 +60,8 @@ enum PageState {
}*/
auto lastExternReferer = mSession->getLastReferer();
//lastExternReferer = "";
if(lastExternReferer != "") {
printf("last extern referer: %s\n", lastExternReferer.data());
if(lastExternReferer != "" && lastExternReferer.find("transaction-send-coins") == std::string::npos) {
//printf("last extern referer: %s\n", lastExternReferer.data());
response.redirect(lastExternReferer);
} else {
response.redirect(ServerConfig::g_php_serverPath + "state-balances/overview");