From a95bceebe5a18489f0fa3ec62252f0eb0d2e2ac9 Mon Sep 17 00:00:00 2001 From: Mathieu Pillard Date: Tue, 27 Feb 2024 13:35:39 +0100 Subject: [PATCH] Don't include empty additional reasoning in cinder appeal decline emails if there isn't any --- ...erActionTargetAppealRemovalAffirmation.txt | 2 +- src/olympia/abuse/tests/test_utils.py | 27 +++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/olympia/abuse/templates/abuse/emails/CinderActionTargetAppealRemovalAffirmation.txt b/src/olympia/abuse/templates/abuse/emails/CinderActionTargetAppealRemovalAffirmation.txt index 6b589d0e3bc..349a1ebb088 100644 --- a/src/olympia/abuse/templates/abuse/emails/CinderActionTargetAppealRemovalAffirmation.txt +++ b/src/olympia/abuse/templates/abuse/emails/CinderActionTargetAppealRemovalAffirmation.txt @@ -2,7 +2,7 @@ Hello, Previously, your {{ type }} was suspended/removed from Mozilla Add-ons, based on a finding that you had violated Mozilla's policies. -After reviewing your appeal, we determined that the previous decision, that your {{ type }} violates Mozilla's policies, was correct. {{ additional_reasoning }}. Based on that determination, we have denied your appeal, and will not reinstate your {{ type }}. +After reviewing your appeal, we determined that the previous decision, that your {{ type }} violates Mozilla's policies, was correct.{% if additional_reasoning %} {{ additional_reasoning }}.{% endif %} Based on that determination, we have denied your appeal, and will not reinstate your {{ type }}. More information about Mozilla's add-on policies can be found at {{ policy_document_url }}. diff --git a/src/olympia/abuse/tests/test_utils.py b/src/olympia/abuse/tests/test_utils.py index dcc5acef15e..76d0365c071 100644 --- a/src/olympia/abuse/tests/test_utils.py +++ b/src/olympia/abuse/tests/test_utils.py @@ -183,11 +183,16 @@ def _test_owner_takedown_email(self, subject, snippet): assert '"' not in mail_item.body assert '<b>' not in mail_item.body - def _test_owner_affirmation_email(self, subject): + def _test_owner_affirmation_email( + self, subject, additional_reasoning='extra notes.' + ): mail_item = mail.outbox[0] self._check_owner_email(mail_item, subject, 'was correct') assert 'right to appeal' not in mail_item.body - assert 'extra notes.' in mail_item.body + if additional_reasoning: + assert additional_reasoning in mail_item.body + else: + assert ' was correct. Based on that determination' in mail_item.body def _test_owner_restore_email(self, subject): mail_item = mail.outbox[0] @@ -472,6 +477,24 @@ def test_target_appeal_decline(self): action.notify_owners() self._test_owner_affirmation_email(f'Mozilla Add-ons: {self.addon.name}') + def test_target_appeal_decline_no_additional_reasoning(self): + self.addon.update(status=amo.STATUS_DISABLED) + ActivityLog.objects.all().delete() + self.cinder_job.update(decision_notes='') + action = CinderActionTargetAppealRemovalAffirmation(self.cinder_job) + assert action.process_action() + + self.addon.reload() + assert self.addon.status == amo.STATUS_DISABLED + assert ActivityLog.objects.count() == 0 + assert len(mail.outbox) == 0 + + action.notify_reporters() + action.notify_owners() + self._test_owner_affirmation_email( + f'Mozilla Add-ons: {self.addon.name}', additional_reasoning=None + ) + def test_notify_owners_with_manual_policy_block(self): self.cinder_job.update( decision_action=CinderJob.DECISION_ACTIONS.AMO_DISABLE_ADDON