8c53cd7512
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
163 lines
5.5 KiB
Python
163 lines
5.5 KiB
Python
"""
|
|
|
|
AUTHOR:
|
|
|
|
Khushal P Soonderji
|
|
|
|
DATE:
|
|
|
|
Monday, 9th Dec., 2024.
|
|
|
|
OBJECTIVE:
|
|
|
|
To define how messages will be stored in the database.
|
|
|
|
REFERENCES:
|
|
|
|
N/A
|
|
|
|
DOWNLOADS:
|
|
|
|
N/A
|
|
|
|
"""
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** IMPORT ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# To make sibling directories accessible for imports:
|
|
import sys
|
|
sys.path.append(".")
|
|
sys.path.append("..")
|
|
|
|
# For making data behaviour_models:
|
|
from pydantic import BaseModel, Field, field_validator, PastDatetime, AwareDatetime
|
|
from typing import Optional, Literal, Union, Any
|
|
|
|
# My utils:
|
|
from utils_v2.string import regex
|
|
from utils_v2.date_time import date_time
|
|
|
|
# To work with MongoDB:
|
|
from bson.objectid import ObjectId
|
|
|
|
# To work with date and time:
|
|
import datetime
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** MACROS / ONE-TIME INIT ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** VARIABLES ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** FUNCTIONS ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
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,
|
|
default_factory = lambda: date_time.get_current_utc_date_time(as_string = False)
|
|
)
|
|
|
|
sender: dict = Field(
|
|
description = "the sender of this message",
|
|
frozen = True
|
|
)
|
|
|
|
recipient: dict = Field(
|
|
description = "the recipient of this message",
|
|
frozen = True
|
|
)
|
|
|
|
text: str = Field(
|
|
description = "the actual text that was sent",
|
|
frozen = True
|
|
)
|
|
|
|
length: int = Field(
|
|
description = "the no. of chars in this message",
|
|
frozen = True
|
|
)
|
|
|
|
isFlash: bool = Field(
|
|
description = "to know whether this message is a flash message or a regular message",
|
|
frozen = True
|
|
)
|
|
|
|
success: bool = Field(
|
|
description = "to know whether this message was sent successfully or not",
|
|
default = False
|
|
)
|
|
|
|
message: str | None = Field(
|
|
description = "a brief message about what happened; useful when something goes wrong",
|
|
default = None
|
|
)
|
|
|
|
metadata: dict | None = Field(
|
|
description = "any extra data about this message",
|
|
frozen = True
|
|
)
|
|
|
|
rawResponse: Any | None = Field(
|
|
description = "the raw response from the third-party client",
|
|
default = None
|
|
)
|
|
|
|
messageId: int | str | None = Field(
|
|
description = "how the client recognizes this message",
|
|
frozen = False,
|
|
default = None
|
|
)
|
|
|
|
# ┏┓ ┏•
|
|
# ┃ ┏┓┏┓╋┓┏┓
|
|
# ┗┛┗┛┛┗┛┗┗┫
|
|
# ┛
|
|
|
|
class Config:
|
|
extra = "allow"
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** MAIN PROGRAM ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
pass
|