(20241204) Alerts bug resolved.
This commit is contained in:
@@ -160,9 +160,7 @@ class BaseModel:
|
|||||||
:return: None.
|
:return: None.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
print("Alert time!")
|
|
||||||
if self._http_client is not None and self._alert_url is not None:
|
if self._http_client is not None and self._alert_url is not None:
|
||||||
print("ALERTTT!!!")
|
|
||||||
response = await self._http_client.post(
|
response = await self._http_client.post(
|
||||||
url = self._alert_url,
|
url = self._alert_url,
|
||||||
headers = {"X-Session-Token": session_token} if session_token else None,
|
headers = {"X-Session-Token": session_token} if session_token else None,
|
||||||
@@ -171,8 +169,6 @@ class BaseModel:
|
|||||||
"type": alert_type
|
"type": alert_type
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
print(response)
|
|
||||||
print(response.json())
|
|
||||||
|
|
||||||
async def call_cached_procedure(
|
async def call_cached_procedure(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -312,230 +312,4 @@ class MailOAuthModel(BaseModel):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
import httpx
|
pass
|
||||||
import asyncio
|
|
||||||
|
|
||||||
http_client = httpx.AsyncClient(
|
|
||||||
limits = httpx.Limits(
|
|
||||||
max_connections = 100, # ............ Maximum number of connections allowed in the pool.
|
|
||||||
max_keepalive_connections = 50, # ... Maximum number of connections that can be kept alive.
|
|
||||||
),
|
|
||||||
timeout = httpx.Timeout(
|
|
||||||
pool = 120.0, # .... Time to wait for a free connection from the pool.
|
|
||||||
connect = 2.5, # ... Time to wait for establishing a connection to the server.
|
|
||||||
write = 10.0, # .... Time to wait for sending data.
|
|
||||||
read = 2.5 # ....... Time to wait for receiving data.
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
script_cred = {
|
|
||||||
"mariaDb": {
|
|
||||||
"read": {
|
|
||||||
"host": "wtt.ditscentre.in",
|
|
||||||
"user": "caOffice",
|
|
||||||
"password": "jstArchon",
|
|
||||||
"database": "caOffice",
|
|
||||||
"poolSize": 4
|
|
||||||
},
|
|
||||||
"write": {
|
|
||||||
"host": "wtt.ditscentre.in",
|
|
||||||
"user": "caOffice",
|
|
||||||
"password": "jstArchon",
|
|
||||||
"database": "caOffice",
|
|
||||||
"poolSize": 4
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mongoDb": {
|
|
||||||
"logs": {
|
|
||||||
"connectionString": "mongodb://del.ditscentre.in:27017,wtt.ditscentre.in:27017,mum.arh.001.ditscentre.in:27017/admin?tls=true&tlsCAFile=%2Fetc%2Fssl%2Fcerts%2Fmongo_data_ca.pem&tlsCertificateKeyFile=%2Fetc%2Fssl%2Fcerts%2Fmongo_data_cert.pem&replicaSet=dits_mongod_rep&readPreference=primary&authMechanism=MONGODB-X509&authSource=%24external",
|
|
||||||
"dbName": "converse",
|
|
||||||
"poolSize": 10
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"connectionString": "mongodb://del.ditscentre.in:27017,wtt.ditscentre.in:27017,mum.arh.001.ditscentre.in:27017/admin?tls=true&tlsCAFile=%2Fetc%2Fssl%2Fcerts%2Fmongo_data_ca.pem&tlsCertificateKeyFile=%2Fetc%2Fssl%2Fcerts%2Fmongo_data_cert.pem&replicaSet=dits_mongod_rep&readPreference=primary&authMechanism=MONGODB-X509&authSource=%24external",
|
|
||||||
"dbName": "converse",
|
|
||||||
"poolSize": 10
|
|
||||||
},
|
|
||||||
"files": {
|
|
||||||
"connectionString": "mongodb://del.ditscentre.in:27017,wtt.ditscentre.in:27017,mum.arh.001.ditscentre.in:27017/admin?tls=true&tlsCAFile=%2Fetc%2Fssl%2Fcerts%2Fmongo_data_ca.pem&tlsCertificateKeyFile=%2Fetc%2Fssl%2Fcerts%2Fmongo_data_cert.pem&replicaSet=dits_mongod_rep&readPreference=primary&authMechanism=MONGODB-X509&authSource=%24external",
|
|
||||||
"dbName": "converseStore",
|
|
||||||
"poolSize": 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data_mongo = AsyncMongo(
|
|
||||||
connection_string = script_cred["mongoDb"]["data"]["connectionString"],
|
|
||||||
database_name = script_cred["mongoDb"]["data"]["dbName"],
|
|
||||||
max_connections = script_cred["mongoDb"]["data"]["poolSize"],
|
|
||||||
debug = True
|
|
||||||
)
|
|
||||||
|
|
||||||
sql_writer = AsyncMySQL(
|
|
||||||
pool_size = script_cred["mariaDb"]["write"]["poolSize"],
|
|
||||||
host = script_cred["mariaDb"]["write"]["host"],
|
|
||||||
user = script_cred["mariaDb"]["write"]["user"],
|
|
||||||
password = script_cred["mariaDb"]["write"]["password"],
|
|
||||||
database = script_cred["mariaDb"]["write"]["database"]
|
|
||||||
)
|
|
||||||
|
|
||||||
mail_oauth_model = MailOAuthModel(
|
|
||||||
cache = None,
|
|
||||||
alert_url = r"https://api.thecaoffice.com/converse/tech/alert/chat/backend",
|
|
||||||
http_client = http_client,
|
|
||||||
debug = True,
|
|
||||||
debug_prefix = "Mail-OAuth | ",
|
|
||||||
debug_only_errors = True
|
|
||||||
)
|
|
||||||
|
|
||||||
token_json = {
|
|
||||||
"accessToken": "ya29.a0AeDClZB1Z-3fLvQe48cI7QNd5vVaovqtlDtg_pYsJSuCyk2iqU8HH3F6PEwY0a4RXJJ369lDxW7wnA9nhesu7mWqv_GydpITo51Jcyx9XMgxSKCTJ2gUmo4FiuTbY8ro2HnI5Uq9hFwbSgOs9Xj50hjs8Y__r6OwoxGebYjRaCgYKAVESARMSFQHGX2MiXZcXxJicW2igbzoDhm93AQ0175",
|
|
||||||
"refreshToken": "1//0gkcQLiO8JZtNCgYIARAAGBASNwF-L9Irz4-KNxIw0vK3Y3rhDo_pkEJPGVRWqzz549gREEH-n8UlNjGu4gIILsWM8HPBoAX16oA",
|
|
||||||
"expiresAt": {
|
|
||||||
"$date": "2024-12-04T12:24:47.282Z"
|
|
||||||
},
|
|
||||||
"scopes": [
|
|
||||||
"https://www.googleapis.com/auth/gmail.modify",
|
|
||||||
"https://www.googleapis.com/auth/userinfo.profile",
|
|
||||||
"https://www.googleapis.com/auth/gmail.labels"
|
|
||||||
],
|
|
||||||
"email": "yatmeshdemo@gmail.com",
|
|
||||||
"displayName": "yatmesh",
|
|
||||||
"displayPictureUrl": "https://lh3.googleusercontent.com/a/ACg8ocK0jD9HdAxkRWZg0qdFrQwceGeWEK4BEFs93vbi8O62cZaJkf0=s100",
|
|
||||||
"labels": {
|
|
||||||
"CHAT": {
|
|
||||||
"id": "CHAT",
|
|
||||||
"name": "CHAT",
|
|
||||||
"messageListVisibility": "hide",
|
|
||||||
"labelListVisibility": "labelHide",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"SENT": {
|
|
||||||
"id": "SENT",
|
|
||||||
"name": "SENT",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"INBOX": {
|
|
||||||
"id": "INBOX",
|
|
||||||
"name": "INBOX",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"IMPORTANT": {
|
|
||||||
"id": "IMPORTANT",
|
|
||||||
"name": "IMPORTANT",
|
|
||||||
"messageListVisibility": "hide",
|
|
||||||
"labelListVisibility": "labelHide",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"TRASH": {
|
|
||||||
"id": "TRASH",
|
|
||||||
"name": "TRASH",
|
|
||||||
"messageListVisibility": "hide",
|
|
||||||
"labelListVisibility": "labelHide",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"DRAFT": {
|
|
||||||
"id": "DRAFT",
|
|
||||||
"name": "DRAFT",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"SPAM": {
|
|
||||||
"id": "SPAM",
|
|
||||||
"name": "SPAM",
|
|
||||||
"messageListVisibility": "hide",
|
|
||||||
"labelListVisibility": "labelHide",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"CATEGORY_FORUMS": {
|
|
||||||
"id": "CATEGORY_FORUMS",
|
|
||||||
"name": "CATEGORY_FORUMS",
|
|
||||||
"messageListVisibility": "hide",
|
|
||||||
"labelListVisibility": "labelHide",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"CATEGORY_UPDATES": {
|
|
||||||
"id": "CATEGORY_UPDATES",
|
|
||||||
"name": "CATEGORY_UPDATES",
|
|
||||||
"messageListVisibility": "hide",
|
|
||||||
"labelListVisibility": "labelHide",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"CATEGORY_PERSONAL": {
|
|
||||||
"id": "CATEGORY_PERSONAL",
|
|
||||||
"name": "CATEGORY_PERSONAL",
|
|
||||||
"messageListVisibility": "hide",
|
|
||||||
"labelListVisibility": "labelHide",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"CATEGORY_PROMOTIONS": {
|
|
||||||
"id": "CATEGORY_PROMOTIONS",
|
|
||||||
"name": "CATEGORY_PROMOTIONS",
|
|
||||||
"messageListVisibility": "hide",
|
|
||||||
"labelListVisibility": "labelHide",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"CATEGORY_SOCIAL": {
|
|
||||||
"id": "CATEGORY_SOCIAL",
|
|
||||||
"name": "CATEGORY_SOCIAL",
|
|
||||||
"messageListVisibility": "hide",
|
|
||||||
"labelListVisibility": "labelHide",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"STARRED": {
|
|
||||||
"id": "STARRED",
|
|
||||||
"name": "STARRED",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"UNREAD": {
|
|
||||||
"id": "UNREAD",
|
|
||||||
"name": "UNREAD",
|
|
||||||
"type": "system"
|
|
||||||
},
|
|
||||||
"CA-Doc": {
|
|
||||||
"id": "Label_5",
|
|
||||||
"name": "CA-Doc",
|
|
||||||
"messageListVisibility": "show",
|
|
||||||
"labelListVisibility": "labelShow",
|
|
||||||
"type": "user",
|
|
||||||
"color": {
|
|
||||||
"textColor": "#434343",
|
|
||||||
"backgroundColor": "#e7e7e7"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CA-AI": {
|
|
||||||
"id": "Label_6",
|
|
||||||
"name": "CA-AI",
|
|
||||||
"messageListVisibility": "show",
|
|
||||||
"labelListVisibility": "labelShow",
|
|
||||||
"type": "user",
|
|
||||||
"color": {
|
|
||||||
"textColor": "#434343",
|
|
||||||
"backgroundColor": "#e7e7e7"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"TCAOFF": {
|
|
||||||
"id": "Label_7",
|
|
||||||
"name": "TCAOFF",
|
|
||||||
"messageListVisibility": "show",
|
|
||||||
"labelListVisibility": "labelShow",
|
|
||||||
"type": "user",
|
|
||||||
"color": {
|
|
||||||
"textColor": "#434343",
|
|
||||||
"backgroundColor": "#e7e7e7"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async def main():
|
|
||||||
|
|
||||||
await mail_oauth_model.set_token(
|
|
||||||
db_conn = sql_writer,
|
|
||||||
mongo_conn = data_mongo,
|
|
||||||
account_identifier = ObjectId("67503139a7804fcbc6c22e14"),
|
|
||||||
email_id = "yatmeshdemo@gmail.com",
|
|
||||||
token = token_json,
|
|
||||||
session_token = None
|
|
||||||
)
|
|
||||||
|
|
||||||
asyncio.run(main())
|
|
||||||
|
|||||||
Reference in New Issue
Block a user