chore: minor cleanup - removed unnecessary branches and comments
This commit is contained in:
parent
c2ceceea6e
commit
88d4d5e10d
3 changed files with 5 additions and 11 deletions
|
|
@ -667,12 +667,9 @@ class EmailAccount(Document):
|
|||
self.log_error("Unable to add to Sent folder")
|
||||
|
||||
def get_oauth_token(self):
|
||||
token = None
|
||||
if self.auth_method == "OAuth":
|
||||
connected_app = frappe.get_doc("Connected App", self.connected_app)
|
||||
token = connected_app.get_active_token(self.connected_user)
|
||||
|
||||
return token
|
||||
return connected_app.get_active_token(self.connected_user)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
|
@ -769,14 +766,12 @@ def notify_unreplied():
|
|||
|
||||
def pull(now=False):
|
||||
"""Will be called via scheduler, pull emails from all enabled Email accounts."""
|
||||
from frappe.integrations.doctype.connected_app.connected_app import has_token
|
||||
|
||||
if frappe.cache().get_value("workers:no-internet") == True:
|
||||
if test_internet():
|
||||
frappe.cache().set_value("workers:no-internet", False)
|
||||
else:
|
||||
return
|
||||
|
||||
from frappe.integrations.doctype.connected_app.connected_app import has_token
|
||||
return
|
||||
|
||||
doctype = frappe.qb.DocType("Email Account")
|
||||
email_accounts = (
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class Oauth:
|
|||
return f"user={self.email}\1auth=Bearer {self._access_token}\1\1"
|
||||
|
||||
def connect(self) -> None:
|
||||
"""Connection method with retry on exception for connection errors"""
|
||||
try:
|
||||
if isinstance(self._conn, POP3):
|
||||
self._connect_pop()
|
||||
|
|
@ -59,7 +58,7 @@ class Oauth:
|
|||
raise
|
||||
|
||||
def _connect_pop(self) -> None:
|
||||
# poplib doesn't have AUTH command implementation
|
||||
# NOTE: poplib doesn't have AUTH command implementation
|
||||
res = self._conn._shortcmd(
|
||||
"AUTH {} {}".format(
|
||||
self._mechanism, base64.b64encode(bytes(self._auth_string, "utf-8")).decode("utf-8")
|
||||
|
|
|
|||
|
|
@ -167,4 +167,4 @@ def callback(code=None, state=None):
|
|||
def has_token(connected_app, connected_user=None):
|
||||
app = frappe.get_doc("Connected App", connected_app)
|
||||
token_cache = app.get_token_cache(connected_user or frappe.session.user)
|
||||
return bool(token_cache.get_json()["access_token"])
|
||||
return bool(token_cache.get_password("access_token", False))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue