def tip_email(tip, to_emails, is_new): round_decimals = 5 if not tip or not tip.txid or not tip.amount or not tip.tokenName: return warning = '' if tip.network == 'mainnet' else "({})".format(tip.network) subject = gettext("⚡️ New Tip Worth {} {} {}").format( round(tip.amount, round_decimals), warning, tip.tokenName) if not is_new: subject = gettext("🕐 Tip Worth {} {} {} Expiring Soon").format( round(tip.amount, round_decimals), warning, tip.tokenName) for to_email in to_emails: cur_language = translation.get_language() try: setup_lang(to_email) from_email = settings.CONTACT_EMAIL html, text = render_tip_email(to_email, tip, is_new) if not should_suppress_notification_email(to_email, 'tip'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def tip_email(tip, to_emails, is_new): round_decimals = 5 if not tip or not tip.url or not tip.amount or not tip.tokenName: return warning = '' if tip.network == 'mainnet' else "({})".format(tip.network) subject = "⚡️ New Tip Worth {} {} {}".format(round(tip.amount, round_decimals), warning, tip.tokenName) if not is_new: subject = "🕐 Tip Worth {} {} {} Expiring Soon".format(round(tip.amount, round_decimals), warning, tip.tokenName) for to_email in to_emails: from_email = settings.CONTACT_EMAIL html, text = render_tip_email(to_email, tip, is_new) send_mail(from_email, to_email, subject, text, html)