(20250115) Can accept WhatsApp (Nimbus) integrations now.
This commit is contained in:
+36
-4
@@ -95,6 +95,32 @@ class TelegramAuth(BaseModel):
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class WhatsAppNimbusAuth(BaseModel):
|
||||
|
||||
apiKey: str = Field(
|
||||
description = "???",
|
||||
min_length = 1,
|
||||
frozen = True
|
||||
)
|
||||
|
||||
senderId: str = Field(
|
||||
description = "???",
|
||||
min_length = 1,
|
||||
frozen = True
|
||||
)
|
||||
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
# ┗┛┗┛┛┗┛┗┗┫
|
||||
# ┛
|
||||
|
||||
class Config:
|
||||
extra = "forbid"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class ChatAuthRequestHeaders(BaseModel):
|
||||
|
||||
sessionToken: str = Field(
|
||||
@@ -121,8 +147,12 @@ class ChatAuthRequestHeaders(BaseModel):
|
||||
|
||||
class ChatAuthRequestData(BaseModel):
|
||||
|
||||
chatClient: Literal["telegram", "whatsapp"] = Field(alias = "client")
|
||||
auth: Union[TelegramAuth]
|
||||
chatClient: Literal[
|
||||
"telegram", # ........ Official Telegram API.
|
||||
"whatsapp", # ........ Official WhatsApp API.
|
||||
"whatsappNimbus" # ... Nimbus IT's unofficial WhatsApp API.
|
||||
] = Field(alias = "client")
|
||||
auth: Union[TelegramAuth, WhatsAppNimbusAuth]
|
||||
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
@@ -138,10 +168,12 @@ class ChatAuthRequestData(BaseModel):
|
||||
|
||||
@model_validator(mode = "after")
|
||||
def ensure_harmony(cls, values):
|
||||
client = values.client
|
||||
client = values.chatClient
|
||||
auth = values.auth
|
||||
harmony_map = {
|
||||
"telegram": TelegramAuth
|
||||
"telegram": TelegramAuth,
|
||||
# "whatsapp": None,
|
||||
"whatsappNimbus": WhatsAppNimbusAuth
|
||||
}
|
||||
if not isinstance(auth, harmony_map[client]):
|
||||
raise ValueError(f"incorrect 'auth' for selected client '{client}'")
|
||||
|
||||
Reference in New Issue
Block a user