(20241205) Some details added to Mail OAuth.
This commit is contained in:
@@ -182,7 +182,8 @@ async def request_oauth_authorization_url(
|
|||||||
user_info = kwargs["session_info"],
|
user_info = kwargs["session_info"],
|
||||||
email_id = inbound_data.mailId,
|
email_id = inbound_data.mailId,
|
||||||
service_client = inbound_data.mailClient,
|
service_client = inbound_data.mailClient,
|
||||||
auth_type = "oauth"
|
auth_type = "oauth",
|
||||||
|
sync_freq = inbound_data.syncFreq
|
||||||
)
|
)
|
||||||
if token_id is None:
|
if token_id is None:
|
||||||
return ResponseModel(
|
return ResponseModel(
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ class MailOAuthModel(BaseModel):
|
|||||||
email_id: str,
|
email_id: str,
|
||||||
service_client: Literal["gmail"],
|
service_client: Literal["gmail"],
|
||||||
auth_type: Literal["oauth"],
|
auth_type: Literal["oauth"],
|
||||||
|
sync_freq: Literal[60, 300, 900] = 300,
|
||||||
session_token: str = None
|
session_token: str = None
|
||||||
) -> ObjectId:
|
) -> 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 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
|
:param auth_type: To identify the type of authentication being done here. This could indicate simple password
|
||||||
authentication, more advance OAuth2.0 authentication, etc.
|
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.
|
:param session_token: The session token of the user who requested this service.
|
||||||
:return: An ObjectId to later store the granted tokens.
|
:return: An ObjectId to later store the granted tokens.
|
||||||
"""
|
"""
|
||||||
@@ -150,6 +152,8 @@ class MailOAuthModel(BaseModel):
|
|||||||
"firstRefreshTs": None,
|
"firstRefreshTs": None,
|
||||||
"lastRefreshTs": None,
|
"lastRefreshTs": None,
|
||||||
"firstRequestTs": request_ts,
|
"firstRequestTs": request_ts,
|
||||||
|
"status": "active",
|
||||||
|
"syncFreq": max(sync_freq, 60)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
projection = {
|
projection = {
|
||||||
@@ -224,19 +228,20 @@ class MailOAuthModel(BaseModel):
|
|||||||
update = {
|
update = {
|
||||||
"$set": {
|
"$set": {
|
||||||
"token": token,
|
"token": token,
|
||||||
|
"status": "active",
|
||||||
"lastRefreshTs": request_ts,
|
"lastRefreshTs": request_ts,
|
||||||
"firstRefreshTs": {
|
# "firstRefreshTs": {
|
||||||
"$cond": {
|
# "$cond": {
|
||||||
"if": {
|
# "if": {
|
||||||
"$or": [
|
# "$or": [
|
||||||
{"$eq": ["$firstRefreshTs", None]},
|
# {"$eq": ["$firstRefreshTs", None]},
|
||||||
{"$eq": [{"$type": "$firstRefreshTs"}, "missing"]}
|
# {"$eq": [{"$type": "$firstRefreshTs"}, "missing"]}
|
||||||
]
|
# ]
|
||||||
},
|
# },
|
||||||
"then": request_ts,
|
# "then": request_ts,
|
||||||
"else": "$firstRefreshTs"
|
# "else": "$firstRefreshTs"
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
projection = {"token": False},
|
projection = {"token": False},
|
||||||
|
|||||||
@@ -109,6 +109,12 @@ class OAuthMailAuthorizationRequestData(BaseModel):
|
|||||||
frozen = True
|
frozen = True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
syncFreq: Literal[60, 300, 900] = Field(
|
||||||
|
description = "the sync interval in seconds to fetch the mails from the client",
|
||||||
|
frozen = True,
|
||||||
|
default = 300
|
||||||
|
)
|
||||||
|
|
||||||
# ┏┓ ┏•
|
# ┏┓ ┏•
|
||||||
# ┃ ┏┓┏┓╋┓┏┓
|
# ┃ ┏┓┏┓╋┓┏┓
|
||||||
# ┗┛┗┛┛┗┛┗┗┫
|
# ┗┛┗┛┛┗┛┗┗┫
|
||||||
|
|||||||
Reference in New Issue
Block a user