def send_daily_digest_to_all_users(nowtime): digest_psync = True digest_token = token_store.get_token(digest_client_email, source) if(digest_token == ""): digest_token = token_store.get_token(digest_client_email, source_2) digest_psync = False digestclient = nylas_helper.get_nylas_client_(digest_token, digest_psync) user_list = token_store.get_email_prio_users() # user_list = ['*****@*****.**', '*****@*****.**'] # user_list = ['*****@*****.**'] # print user_list digest_times = token_store.get_daily_digest_time(user_list) timezones = token_store.get_timezones(user_list) for i in range(len(user_list)): try: user = user_list[i] digest_time = digest_times[i] timezone = timezones[i] tzobj = pytz.timezone(timezone) tztime = nowtime.astimezone(tzobj).time() dt = digest_time.hour*60+digest_time.minute tzt = tztime.hour*60+tztime.minute # print tztime, digest_time if dt-tzt < 30 and dt-tzt >= 0: #if the current time and time of daily digest are 30 minutes apart, then send the daily digest print "Preparing to send daily digest to",user send_daily_digest(user, digestclient) print 'Sent the digest to',user else: print "Not the time",user except Exception as e: print 'Daily digest crashed {' + str(e) + '}'
def manage_expired_threads(email_id, expired_thread_list): psync = True token = token_store.get_token(email_id, source_1) if token == "": token = token_store.get_token(email_id, source_2) psync = False nylas_client = nylas_helper.get_nylas_client_(token, psync) for thread in expired_thread_list: auto_ask = int(thread["auto_ask"]) first_msg = thread["first_msg"] thread_id = thread["id"] subject = thread["subject"] thread_object = nylas_client.threads.find(thread_id) # print thread_object if (is_thread_replied(email_id, thread_object, first_msg, nylas_client)): print "thread is replied" token_store.remove_thread_from_reminder_list(email_id, thread_id) else: print "thread is not replied" send_reminder(email_id, thread_object, subject, auto_ask, first_msg) token_store.remove_thread_from_reminder_list(email_id, thread_id) return
def manage_expired_threads(email_id, expired_thread_list): psync = True token = token_store.get_token(email_id, source_1) if token == "": token = token_store.get_token(email_id, source_2) psync = False nylas_client = nylas_helper.get_nylas_client_(token, psync) for thread in expired_thread_list: auto_ask = int(thread["auto_ask"]) first_msg = thread["first_msg"] thread_id = thread["id"] subject = thread["subject"] thread_object = nylas_client.threads.find(thread_id) # print thread_object if(is_thread_replied(email_id,thread_object,first_msg,nylas_client)): print "thread is replied" token_store.remove_thread_from_reminder_list(email_id,thread_id) else: print "thread is not replied" send_reminder(email_id,thread_object,subject,auto_ask,first_msg) token_store.remove_thread_from_reminder_list(email_id, thread_id) return
def send_daily_digest_to_all_users(nowtime): digest_psync = True digest_token = token_store.get_token(digest_client_email, source) if (digest_token == ""): digest_token = token_store.get_token(digest_client_email, source_2) digest_psync = False digestclient = nylas_helper.get_nylas_client_(digest_token, digest_psync) user_list = token_store.get_email_prio_users() # user_list = ['*****@*****.**', '*****@*****.**'] # user_list = ['*****@*****.**'] # print user_list digest_times = token_store.get_daily_digest_time(user_list) timezones = token_store.get_timezones(user_list) for i in range(len(user_list)): try: user = user_list[i] digest_time = digest_times[i] timezone = timezones[i] tzobj = pytz.timezone(timezone) tztime = nowtime.astimezone(tzobj).time() dt = digest_time.hour * 60 + digest_time.minute tzt = tztime.hour * 60 + tztime.minute # print tztime, digest_time if dt - tzt < 30 and dt - tzt >= 0: #if the current time and time of daily digest are 30 minutes apart, then send the daily digest print "Preparing to send daily digest to", user send_daily_digest(user, digestclient) print 'Sent the digest to', user else: print "Not the time", user except Exception as e: print 'Daily digest crashed {' + str(e) + '}'
def manage_expired_threads(email_id,expired_thread_list): psync = True token = token_store.get_token(email_id, source_1) if token == "": token = token_store.get_token(email_id, source_2) psync = False nylas_client = nylas_helper.get_nylas_client_(token, psync) for thread_id in expired_thread_list: thread_object = nylas_client.threads.find(thread_id) send_snooze_reminder(email_id, thread_object) token_store.remove_thread_from_followup(email_id,thread_id,token) return
def testing_digest(nowtime): digest_psync = True digest_token = token_store.get_token(digest_client_email, source) if(digest_token == ""): digest_token = token_store.get_token(digest_client_email, source_2) digest_psync = False digestclient = nylas_helper.get_nylas_client_(digest_token, digest_psync) # user_list = token_store.get_email_prio_users() user_list = ['*****@*****.**'] for i in range(len(user_list)): try: user = user_list[i] print "Preparing to send daily digest to",user send_daily_digest(user, digestclient) print 'Sent the digest to',user except Exception as e: print 'Daily digest crashed {' + str(e) + '}'
def testing_digest(nowtime): digest_psync = True digest_token = token_store.get_token(digest_client_email, source) if (digest_token == ""): digest_token = token_store.get_token(digest_client_email, source_2) digest_psync = False digestclient = nylas_helper.get_nylas_client_(digest_token, digest_psync) # user_list = token_store.get_email_prio_users() user_list = ['*****@*****.**'] for i in range(len(user_list)): try: user = user_list[i] print "Preparing to send daily digest to", user send_daily_digest(user, digestclient) print 'Sent the digest to', user except Exception as e: print 'Daily digest crashed {' + str(e) + '}'