(20241218) Can now add tags to SMS messages while sending them, and small 'limit' bug fixed in listing mails where a huge no. of tokens are being sent.
This commit is contained in:
@@ -594,7 +594,7 @@ class MailController:
|
||||
additional_filter: dict = None
|
||||
) -> List[CoreMessageModel] | None:
|
||||
|
||||
# regardless of what additional filter is provided from outside,
|
||||
# Regardless of what additional filter is provided from outside,
|
||||
# we add a mail-selecting filter here:
|
||||
if additional_filter is None: additional_filter = {}
|
||||
additional_filter["serviceType"] = "email"
|
||||
|
||||
+10
-5
@@ -187,6 +187,7 @@ class SMSController:
|
||||
http_client: httpx.AsyncClient,
|
||||
auth_token: CoreAuthTokenModel,
|
||||
messages: List[NimbusSMSIndiaMessage],
|
||||
tags: List[Any]
|
||||
) -> SMSSendManyResults:
|
||||
|
||||
# Start with a blank variable:
|
||||
@@ -232,7 +233,7 @@ class SMSController:
|
||||
message = client_response.model_dump(),
|
||||
snippet = message.text,
|
||||
aiSnippet = None,
|
||||
tags = ["sms", "nimbusSmsIndia"]
|
||||
tags = list(set(tags + ["SMS", "Nimbus SMS", "India"]))
|
||||
))
|
||||
|
||||
# Done here:
|
||||
@@ -243,6 +244,7 @@ class SMSController:
|
||||
http_client: httpx.AsyncClient,
|
||||
auth_token: CoreAuthTokenModel,
|
||||
messages: List[SavvyBulkSMSKenyaMessage],
|
||||
tags: List[Any]
|
||||
) -> SMSSendManyResults:
|
||||
|
||||
# Start with a blank variable:
|
||||
@@ -286,7 +288,7 @@ class SMSController:
|
||||
message = client_response.model_dump(),
|
||||
snippet = message.text,
|
||||
aiSnippet = None,
|
||||
tags = ["sms", "savvyBulkSmsKenya"]
|
||||
tags = list(set(tags + ["SMS", "Savvy Bulk SMS", "Kenya"]))
|
||||
))
|
||||
|
||||
# Done here:
|
||||
@@ -297,7 +299,8 @@ class SMSController:
|
||||
mongo_conn: AsyncMongo,
|
||||
http_client: httpx.AsyncClient,
|
||||
auth_token: CoreAuthTokenModel,
|
||||
messages: List[NimbusSMSIndiaMessage | SavvyBulkSMSKenyaMessage]
|
||||
messages: List[NimbusSMSIndiaMessage | SavvyBulkSMSKenyaMessage],
|
||||
tags: List[Any]
|
||||
) -> SMSSendManyResults:
|
||||
|
||||
# Start by assuming failure:
|
||||
@@ -309,13 +312,15 @@ class SMSController:
|
||||
send_results = await self.__send_from_nimbus_sms_india(
|
||||
http_client = http_client,
|
||||
auth_token = auth_token,
|
||||
messages = messages
|
||||
messages = messages,
|
||||
tags = tags
|
||||
)
|
||||
case "savvyBulkSmsKenya":
|
||||
send_results = await self.__send_from_savvy_bulk_sms_kenya(
|
||||
http_client = http_client,
|
||||
auth_token = auth_token,
|
||||
messages = messages
|
||||
messages = messages,
|
||||
tags = tags
|
||||
)
|
||||
case _:
|
||||
send_results.message = f"invalid client {auth_token.client}"
|
||||
|
||||
@@ -320,12 +320,14 @@ class CoreAuthTokenController(BaseModel):
|
||||
self,
|
||||
mongo_conn: AsyncMongo,
|
||||
token_ids: List[ObjectId | str] = None,
|
||||
limit: int = 100
|
||||
) -> 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.
|
||||
:param limit: The max. no. of records to pick.
|
||||
: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.
|
||||
"""
|
||||
@@ -333,7 +335,8 @@ class CoreAuthTokenController(BaseModel):
|
||||
# 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]}}
|
||||
filter = {"_id": {"$in": [ObjectId(k) for k in token_ids]}},
|
||||
limit = limit
|
||||
)
|
||||
|
||||
# Done here:
|
||||
@@ -343,12 +346,14 @@ class CoreAuthTokenController(BaseModel):
|
||||
self,
|
||||
mongo_conn: AsyncMongo,
|
||||
token_keys: List[ObjectId | str] = None,
|
||||
limit: int = 100
|
||||
) -> 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_keys: the identifiers granted by the 'get_token_key' method.
|
||||
:param limit: The max. no. of records to pick.
|
||||
: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.
|
||||
"""
|
||||
@@ -356,7 +361,8 @@ class CoreAuthTokenController(BaseModel):
|
||||
# If there is some filtering possible, we fetch the token:
|
||||
tokens = await mongo_conn.find_many(
|
||||
collection = self.AUTH_COLLECTION,
|
||||
filter = {"key": {"$in": [ObjectId(k) for k in token_keys]}}
|
||||
filter = {"key": {"$in": [ObjectId(k) for k in token_keys]}},
|
||||
limit = limit
|
||||
)
|
||||
|
||||
# Done here:
|
||||
|
||||
Reference in New Issue
Block a user