Skip to content

Commit 90865d7

Browse files
chore: purge stale / bounty feedback mail (#10821)
1 parent ac3bc3f commit 90865d7

File tree

8 files changed

+2
-445
lines changed

8 files changed

+2
-445
lines changed

app/app/urls.py

-2
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,6 @@
712712
retail.emails.bounty_expire_warning,
713713
name='bounty_expire_warning'
714714
),
715-
path('_administration/email/bounty_feedback', retail.emails.bounty_feedback, name='bounty_feedback'),
716-
path('_administration/email/funder_stale', retail.emails.funder_stale, name='funder_stale'),
717715
path(
718716
'_administration/email/start_work_expire_warning',
719717
retail.emails.start_work_expire_warning,

app/marketing/common/utils.py

-46
Original file line numberDiff line numberDiff line change
@@ -287,52 +287,6 @@ def generate_hackathon_email_intro(sponsors_prizes):
287287
return f"{sponsors_prizes[0]['sponsor'].name} is"
288288

289289

290-
def handle_bounty_feedback(bounty):
291-
from dashboard.models import Bounty, BountyFulfillment
292-
293-
to_fulfiller = to_funder = False
294-
fulfiller_previous_bounties = funder_previous_bounties = None
295-
statuses = ['done', 'cancelled']
296-
297-
# identity
298-
submitter_email = bounty.bounty_owner_email
299-
is_fulfiller_and_funder_same_person = False
300-
301-
# send email to the fulfiller
302-
accepted_fulfillments = bounty.fulfillments.filter(accepted=True)
303-
304-
if accepted_fulfillments.exists() and bounty.status == 'done':
305-
accepted_fulfillment = accepted_fulfillments.first()
306-
fulfiller_email = accepted_fulfillment.fulfiller_email
307-
is_fulfiller_and_funder_same_person = (fulfiller_email == submitter_email)
308-
fulfillment_pks = [
309-
fulfillment.pk for fulfillment in BountyFulfillment.objects.filter(accepted=True) \
310-
if fulfillment.fulfiller_email == fulfiller_email
311-
]
312-
previous_bounties = Bounty.objects.current().filter(
313-
idx_status__in=statuses,
314-
fulfillments__pk__in=fulfillment_pks
315-
).exclude(pk=bounty.pk).distinct()
316-
has_been_sent_before_to_persona = previous_bounties.count()
317-
if not has_been_sent_before_to_persona and not is_fulfiller_and_funder_same_person:
318-
to_fulfiller = True
319-
fulfiller_previous_bounties = previous_bounties
320-
321-
# send email to the funder
322-
previous_bounties = Bounty.objects.filter(
323-
idx_status__in=statuses,
324-
bounty_owner_email=submitter_email,
325-
current_bounty=True
326-
).exclude(pk=bounty.pk).distinct()
327-
has_been_sent_before_to_persona = previous_bounties.count()
328-
329-
if not has_been_sent_before_to_persona and not is_fulfiller_and_funder_same_person:
330-
to_funder = True
331-
funder_previous_bounties = previous_bounties
332-
333-
return (to_fulfiller, to_funder, fulfiller_previous_bounties, funder_previous_bounties)
334-
335-
336290
def func_name():
337291
"""Determine the calling function's name.
338292

app/marketing/mails.py

+2-66
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
from python_http_client.exceptions import HTTPError, UnauthorizedError
3333
from retail.emails import (
3434
email_to_profile, get_notification_count, render_admin_contact_funder, render_bounty_changed,
35-
render_bounty_expire_warning, render_bounty_feedback, render_bounty_hypercharged,
35+
render_bounty_expire_warning, render_bounty_hypercharged,
3636
render_bounty_startwork_expire_warning, render_bounty_unintersted, render_comment, render_featured_funded_bounty,
37-
render_funder_payout_reminder, render_funder_stale, render_gdpr_reconsent, render_gdpr_update,
37+
render_funder_payout_reminder, render_gdpr_reconsent, render_gdpr_update,
3838
render_grant_cancellation_email, render_grant_match_distribution_final_txn, render_grant_recontribute,
3939
render_grant_txn_failed, render_grant_update, render_match_distribution, render_match_email, render_mention,
4040
render_new_bounty, render_new_bounty_acceptance, render_new_bounty_rejection, render_new_bounty_roundup,
@@ -436,70 +436,6 @@ def admin_contact_funder(bounty, text, from_user):
436436
translation.activate(cur_language)
437437

438438

439-
def funder_stale(to_email, github_username, days=30, time_as_str='about a month'):
440-
from_email = '[email protected]'
441-
cur_language = translation.get_language()
442-
try:
443-
setup_lang(to_email)
444-
445-
subject = "hey from gitcoin.co" if not github_username else f"hey @{github_username}"
446-
__, text = render_funder_stale(github_username, days, time_as_str)
447-
cc_emails = []
448-
if allowed_to_send_email(to_email, 'admin_contact_funder'):
449-
send_mail(
450-
from_email,
451-
to_email,
452-
subject,
453-
text,
454-
cc_emails=cc_emails,
455-
from_name=from_email,
456-
categories=['transactional', func_name()],
457-
)
458-
finally:
459-
translation.activate(cur_language)
460-
461-
462-
def bounty_feedback(bounty, persona='fulfiller', previous_bounties=None):
463-
from_email = '[email protected]'
464-
to_email = None
465-
cur_language = translation.get_language()
466-
if previous_bounties is None:
467-
previous_bounties = []
468-
469-
try:
470-
setup_lang(to_email)
471-
if persona == 'fulfiller':
472-
accepted_fulfillments = bounty.fulfillments.filter(accepted=True)
473-
to_email = accepted_fulfillments.first().fulfiller_email if accepted_fulfillments.exists() else ""
474-
elif persona == 'funder':
475-
to_email = bounty.bounty_owner_email
476-
if not to_email:
477-
if bounty.bounty_owner_profile:
478-
to_email = bounty.bounty_owner_profile.email
479-
if not to_email:
480-
if bounty.bounty_owner_profile and bounty.bounty_owner_profile.user:
481-
to_email = bounty.bounty_owner_profile.user.email
482-
if not to_email:
483-
return
484-
485-
subject = bounty.github_url
486-
html, text = render_bounty_feedback(bounty, persona, previous_bounties)
487-
cc_emails = [from_email, '[email protected]']
488-
if allowed_to_send_email(to_email, 'bounty_feedback'):
489-
send_mail(
490-
from_email,
491-
to_email,
492-
subject,
493-
text,
494-
html,
495-
cc_emails=cc_emails,
496-
from_name="Gitcoin Product Team",
497-
categories=['transactional', func_name()],
498-
)
499-
finally:
500-
translation.activate(cur_language)
501-
502-
503439
def tip_email(tip, to_emails, is_new):
504440
round_decimals = 5
505441
if not tip or not tip.txid or not tip.amount or not tip.tokenName:

app/marketing/management/commands/bounty_feedback_email.py

-62
This file was deleted.

app/marketing/management/commands/funder_stale_email.py

-103
This file was deleted.

0 commit comments

Comments
 (0)