From 8c53cd751261a9c46177fd509aa49d591dd4bcf2 Mon Sep 17 00:00:00 2001 From: Khushal P Soonderji Date: Tue, 30 Sep 2025 14:14:17 +0530 Subject: [PATCH] Squashed 'utils_v2/' changes from f03179d..2b9fdb1 2b9fdb1 (20250620) Minor upgrade to the SMS sending util. 6eb94a1 Merge commit '3dcc80e729011d6ee58e3af70b677f3fd9659c7a' as 'utils_v2' dbcc5b8 Resetting utils subtree. d1c0ce2 (20250614) Ready for deployment with the UI. 584dbfc (20250613) Cert expiry checker now takes io.BytesIO buffers also 8eb8cc0 Merge commit 'f6e7755b2f536bd6a6ba719dd190b69fffb2c3ad' as 'utils_v2' b3748f1 Resetting utils subtree. 00b5aa0 Merge commit 'b53ef86ef83302f2663e591baf8e52b9de3caa58' as 'utils_v2' b53ef86 Squashed 'utils_v2/' content from commit 7f27356 65cceb1 Resetting utils subtree. 9e8a4d6 Merge commit '26158fbca60a548a81a19ebf046842c297b7366b' as 'utils_v2' 26158fb Squashed 'utils_v2/' content from commit 7f27356 6f510c3 Resetting utils subtree. 94a2544 (20250528) Trying not to wait for API-level logging. 5051f73 (20241226) Started working on the server management system. 7607a42 (20241225) Small changes in Async Mongo. 1fd2879 (20241225) Work started on upgrades and server-registration module. 053e2c4 (20241225) Small fix in reconnection attempts for MySQL. d096785 Merge commit 'cf354c722a56c2db220df96adaf6ad45fd343f40' as 'utils_v2' cf354c7 Squashed 'utils_v2/' content from commit 3be5145 b96958f (20241119) Requirements added. 1ffd451 Merge commit 'f32ee8c9af77d79b71756298898bf95d9a43f99f' as 'utils_v2' f32ee8c Squashed 'utils_v2/' content from commit 13ad158 f358a99 Resetting utils subtree. 5c00496 (20241119) Trying it on WTT. 3583c17 (20241010) 50% ready to use. 52b02e0 Merge commit '9ee1467d11386139626e32681ea4c948584321b1' as 'utils_v2' 9ee1467 Squashed 'utils_v2/' content from commit ef9630d 4bb085c (20240930) Adding pages... 15583af (20240930) Let's begin! git-subtree-dir: utils_v2 git-subtree-split: 2b9fdb1c991ddfe1bd239b3a46f118ec39886897 --- sms/india/nimbus/controllers/async_nimbus.py | 1 + sms/models/sms_message.py | 5 +++++ web/certs/expiry.py | 14 +++++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sms/india/nimbus/controllers/async_nimbus.py b/sms/india/nimbus/controllers/async_nimbus.py index 0830cbf..d758ebf 100644 --- a/sms/india/nimbus/controllers/async_nimbus.py +++ b/sms/india/nimbus/controllers/async_nimbus.py @@ -199,6 +199,7 @@ class AsyncNimbusSMS: # Construct the basic structure of the response of this method: summary = SentSMSMessageModel( + client = "nimbusSmsIndia", sender = {"senderId": self.__sender_id}, recipient = {"recipientNo": recipient_number}, text = message, diff --git a/sms/models/sms_message.py b/sms/models/sms_message.py index 44c5a18..972f9c2 100644 --- a/sms/models/sms_message.py +++ b/sms/models/sms_message.py @@ -79,6 +79,11 @@ import datetime class SentSMSMessageModel(BaseModel): + client: str = Field( + description = "The name of the client (service) that was used.", + frozen = True + ) + ts: AwareDatetime = Field( description = "the time (utc) at which this message was sent by the sender", frozen = True, diff --git a/web/certs/expiry.py b/web/certs/expiry.py index 1b82ded..6086f01 100644 --- a/web/certs/expiry.py +++ b/web/certs/expiry.py @@ -35,6 +35,9 @@ import sys sys.path.append(".") sys.path.append("..") +# System-level activities: +import io + # To check certs through cryptographic algorithms: from cryptography import x509 from cryptography.hazmat.backends import default_backend @@ -204,7 +207,7 @@ class CertExpiryCheck: # ┃ ┏┓┏┏┓┃ ┃ ┏┓┏┓╋┏ # ┗┛┗┛┗┗┻┗ ┗┛┗ ┛ ┗┛ - def load_local(self, path: str) -> bool: + def load_local(self, path: str | io.BytesIO) -> bool: """ Loads a certificate stored on a local file path and checks for its validity. @@ -221,8 +224,13 @@ class CertExpiryCheck: try: # Read the contents of the certificate file: - with open(path, 'rb') as f: - cert_data = f.read() + if isinstance(path, str): + with open(path, 'rb') as f: + cert_data = f.read() + elif isinstance(path, io.BytesIO): + path.seek(0) + cert_data = path.read() + else: cert_data = None # Load the certificate: cert = x509.load_pem_x509_certificate(cert_data, default_backend())