Exemplo n.º 1
0
Arquivo: tasks.py Projeto: ollutr/web
def bounty_emails(self, emails, msg, profile_handle, invite_url=None, kudos_invite=False, retry: bool = True) -> None:
    """
    :param self:
    :param emails:
    :param msg:
    :param profile_handle:
    :param invite_url:
    :param kudos_invite:
    :return:
    """
    with redis.lock("tasks:bounty_email:%s" % invite_url, timeout=LOCK_TIMEOUT):
        # need to look at how to send bulk emails with SG
        profile = Profile.objects.get(handle=profile_handle.lower())
        try:
            for email in emails:
                to_email = email
                from_email = settings.CONTACT_EMAIL
                subject = "You have been invited to work on a bounty."
                html, text = render_share_bounty(to_email, msg, profile, invite_url, kudos_invite)
                send_mail(
                    from_email,
                    to_email,
                    subject,
                    text,
                    html,
                    from_name=f"@{profile.handle}",
                    categories=['transactional', func_name()],
                )

        except ConnectionError as exc:
            logger.info(str(exc))
            logger.info("Retrying connection")
            self.retry(countdown=30)
        except Exception as e:
            logger.error(str(e))
Exemplo n.º 2
0
def share_bounty(emails, msg, profile, invite_url=None, kudos_invite=False):
    for email in emails:
        to_email = email
        from_email = profile.email
        subject = "You have been invited to work on a bounty."
        html, text = render_share_bounty(to_email, msg, profile, invite_url, kudos_invite)
        send_mail(
            from_email,
            to_email,
            subject,
            text,
            html,
            from_name=f"@{profile.handle}",
            categories=['transactional', func_name()],
        )
Exemplo n.º 3
0
def share_bounty(emails, msg, profile, invite_url=None, kudos_invite=False):
    for email in emails:
        to_email = email
        from_email = settings.CONTACT_EMAIL
        subject = f"@{profile.handle} invited you to to work on a bounty."
        html, text = render_share_bounty(to_email, msg, profile, invite_url, kudos_invite)
        send_mail(
            from_email,
            to_email,
            subject,
            text,
            html,
            from_name=f"@{profile.handle}",
            categories=['transactional', func_name()],
        )