From 214b4f3a85f3fb91883743b2ef6dd22e133bbe29 Mon Sep 17 00:00:00 2001 From: ParticleG Date: Tue, 6 Aug 2024 00:02:20 +0800 Subject: [PATCH] - Remove unused header - Update smtps::ssl_options --- plugins/EmailManager.cc | 52 ++++++++++++++++++++--------------------- types/Permission.h | 2 -- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/plugins/EmailManager.cc b/plugins/EmailManager.cc index 6a32aa4..c5d4e31 100644 --- a/plugins/EmailManager.cc +++ b/plugins/EmailManager.cc @@ -17,14 +17,14 @@ using namespace studio26f::plugins; using namespace studio26f::structures; using namespace studio26f::types; -void EmailManager::initAndStart(const Json::Value &config) { +void EmailManager::initAndStart(const Json::Value& config) { if (!( - config["server"].isString() && - config["port"].isUInt() && - config["account"].isString() && - config["password"].isString() && - config["senderEmail"].isString() && - config["senderName"].isString() + config["server"].isString() && + config["port"].isUInt() && + config["account"].isString() && + config["password"].isString() && + config["senderEmail"].isString() && + config["senderName"].isString() )) { LOG_ERROR << R"(Invalid config)"; abort(); @@ -44,9 +44,9 @@ void EmailManager::shutdown() { } void EmailManager::smtp( - const string &receiverEmail, - const string &subject, - const string &content + const string& receiverEmail, + const string& subject, + const string& content ) { try { message msg; @@ -58,32 +58,32 @@ void EmailManager::smtp( msg.content_type(message::media_type_t::TEXT, "html", "utf-8"); msg.content(content); smtps conn(_server, _port); + conn.ssl_options({{}, 0}); conn.authenticate(_account, _password, smtps::auth_method_t::START_TLS); conn.submit(msg); - } catch (smtp_error &e) { + } catch (smtp_error& e) { LOG_WARN << "SMTP Error: " << e.what(); throw ResponseException( - i18n("emailError"), - e, - ResultCode::EmailError, - k503ServiceUnavailable + i18n("emailError"), + e, + ResultCode::EmailError, + k503ServiceUnavailable ); - } catch (dialog_error &e) { + } catch (dialog_error& e) { LOG_WARN << "Dialog Error: " << e.what(); throw ResponseException( - i18n("emailError"), - e, - ResultCode::EmailError, - k503ServiceUnavailable + i18n("emailError"), + e, + ResultCode::EmailError, + k503ServiceUnavailable ); - } catch (message_error &e) { + } catch (message_error& e) { LOG_WARN << "Message Error: " << e.what(); throw ResponseException( - i18n("emailError"), - e, - ResultCode::EmailError, - k503ServiceUnavailable + i18n("emailError"), + e, + ResultCode::EmailError, + k503ServiceUnavailable ); } } - diff --git a/types/Permission.h b/types/Permission.h index 961a243..0100bea 100644 --- a/types/Permission.h +++ b/types/Permission.h @@ -4,8 +4,6 @@ #pragma once -#include - namespace studio26f::types { enum class Permission { Banned,