(20241217) payment reference will now be the same as the payment id.
This commit is contained in:
@@ -286,7 +286,7 @@ class MailController:
|
||||
) -> CoreAuthTokenModel | None:
|
||||
|
||||
# Simply call the core model:
|
||||
return await current_app.core_auth_token_controller.get_token(
|
||||
return await current_app.core_auth_token_controller.get_token_from_key(
|
||||
mongo_conn = mongo_conn,
|
||||
token_key = token_key
|
||||
)
|
||||
@@ -298,7 +298,7 @@ class MailController:
|
||||
) -> List[CoreAuthTokenModel] | None:
|
||||
|
||||
# Simply call the core model:
|
||||
return await current_app.core_auth_token_controller.get_tokens(
|
||||
return await current_app.core_auth_token_controller.get_tokens_from_keys(
|
||||
mongo_conn = mongo_conn,
|
||||
token_keys = token_keys
|
||||
)
|
||||
@@ -611,14 +611,12 @@ class MailController:
|
||||
@staticmethod
|
||||
async def get_one_mail(
|
||||
mongo_conn: AsyncMongo,
|
||||
token_id: ObjectId | str,
|
||||
message_id: ObjectId | str
|
||||
) -> CoreMessageModel | None:
|
||||
|
||||
# Simply call the core model:
|
||||
return await current_app.core_message_controller.get_message(
|
||||
mongo_conn = mongo_conn,
|
||||
token_id = token_id,
|
||||
message_id = message_id
|
||||
)
|
||||
|
||||
|
||||
@@ -162,25 +162,25 @@ class PaymentController:
|
||||
return success
|
||||
|
||||
@staticmethod
|
||||
async def get_token(
|
||||
async def get_token_from_key(
|
||||
mongo_conn: AsyncMongo,
|
||||
token_key: ObjectId | str = None,
|
||||
) -> CoreAuthTokenModel | None:
|
||||
|
||||
# Simply call the core model:
|
||||
return await current_app.core_auth_token_controller.get_token(
|
||||
return await current_app.core_auth_token_controller.get_token_from_key(
|
||||
mongo_conn = mongo_conn,
|
||||
token_key = token_key
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
async def get_tokens(
|
||||
async def get_tokens_from_keys(
|
||||
mongo_conn: AsyncMongo,
|
||||
token_keys: ObjectId | str = None,
|
||||
) -> List[CoreAuthTokenModel] | None:
|
||||
|
||||
# Simply call the core model:
|
||||
return await current_app.core_auth_token_controller.get_tokens(
|
||||
return await current_app.core_auth_token_controller.get_tokens_from_keys(
|
||||
mongo_conn = mongo_conn,
|
||||
token_keys = token_keys
|
||||
)
|
||||
@@ -223,7 +223,7 @@ class PaymentController:
|
||||
substitute_text = ""
|
||||
) if isinstance(payment_request.customerNo, str) else payment_request.customerNo,
|
||||
type = "CustomerPayBillOnline",
|
||||
reference = payment_request.reference,
|
||||
reference = str(payment_id),
|
||||
description = payment_request.description,
|
||||
callback_url = callback_url,
|
||||
payer_no = regex.replace(
|
||||
|
||||
@@ -173,7 +173,7 @@ class SMSController:
|
||||
) -> CoreAuthTokenModel | None:
|
||||
|
||||
# Simply call the core model:
|
||||
return await current_app.core_auth_token_controller.get_token(
|
||||
return await current_app.core_auth_token_controller.get_token_from_key(
|
||||
mongo_conn = mongo_conn,
|
||||
token_key = token_key
|
||||
)
|
||||
|
||||
@@ -270,10 +270,33 @@ class CoreAuthTokenController(BaseModel):
|
||||
# Done here:
|
||||
return token_saved
|
||||
|
||||
async def get_token(
|
||||
async def get_token_from_id(
|
||||
self,
|
||||
mongo_conn: AsyncMongo,
|
||||
token_key: ObjectId | str = None,
|
||||
token_id: ObjectId | str = None,
|
||||
) -> CoreAuthTokenModel | None:
|
||||
|
||||
"""
|
||||
To retrieve stored tokens from the database. One token at a time.
|
||||
:param mongo_conn: The database connection (MongoDB) to use to perform the action.
|
||||
:param token_id: The identifier of the document that holds the token's details.
|
||||
:return: The retrieved record that has the token, and information about the service and client if found, else
|
||||
None when there is no matching record.
|
||||
"""
|
||||
|
||||
# If there is some filtering possible, we fetch the token:
|
||||
token = await mongo_conn.find_one(
|
||||
collection = self.AUTH_COLLECTION,
|
||||
filter = {"_id": ObjectId(token_id)}
|
||||
)
|
||||
|
||||
# Done here:
|
||||
return CoreAuthTokenModel(**token) if token else None
|
||||
|
||||
async def get_token_from_key(
|
||||
self,
|
||||
mongo_conn: AsyncMongo,
|
||||
token_key: ObjectId | str = None
|
||||
) -> CoreAuthTokenModel | None:
|
||||
|
||||
"""
|
||||
@@ -287,13 +310,36 @@ class CoreAuthTokenController(BaseModel):
|
||||
# If there is some filtering possible, we fetch the token:
|
||||
token = await mongo_conn.find_one(
|
||||
collection = self.AUTH_COLLECTION,
|
||||
filter = {"key": ObjectId(token_key)},
|
||||
filter = {"key": ObjectId(token_key)}
|
||||
)
|
||||
|
||||
# Done here:
|
||||
return CoreAuthTokenModel(**token) if token else None
|
||||
|
||||
async def get_tokens(
|
||||
async def get_tokens_from_ids(
|
||||
self,
|
||||
mongo_conn: AsyncMongo,
|
||||
token_ids: List[ObjectId | str] = None,
|
||||
) -> List[CoreAuthTokenModel]:
|
||||
|
||||
"""
|
||||
To retrieve stored tokens from the database. Multiple tokens at a time.
|
||||
:param mongo_conn: The database connection (MongoDB) to use to perform the action.
|
||||
:param token_ids: The identifier of the document that holds the token's details.
|
||||
:return: The retrieved record that has the token, and information about the service and client if found, else
|
||||
None when there is no matching record.
|
||||
"""
|
||||
|
||||
# If there is some filtering possible, we fetch the token:
|
||||
tokens = await mongo_conn.find_many(
|
||||
collection = self.AUTH_COLLECTION,
|
||||
filter = {"_id": {"$in": [ObjectId(k) for k in token_ids]}}
|
||||
)
|
||||
|
||||
# Done here:
|
||||
return [CoreAuthTokenModel(**token) for token in tokens]
|
||||
|
||||
async def get_tokens_from_keys(
|
||||
self,
|
||||
mongo_conn: AsyncMongo,
|
||||
token_keys: List[ObjectId | str] = None,
|
||||
|
||||
@@ -302,14 +302,12 @@ class CoreMessageController(BaseModel):
|
||||
async def get_message(
|
||||
self,
|
||||
mongo_conn: AsyncMongo,
|
||||
token_id: ObjectId | str,
|
||||
message_id: ObjectId | str,
|
||||
) -> CoreMessageModel | None:
|
||||
|
||||
"""
|
||||
Gets one message if you know its message id.
|
||||
:param mongo_conn: The instance of the database connector to use for the operation.
|
||||
:param token_id: The id of the auth-token associated with the message. Needed for security.
|
||||
:param message_id: The id of the message that needs to be read.
|
||||
:return: The contents of that one message in a structured format.
|
||||
"""
|
||||
@@ -317,10 +315,7 @@ class CoreMessageController(BaseModel):
|
||||
# We fetch the whole payload of that one message:
|
||||
record = await mongo_conn.find_one(
|
||||
collection = self.MESSAGES_COLLECTION,
|
||||
filter = {
|
||||
"_id": ObjectId(message_id),
|
||||
"tokenId": ObjectId(token_id)
|
||||
},
|
||||
filter = {"_id": ObjectId(message_id)},
|
||||
raise_exception = True
|
||||
)
|
||||
|
||||
@@ -342,7 +337,6 @@ class CoreMessageController(BaseModel):
|
||||
async def update_tags(
|
||||
self,
|
||||
mongo_conn: AsyncMongo,
|
||||
token_id: ObjectId | str,
|
||||
message_id: ObjectId | str,
|
||||
unset_tags: List[str] = None,
|
||||
set_tags: List[str] = None
|
||||
@@ -351,7 +345,6 @@ class CoreMessageController(BaseModel):
|
||||
"""
|
||||
Updates the tags on one message. The tags to remove are processed first, the ones to add are processed later.
|
||||
:param mongo_conn: The instance of the database connector to use for the operation.
|
||||
:param token_id: The id of the auth-token associated with the message. Needed for security.
|
||||
:param message_id: The id of the message that needs to be read.
|
||||
:param unset_tags: The tags to remove from the message.
|
||||
:param set_tags: The tags to add to the message.
|
||||
@@ -361,10 +354,7 @@ class CoreMessageController(BaseModel):
|
||||
# Update the tags:
|
||||
return await mongo_conn.update_one(
|
||||
collection = self.MESSAGES_COLLECTION,
|
||||
filter = {
|
||||
"_id": ObjectId(message_id),
|
||||
"tokenId": ObjectId(token_id)
|
||||
},
|
||||
filter = {"_id": ObjectId(message_id)},
|
||||
update = [{
|
||||
"$set": {
|
||||
"tags": {
|
||||
|
||||
Reference in New Issue
Block a user