<commit_before>#include "Mailer.h"
#include "../Interface/Server.h"
#include "../Interface/Database.h"
#include "database.h"
#include "../urlplugin/IUrlFactory.h"
#include "ClientMain.h"
#include <math.h>

IMutex* Mailer::mutex = NULL;
ICondition* Mailer::cond = NULL;
bool Mailer::queue_limit = false;
bool Mailer::queued_mail = false;
extern IUrlFactory *url_fak;

//Should be about 3 days
const size_t max_mail_retry_count = 8500;

bool Mailer::sendMail(const std::string & send_to, const std::string & subject, const std::string & message)
{
	IScopedLock lock(mutex);
	if (queue_limit)
		return false;

	lock.relock(NULL);

	IDatabase* db = Server->getDatabase(Server->getThreadID(), URBACKUPDB_SERVER);
	DBScopedSynchronous db_synchronous(db);
	IQuery* q = db->Prepare("INSERT INTO mail_queue (send_to, subject, message) VALUES (?,?,?)", false);
	q->Bind(send_to);
	q->Bind(subject);
	q->Bind(message);
	bool b = q->Write();
<commit_msg>Delete mail from queue after retrying for 3 days<commit_after>#include "Mailer.h"
#include "../Interface/Server.h"
#include "../Interface/Database.h"
#include "database.h"
#include "../urlplugin/IUrlFactory.h"
#include "ClientMain.h"
#include <math.h>

IMutex* Mailer::mutex = NULL;
ICondition* Mailer::cond = NULL;
bool Mailer::queue_limit = false;
bool Mailer::queued_mail = false;
extern IUrlFactory *url_fak;

//Should be about 3 days
const size_t max_mail_retry_count = 164;

bool Mailer::sendMail(const std::string & send_to, const std::string & subject, const std::string & message)
{
	IScopedLock lock(mutex);
	if (queue_limit)
		return false;

	lock.relock(NULL);

	IDatabase* db = Server->getDatabase(Server->getThreadID(), URBACKUPDB_SERVER);
	DBScopedSynchronous db_synchronous(db);
	IQuery* q = db->Prepare("INSERT INTO mail_queue (send_to, subject, message) VALUES (?,?,?)", false);
	q->Bind(send_to);
	q->Bind(subject);
	q->Bind(message);
	bool b = q->Write();

{'fraction_non_alphanumeric': 0.15641293013555788, 'fraction_numerical': 0.005213764337851929, 'mean_word_length': 5.829181494661921, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2456323', 'n_tokens_mistral': 700, 'n_tokens_neox': 682, 'n_words': 162}