Skip to content

Commit

Permalink
fix: run companies update only when mail is the option
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Nov 27, 2024
1 parent 5d593d2 commit 73a87bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions mftp/env.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
MONGO_URI = f'mongodb://{MONGO_ROOT_USERNAME}:{MONGO_ROOT_PASSWORD}@db:{MONGO_PORT}'
MONGO_COLLECTION = "AY_2024-25"

# EMAIL (via SMTP)
## Senders' Credentials
# EMAIL
## Senders' Credentials (via SMTP)
FROM_EMAIL = "abc@gmail.com" # Notification Sender Email-id
FROM_EMAIL_PASS = "**********" # App password for the above email-id
## EMAIL - Receiver's Address
Expand Down
13 changes: 7 additions & 6 deletions mftp/mftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
print('[ERP LOGIN]', flush=True)
_, ssoToken = erp.login(headers, session, ERPCREDS=env, OTP_CHECK_INTERVAL=2, LOGGING=True, SESSION_STORAGE_FILE='.session')

if now - last_companies_email_time >= timedelta(hours=1):
companies = company.fetch(session, headers, ssoToken)
open_not_applied_companies = company.filter(companies, "OPEN_N")
companies_update_mail = mail.format_companies(session.cookies.get('ssoToken'), open_not_applied_companies)
mail.send_companies(companies_update_mail, args.gmail_api, args.smtp)
last_companies_email_time = now
if args.gmail_api or args.smtp:
if now - last_companies_email_time >= timedelta(hours=1):
companies = company.fetch(session, headers, ssoToken)
open_not_applied_companies = company.filter(companies, "OPEN_N")
companies_update_mail = mail.format_companies(session.cookies.get('ssoToken'), open_not_applied_companies)
mail.send_companies(companies_update_mail, args.gmail_api, args.smtp)
last_companies_email_time = now

notice_db = db.NoticeDB(config={
'uri': env.MONGO_URI,
Expand Down

0 comments on commit 73a87bf

Please sign in to comment.