(20241217) payment reference will now be the same as the payment id.

This commit is contained in:
2024-12-17 15:57:13 +05:30
parent d24d9cc248
commit 2e0c0224d4
15 changed files with 93 additions and 69 deletions
@@ -166,7 +166,7 @@ async def payment_list(
# ┗┛┛┗┗┗┛┗ ┛ ┗┗┻┗┗┛
# Get the token ids from the token keys:
auth_tokens = await current_app.payment_controller.get_tokens(
auth_tokens = await current_app.payment_controller.get_tokens_from_keys(
mongo_conn = current_app.data_mongo,
token_keys = inbound_data.tokenKeys
)
@@ -167,7 +167,7 @@ async def request_payment(
# ┗ ┛
# Get the token from the token key:
auth_token = await current_app.payment_controller.get_token(
auth_token = await current_app.payment_controller.get_token_from_key(
mongo_conn = current_app.data_mongo,
token_key = inbound_data.tokenKey
)
+1 -1
View File
@@ -159,7 +159,7 @@ async def handle_gmail_callback() -> render_template:
# Here's where we do the checking of the e-mails,
# if they don't match, we reject the authorization:
auth_token = await current_app.mail_controller.get_token(
auth_token = await current_app.mail_controller.get_token_from_key(
mongo_conn = current_app.data_mongo,
token_key = g.inbound_data["state"]
)
+26 -20
View File
@@ -70,6 +70,7 @@ from shared import constants
# Data Models:
from models.api.mail.get import MailGetRequestHeaders, MailGetRequestData
from models.core.user import CoreUserInfoModel
# To work with datatypes:
from typing import Literal
@@ -80,6 +81,9 @@ import asyncio
# To work with date and time:
import datetime
# Helpers:
from api.helpers.user import token_check
# *****************************************************************************************************************
# ***** ****
@@ -165,25 +169,7 @@ async def get_one_mail(
return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.UNAUTHORIZED,
messge = "invalid session"
)
# ┏┓ ┓ ┏┳┓ ┓
# ┣ ┏┓╋┏┣┓ ┃ ┏┓┃┏┏┓┏┓┏
# ┻ ┗ ┗┗┛┗ ┻ ┗┛┛┗┗ ┛┗┛
# We first load the authorization tokens:
auth_token = await current_app.mail_controller.get_token(
mongo_conn = current_app.data_mongo,
token_key = inbound_data.tokenKey,
)
# If we failed to load the authorization tokens:
if not auth_token:
return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.UNAUTHORIZED,
message = f"no such token key '{inbound_data.tokenKey}'"
message = "Invalid session."
)
# ┏┓ ┓ ┳┳┓ •┓
@@ -193,10 +179,30 @@ async def get_one_mail(
# Get the mail:
message = await current_app.mail_controller.get_one_mail(
mongo_conn = current_app.data_mongo,
token_id = auth_token.authTokenId,
message_id = inbound_data.messageId
)
# ┏┓ ┓ • ┏┓┓ ┓
# ┃┃┓┏┏┏┓┏┓┏┓┏┣┓┓┏┓ ┃ ┣┓┏┓┏┃┏
# ┗┛┗┻┛┛┗┗ ┛ ┛┛┗┗┣┛ ┗┛┛┗┗ ┗┛┗
# ┛
# We check if the token that was used to fetch the mail is owned by this user:
if not await token_check.is_authorized(
mongo_conn = current_app.data_mongo,
user_info = CoreUserInfoModel(**kwargs["session_info"]),
token_ids = [message.tokenId]
): return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.UNAUTHORIZED,
message = "The message does not belong to this user."
)
# ┳┓
# ┣┫┏┓┏┏┓┏┓┏┓┏┏┓
# ┛┗┗ ┛┣┛┗┛┛┗┛┗
# ┛
# Done here:
return ResponseModel(
status_code = StatusCodes.OK if message else StatusCodes.FAILED,
+1 -1
View File
@@ -180,7 +180,7 @@ async def list_mails(
# ┗┛┛┗┗┗┛┗ ┛ ┗┗┻┗┗┛
# Get the token ids from the token keys:
auth_tokens = await current_app.mail_controller.get_tokens(
auth_tokens = await current_app.mail_controller.get_tokens_from_keys(
mongo_conn = current_app.data_mongo,
token_keys = inbound_data.tokenKeys
)
-6
View File
@@ -172,12 +172,6 @@ async def update_mail_tags(
# ┗┛┣┛┗┻┗┻┗┗ ┛ ┗┗┻┗┗
# ┛
# get the token id from the token key:
auth_token = await current_app.mail_controller.get_token(
mongo_conn = current_app.data_mongo,
token_key = inbound_data.tokenKey
)
# Update the mail:
success = await current_app.mail_controller.update_tags(
mongo_conn = current_app.data_mongo,
+1 -1
View File
@@ -162,7 +162,7 @@ async def send_sms(
# ┗┛┗ ┛┗┗┻ ┻ ┛┗┗ ┗┛┛ ┗┗┛
# Get the token from the token key:
auth_token = await current_app.mail_controller.get_token(
auth_token = await current_app.mail_controller.get_token_from_key(
mongo_conn = current_app.data_mongo,
token_key = inbound_data.tokenKey
)
+1 -1
View File
@@ -112,7 +112,7 @@ async def is_authorized(
# Fetch the auth tokens from the database:
# Retrieve the document of the token id:
auth_tokens = await current_app.core_auth_token_controller.get_tokens(
auth_tokens = await current_app.core_auth_token_controller.get_tokens_from_ids(
mongo_conn = mongo_conn,
token_ids = [ObjectId(t) for t in token_ids]
)