Пример #1
0
def get_bcc_address():
    if is_production():
        return '*****@*****.**'
    elif is_dev():
        return '*****@*****.**'
    else:
        return 'bcc@local'
Пример #2
0
def get_recruiter_for_candidate(candidate):
    if is_production():
        employer_user = candidate.employer_user
        if employer_user is None:
            return get_recruiter_for_job(candidate.employer_job)
        else:
            return employer_user
    else:
        return candidate.employer_user
Пример #3
0
def forward_exception_to_sentry():
    if is_production():
        try:
            sentry_client.captureException()
            return
        except:
            pass

    print(traceback.format_exc())
Пример #4
0
def generate_custom_email_address(employer_user):
    user = employer_user.user

    if is_production():
        domain = "applications.bakround.com"
    elif is_dev():
        domain = "applications-dev.bakround.com"
    else:
        domain = "local"

    return "{}{}_{}@{}".format(user.first_name.lower().replace(" ", ""),
                               user.last_name.lower().replace(" ", ""),
                               employer_user.id, domain)
Пример #5
0
def send_email_notification(notification, resend=False):
    # include the original recipients if the service is running in prod, or if it's a system notification
    if is_production() or notification.initiator_user is None:
        ensure_recipient_verified(notification)
        subject = notification.subject
        to_email = get_recipient_email_addresses(notification, resend=resend)

        if notification.follow_up_count > 0:
            subject = "Reminder: {}".format(subject)
    else:
        to_email = [notification.initiator_user.email]
        subject = '{} ({})'.format(notification.subject, ', '.join(to_email))

    from_email = get_sender_email(notification)
    body = notification.html_body or notification.body
    headers = build_header_json(notification)

    for email_address in to_email:
        # TODO: Ensure we don't send emails except from prod
        email = EmailMessage(subject=subject,
                             body=body,
                             from_email=from_email,
                             to=[email_address],
                             bcc=[get_bcc_address()],
                             headers=headers)
        email.content_subtype = "html"  # This is an HTML email.
        email.send()

        notification_recipient = NotificationRecipient(
            notification=notification, recipient_email=email.to[0], sent=True)
        notification_recipient.save()

    notification.sent = True
    notification.save()

    return to_email