(20241205) Migrating from the field "accountId" to "tokenId" to identify auth tokens.
This commit is contained in:
@@ -98,20 +98,20 @@ class MailRetrieveModel(BaseModel):
|
||||
async def get_mail(
|
||||
self,
|
||||
mongo_conn: AsyncMongo,
|
||||
mail_identifier: str | ObjectId
|
||||
mail_id: str | ObjectId
|
||||
):
|
||||
|
||||
"""
|
||||
Retrieves one full mail from the database.
|
||||
:param mongo_conn: The instance of the database connector to use to get the mail's data.
|
||||
:param mail_identifier: The '_id' of the document that holds the mail.
|
||||
:param mail_id: The '_id' of the document that holds the mail.
|
||||
:return: Either the JSON that describes the mail or None if such a mail does not exist.
|
||||
"""
|
||||
|
||||
# Get the data from the database:
|
||||
mail_data = await mongo_conn.find_one(
|
||||
collection = self.MAIL_COLLECTION,
|
||||
filter = {"_id": ObjectId(mail_identifier)},
|
||||
filter = {"_id": ObjectId(mail_id)},
|
||||
projection = {
|
||||
"_id": True,
|
||||
"serviceType": True,
|
||||
@@ -141,10 +141,10 @@ class MailRetrieveModel(BaseModel):
|
||||
# Done here:
|
||||
return mail_data
|
||||
|
||||
async def list_for_account_identifier(
|
||||
async def list_for_token_id(
|
||||
self,
|
||||
mongo_conn: AsyncMongo,
|
||||
account_identifier: str | ObjectId,
|
||||
token_id: str | ObjectId,
|
||||
limit: int = 25,
|
||||
skip: int = 0
|
||||
):
|
||||
@@ -152,7 +152,7 @@ class MailRetrieveModel(BaseModel):
|
||||
"""
|
||||
To enlist mails for one account.
|
||||
:param mongo_conn: The instance of the database connector to use to get the mail's data.
|
||||
:param account_identifier: The id of the document in the database that holds the tokens to access the account.
|
||||
:param token_id: The id of the document in the database that holds the tokens to access the account.
|
||||
:param limit: How many records to fetch.
|
||||
:param skip: How many initial records to skip. useful for pagination.
|
||||
:return: Either the JSON that describes the mails or None if something failed.
|
||||
@@ -161,7 +161,7 @@ class MailRetrieveModel(BaseModel):
|
||||
# Get the data from the database:
|
||||
mails_list = await mongo_conn.find_many(
|
||||
collection = self.MAIL_COLLECTION,
|
||||
filter = {"accountId": ObjectId(account_identifier)},
|
||||
filter = {"tokenId": ObjectId(token_id)},
|
||||
projection = {
|
||||
"_id": True,
|
||||
"serviceType": True,
|
||||
|
||||
Reference in New Issue
Block a user