(20241217) payment reference will now be the same as the payment id.
This commit is contained in:
@@ -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