(20241213) Started accepting "auth" for software/theCaOfficeAi... I don't know how these details count as "auth", though.

This commit is contained in:
2024-12-13 17:01:32 +05:30
parent e8ddffbdfe
commit 4c258b110a
11 changed files with 604 additions and 18 deletions
+12 -6
View File
@@ -89,7 +89,7 @@ class CoreAuthTokenModel(BaseModel):
alias = "_id"
)
serviceType: Literal["email", "sms", "chat"] = Field(
serviceType: Literal["software", "email", "sms", "chat"] = Field(
description = "the kind of service this message was sent/received from",
frozen = True
)
@@ -98,7 +98,8 @@ class CoreAuthTokenModel(BaseModel):
"gmail", "outlook", # ...................... Mail Clients
"telegram", "whatsapp", # .................. Chat Clients
"nimbusSmsIndia", "savvyBulkSmsKenya", # ... SMS Clients
"razorpay", "safaricomMPesaExpress" # ...... Payment Gateways
"razorpay", "safaricomMPesaExpress", # ..... Payment Gateways
"theCaOfficeAi" # .......................... God knows, don't ask.
] = Field(
description = "the third-part client that was used",
frozen = True
@@ -133,16 +134,16 @@ class CoreAuthTokenModel(BaseModel):
default = None
)
auth: dict | None = Field(
auth: dict = Field(
description = "any direct auth details like api keys or passwords; will differ for each client",
frozen = False,
default = None
default = {}
)
token: dict | None = Field(
token: dict = Field(
description = "the actual auth tokens of that client; will differ for each client",
frozen = False,
default = None
default = {}
)
user: CoreUserInfoModel = Field(
@@ -191,6 +192,11 @@ class CoreAuthTokenModel(BaseModel):
def parse_date_time(cls, value):
return date_time.parse_date_time(input_value = value, timezone = date_time.TIMEZONE_UTC)
@field_validator("auth", "token", mode = "before")
def handle_null_creds(cls, value):
if value is None: value = {}
return value
# *****************************************************************************************************************
# ***** ****