(20241213) Mail Module Reworked!
This commit is contained in:
@@ -81,7 +81,7 @@ import asyncio
|
||||
|
||||
|
||||
# Related to Quart:
|
||||
mail_callback_bp = Blueprint("mail_cb", __name__)
|
||||
mail_oauth_callback_bp = Blueprint("mail_cb", __name__)
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
@@ -101,7 +101,7 @@ mail_callback_bp = Blueprint("mail_cb", __name__)
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
@mail_callback_bp.record_once
|
||||
@mail_oauth_callback_bp.record_once
|
||||
def init(blueprint_setup_state):
|
||||
|
||||
# This gets called when the blueprint is registered.
|
||||
@@ -239,7 +239,7 @@ async def handle_gmail_callback() -> render_template:
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@mail_callback_bp.route("/callback/<mail_client>", methods = ["POST", "GET"])
|
||||
@mail_oauth_callback_bp.route("/callback/<mail_client>", methods = ["POST", "GET"])
|
||||
@set_api_version(api_version = "1.0.0")
|
||||
@read_input(sanitize_headers = False, sanitize_data = False)
|
||||
@log_request_to_mongo(
|
||||
|
||||
@@ -85,7 +85,7 @@ import asyncio
|
||||
|
||||
|
||||
# Related to Quart:
|
||||
mail_oauth_bp = Blueprint("mail_oauth", __name__)
|
||||
mail_oauth_request_bp = Blueprint("mail_oauth", __name__)
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
@@ -105,7 +105,7 @@ mail_oauth_bp = Blueprint("mail_oauth", __name__)
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
@mail_oauth_bp.record_once
|
||||
@mail_oauth_request_bp.record_once
|
||||
def init(blueprint_setup_state):
|
||||
|
||||
# This gets called when the blueprint is registered.
|
||||
@@ -116,7 +116,7 @@ def init(blueprint_setup_state):
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@mail_oauth_bp.route("/oauth", methods = ["GET"])
|
||||
@mail_oauth_request_bp.route("/oauth", methods = ["GET"])
|
||||
@set_api_version(api_version = "1.0.0")
|
||||
@read_input(sanitize_headers = False, sanitize_data = False)
|
||||
@get_session_info(key = "X-Session-Token", session_coro = "get_session")
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
# To make sibling directories accessible for imports:
|
||||
import sys
|
||||
sys.path.append(".")
|
||||
sys.path.append("..")
|
||||
sys.path.append("../..")
|
||||
|
||||
# For using Quart:
|
||||
from quart import Blueprint, current_app, g, request
|
||||
@@ -136,13 +136,13 @@ def init(blueprint_setup_state):
|
||||
@log_chain_to_mongo(attr_name = "logs_mongo")
|
||||
@should_not_be_under_maintenance(attr_name = "is_under_maintenance")
|
||||
@validate_input(
|
||||
header_validator = lambda x: MailGetRequestHeaders(**x).model_dump(),
|
||||
data_validator = lambda x: MailGetRequestData(**x)
|
||||
header_validator = lambda x: MailUpdateTagsRequestHeaders(**x).model_dump(),
|
||||
data_validator = lambda x: MailUpdateTagsRequestData(**x)
|
||||
)
|
||||
@handle_cancelled_request()
|
||||
async def update_mail_tags(
|
||||
inbound_headers: dict | MailGetRequestHeaders = None,
|
||||
inbound_data: dict | MailGetRequestData = None,
|
||||
inbound_headers: dict | MailUpdateTagsRequestHeaders = None,
|
||||
inbound_data: dict | MailUpdateTagsRequestData = None,
|
||||
inbound_files: dict = None,
|
||||
**kwargs
|
||||
):
|
||||
@@ -164,17 +164,18 @@ async def update_mail_tags(
|
||||
)
|
||||
|
||||
# Get the mail:
|
||||
message = await current_app.mail_controller.get_one_mail(
|
||||
success = await current_app.mail_controller.update_tags(
|
||||
mongo_conn = current_app.data_mongo,
|
||||
token_id = inbound_data.tokenId,
|
||||
message_id = inbound_data.messageId
|
||||
message_id = inbound_data.messageId,
|
||||
unset_tags = inbound_data.unsetTags,
|
||||
set_tags = inbound_data.setTags
|
||||
)
|
||||
|
||||
# Done here:
|
||||
return ResponseModel(
|
||||
status_code = StatusCodes.OK if message else StatusCodes.FAILED,
|
||||
http_code = HttpCodes.SUCCESS if message else HttpCodes.NOT_FOUND,
|
||||
data = message.full
|
||||
status_code = StatusCodes.OK if success else StatusCodes.FAILED,
|
||||
http_code = HttpCodes.SUCCESS if success else HttpCodes.INTERNAL_SERVER_ERROR
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user