Exemple #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)
Exemple #2
0
def maybe_market_to_email(b, event_name):
    from marketing.mails import new_work_submission, new_bounty_rejection, new_bounty_acceptance
    to_emails = []
    if b.network != settings.ENABLE_NOTIFICATIONS_ON_NETWORK:
        return False

    if event_name == 'new_bounty' and not settings.DEBUG:
        # handled in 'new_bounties_email'
        return
    elif event_name == 'work_submitted':
        try:
            to_emails = [b.bounty_owner_email]
            new_work_submission(b, to_emails)
        except Exception as e:
            logging.exception(e)
            print(e)
    elif event_name == 'work_done':
        try:
            accepted_fulfillment = b.fulfillments.filter(accepted=True).latest('modified_on')
            to_emails = [b.bounty_owner_email, accepted_fulfillment.fulfiller_email]
            new_bounty_acceptance(b, to_emails)
        except Exception as e:
            logging.exception(e)
            print(e)
    elif event_name == 'rejected_claim':
        try:
            rejected_fulfillment = b.fulfillments.filter(accepted=False).latest('modified_on')
            to_emails = [b.bounty_owner_email, rejected_fulfillment.fulfiller_email]
            new_bounty_rejection(b, to_emails)
        except Exception as e:
            logging.exception(e)

    return len(to_emails)
Exemple #3
0
def maybe_market_to_email(b, event_name):
    from marketing.mails import new_work_submission, 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:
            # this doesnt scale because there are typically like 600 matches.. need to move to a background job
            return
            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))

            should_send_email = b.web3_created > (timezone.now() -
                                                  timezone.timedelta(hours=15))
            # only send if the bounty is reasonbly new

            if should_send_email:
                for to_email in set(to_emails):
                    new_bounty(b, [to_email])
        except Exception as e:
            logging.exception(e)
            print(e)
    elif event_name == 'work_submitted':
        try:
            to_emails = [b.bounty_owner_email]
            new_work_submission(b, to_emails)
        except Exception as e:
            logging.exception(e)
            print(e)
    elif event_name == 'work_done':
        accepted_fulfillment = b.fulfillments.filter(
            accepted=True).latest('modified_on')
        try:
            to_emails = [
                b.bounty_owner_email, accepted_fulfillment.fulfiller_email
            ]
            new_bounty_acceptance(b, to_emails)
        except Exception as e:
            logging.exception(e)
            print(e)
    elif event_name == 'rejected_claim':
        try:
            rejected_fulfillment = b.fulfillments.filter(
                accepted=False).latest('modified_on')
            to_emails = [
                b.bounty_owner_email, rejected_fulfillment.fulfiller_email
            ]
            new_bounty_rejection(b, to_emails)
        except Exception as e:
            logging.exception(e)

    return len(to_emails)
Exemple #4
0
def maybe_market_to_email(b, event_name):
    from marketing.mails import new_work_submission, new_bounty_rejection, new_bounty_acceptance, bounty_changed
    to_emails = []
    if b.network != settings.ENABLE_NOTIFICATIONS_ON_NETWORK:
        return False

    if event_name == 'new_bounty' and not settings.DEBUG:
        featured_funded_bounty(settings.CONTACT_EMAIL, bounty=b)
        return
    elif event_name == 'work_submitted':
        try:
            to_emails = [b.bounty_owner_email]
            new_work_submission(b, to_emails)
        except Exception as e:
            logging.exception(e)
            print(e)
    elif event_name == 'work_done':
        try:
            accepted_fulfillment = b.fulfillments.filter(
                accepted=True).latest('modified_on')
            to_emails = [
                b.bounty_owner_email, accepted_fulfillment.fulfiller_email
            ]
            new_bounty_acceptance(b, to_emails)
        except Exception as e:
            logging.exception(e)
            print(e)
    elif event_name == 'rejected_claim':
        try:
            rejected_fulfillment = b.fulfillments.filter(
                accepted=False).latest('modified_on')
            to_emails = [
                b.bounty_owner_email, rejected_fulfillment.fulfiller_email
            ]
            new_bounty_rejection(b, to_emails)
        except Exception as e:
            logging.exception(e)
    elif event_name == 'bounty_changed':
        try:
            to_emails = [b.bounty_owner_email]
            for profile in b.interested.select_related('profile').all():
                email = profile.profile.email
                if email:
                    to_emails.append(email)

            bounty_changed(b, to_emails)
        except Exception as e:
            logging.exception(e)

    return len(to_emails)
Exemple #5
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)