(20241205) Some details added to Mail OAuth.
This commit is contained in:
@@ -103,6 +103,7 @@ class MailOAuthModel(BaseModel):
|
||||
email_id: str,
|
||||
service_client: Literal["gmail"],
|
||||
auth_type: Literal["oauth"],
|
||||
sync_freq: Literal[60, 300, 900] = 300,
|
||||
session_token: str = None
|
||||
) -> ObjectId:
|
||||
|
||||
@@ -116,6 +117,7 @@ class MailOAuthModel(BaseModel):
|
||||
:param service_client: The name of the company or brand that is providing this service that is being integrated.
|
||||
:param auth_type: To identify the type of authentication being done here. This could indicate simple password
|
||||
authentication, more advance OAuth2.0 authentication, etc.
|
||||
:param sync_freq: The time interval in which mails need to be sync'd. Specify this in seconds.
|
||||
:param session_token: The session token of the user who requested this service.
|
||||
:return: An ObjectId to later store the granted tokens.
|
||||
"""
|
||||
@@ -150,6 +152,8 @@ class MailOAuthModel(BaseModel):
|
||||
"firstRefreshTs": None,
|
||||
"lastRefreshTs": None,
|
||||
"firstRequestTs": request_ts,
|
||||
"status": "active",
|
||||
"syncFreq": max(sync_freq, 60)
|
||||
}
|
||||
},
|
||||
projection = {
|
||||
@@ -224,19 +228,20 @@ class MailOAuthModel(BaseModel):
|
||||
update = {
|
||||
"$set": {
|
||||
"token": token,
|
||||
"status": "active",
|
||||
"lastRefreshTs": request_ts,
|
||||
"firstRefreshTs": {
|
||||
"$cond": {
|
||||
"if": {
|
||||
"$or": [
|
||||
{"$eq": ["$firstRefreshTs", None]},
|
||||
{"$eq": [{"$type": "$firstRefreshTs"}, "missing"]}
|
||||
]
|
||||
},
|
||||
"then": request_ts,
|
||||
"else": "$firstRefreshTs"
|
||||
}
|
||||
}
|
||||
# "firstRefreshTs": {
|
||||
# "$cond": {
|
||||
# "if": {
|
||||
# "$or": [
|
||||
# {"$eq": ["$firstRefreshTs", None]},
|
||||
# {"$eq": [{"$type": "$firstRefreshTs"}, "missing"]}
|
||||
# ]
|
||||
# },
|
||||
# "then": request_ts,
|
||||
# "else": "$firstRefreshTs"
|
||||
# }
|
||||
# }
|
||||
}
|
||||
},
|
||||
projection = {"token": False},
|
||||
|
||||
Reference in New Issue
Block a user