Пример #1
0
def maybe_market_to_email(b, event_name, txid):
    from marketing.mails import new_bounty_claim, new_bounty_rejection, new_bounty_acceptance

    #TODO: allow people to subscribe to new_bounty notifications
    #new_bounty(b, [to_email])

    to_emails = []

    if event_name == 'new_claim':
        try:
            to_emails = [b.bounty_owner_email]
            new_bounty_claim(b, to_emails)
        except Exception as e:
            print(e)
    if event_name == 'approved_claim':
        try:
            to_emails = [b.bounty_owner_email, b.claimee_email]
            new_bounty_acceptance(b, to_emails)
        except Exception as e:
            print(e)
    if event_name == 'rejected_claim':
        try:
            to_emails = [b.bounty_owner_email, b.claimee_email]
            new_bounty_rejection(b, to_emails)
        except Exception as e:
            print(e)

    return len(to_emails)
Пример #2
0
def maybe_market_to_email(b, event_name, txid):
    from marketing.mails import new_bounty_claim, new_bounty_rejection, new_bounty_acceptance, new_bounty
    from marketing.models import EmailSubscriber
    to_emails = []
    if b.network != settings.ENABLE_NOTIFICATIONS_ON_NETWORK:
        return False

    if event_name == 'new_bounty' and not settings.DEBUG:
        try:
            to_emails = []
            keywords = b.keywords.split(',')
            for keyword in keywords:
                to_emails = to_emails + list(
                    EmailSubscriber.objects.filter(
                        keywords__contains=[keyword.strip()]).values_list(
                            'email', flat=True))
            for to_email in set(to_emails):
                new_bounty(b, [to_email])
        except Exception as e:
            logging.exception(e)
            print(e)
    if event_name == 'new_claim':
        try:
            to_emails = [b.bounty_owner_email]
            new_bounty_claim(b, to_emails)
        except Exception as e:
            logging.exception(e)
            print(e)
    if event_name == 'approved_claim':
        try:
            to_emails = [b.bounty_owner_email, b.claimee_email]
            new_bounty_acceptance(b, to_emails)
        except Exception as e:
            logging.exception(e)
            print(e)
    if event_name == 'rejected_claim':
        try:
            to_emails = [b.bounty_owner_email, b.claimee_email]
            new_bounty_rejection(b, to_emails)
        except Exception as e:
            logging.exception(e)
            print(e)

    return len(to_emails)