Skip to content

Commit

Permalink
Attachment Emails for Reviewer Attachments (#22704)
Browse files Browse the repository at this point in the history
* Modified email templates associated with reviewer actions to indicate whether they include an attachment

* cleanup

* remove unused param

* formatting

* stricter test

* formatting

* move attachment for files with policy.txt

* move for non-policy
  • Loading branch information
chrstinalin authored Sep 27, 2024
1 parent 2f74a72 commit 3ab810b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/olympia/abuse/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from olympia import amo
from olympia.addons.models import Addon
from olympia.amo.models import BaseQuerySet, ManagerBase, ModelBase
from olympia.amo.templatetags.jinja_helpers import absolutify
from olympia.api.utils import APIChoicesWithNone
from olympia.bandwagon.models import Collection
from olympia.constants.abuse import (
Expand Down Expand Up @@ -1241,6 +1242,10 @@ def notify_reviewer_decision(
# tools, we don't want to duplicate it as policies too.
'policies': policies if not self.notes else (),
'version_list': ', '.join(ver_str for ver_str in version_numbers),
'has_attachment': hasattr(log_entry, 'attachmentlog'),
'dev_url': absolutify(self.target.get_dev_url('versions'))
if self.addon_id
else None,
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Your add-on can be subject to human review at any time. Reviewers may determine
{% endif %}
{% if manual_reasoning_text %}Comments: {{ manual_reasoning_text }}.{% endif %}

{% if has_attachment %}
An attachment was provided. {% if dev_url %}To respond or view the file, visit {{ dev_url }}.{% endif %}

{% endif %}
Thank you.

More information about Mozilla's add-on policies can be found at {{ policy_document_url }}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Our review found that your content violates the following Mozilla policy or poli
{% include 'abuse/emails/includes/policies.txt' %}

Based on that finding, your {{ type }} has been permanently disabled on {{ target_url }} and is no longer available for download from Mozilla Add-ons, anywhere in the world. {% if is_addon_being_blocked %}In addition, users who have previously installed the add-on won't be able to continue using it.{% else %}Users who have previously installed your add-on will be able to continue using it.{% endif %}
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Previously, your {{ type }} was suspended/removed from Mozilla Add-ons, based on
{% if not is_override %}After reviewing your appeal, we{% else %}We have now{% endif %} determined that the previous decision was incorrect, and based on that determination, we have restored your {{ type }}. It is now available at {{ target_url }}.
{% if manual_reasoning_text %}{{ manual_reasoning_text }}. {% endif %}

{% if has_attachment %}
An attachment was provided. {% if dev_url %}To respond or view the file, visit {{ dev_url }}.{% endif %}

{% endif %}
Thank you.

More information about Mozilla's add-on policies can be found at {{ policy_document_url }}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Previously, your {{ type }} was suspended/removed from Mozilla Add-ons, based on

After reviewing your appeal, we determined that the previous decision, that your {{ type }} violates Mozilla's policies, was correct. {% if manual_reasoning_text %}{{ manual_reasoning_text }}. {% endif %}Based on that determination, we have denied your appeal, and will not reinstate your {{ type }}.

{% if has_attachment %}
An attachment was provided. {% if dev_url %}To respond or view the file, visit {{ dev_url }}.{% endif %}

{% endif %}
More information about Mozilla's add-on policies can be found at {{ policy_document_url }}.

Thank you.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
- {{ policy.full_text|safe }}
{% endfor %}
{% if manual_reasoning_text %}{{ manual_reasoning_text|safe }}. {% endif %}

{% if has_attachment %}
An attachment was provided. {% if dev_url %}To respond or view the file, visit {{ dev_url }}.{% endif %}

{% endif %}
15 changes: 14 additions & 1 deletion src/olympia/abuse/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
from django.conf import settings
from django.core import mail
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.core.files.base import ContentFile
from django.db.utils import IntegrityError

import pytest
import responses
from waffle.testutils import override_switch

from olympia import amo
from olympia.activity.models import ActivityLog
from olympia.activity.models import ActivityLog, AttachmentLog
from olympia.addons.models import Addon
from olympia.amo.tests import (
TestCase,
Expand Down Expand Up @@ -2746,6 +2747,18 @@ def _test_notify_reviewer_decision(
assert 'days' not in mail.outbox[0].body
assert 'some review text' in mail.outbox[0].body
assert 'some policy text' not in mail.outbox[0].body
AttachmentLog.objects.create(
activity_log=log_entry,
file=ContentFile('Pseudo File', name='attachment.txt'),
)
decision.notify_reviewer_decision(
log_entry=log_entry,
entity_helper=entity_helper,
)
assert 'An attachment was provided.' not in mail.outbox[0].body
assert 'To respond or view the file,' not in mail.outbox[0].body
assert 'An attachment was provided.' in mail.outbox[1].body
assert 'To respond or view the file,' in mail.outbox[1].body
else:
assert len(mail.outbox) == 0

Expand Down

0 comments on commit 3ab810b

Please sign in to comment.