Skip to content

Commit

Permalink
Notify developer
Browse files Browse the repository at this point in the history
  • Loading branch information
diox committed Jan 20, 2025
1 parent b72c889 commit dbcb1ee
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/olympia/abuse/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ def process_action(self):
)


class ContentActionChangePendingRejectionDate(ContentAction):
description = 'Add-on pending rejection date has changed'
valid_targets = (Addon,)

def get_owners(self):
return self.target.authors.all()


class ContentActionDeleteCollection(ContentAction):
valid_targets = (Collection,)
description = 'Collection has been deleted'
Expand Down
5 changes: 5 additions & 0 deletions src/olympia/abuse/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
ContentActionApproveInitialDecision,
ContentActionApproveNoAction,
ContentActionBanUser,
ContentActionChangePendingRejectionDate,
ContentActionDeleteCollection,
ContentActionDeleteRating,
ContentActionDisableAddon,
Expand Down Expand Up @@ -1048,6 +1049,9 @@ def get_action_helper_class(cls, decision_action):
DECISION_ACTIONS.AMO_IGNORE: ContentActionIgnore,
DECISION_ACTIONS.AMO_CLOSED_NO_ACTION: ContentActionAlreadyRemoved,
DECISION_ACTIONS.AMO_LEGAL_FORWARD: ContentActionForwardToLegal,
DECISION_ACTIONS.AMO_CHANGE_PENDING_REJECTION_DATE: (
ContentActionChangePendingRejectionDate
),
}.get(decision_action, ContentActionNotImplemented)

def get_action_helper(self):
Expand Down Expand Up @@ -1275,6 +1279,7 @@ def execute_action_and_notify(self, *, release_hold=False):
extra_context = {
'auto_approval': is_auto_approval,
'delayed_rejection_days': details.get('delayed_rejection_days'),
'details': details,
'is_addon_being_blocked': details.get('is_addon_being_blocked'),
'is_addon_disabled': details.get('is_addon_being_disabled')
or getattr(self.target, 'is_disabled', False),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends "abuse/emails/base.txt" %}{% block content %}

As you are aware, your {{ type }} {{ name }} was manually reviewed by the Mozilla Add-ons team, at which point we found a violation of one or more Mozilla add-on policies.

Our previous correspondence indicated that you would be required to correct the violation(s) by {{ details.old_deadline }}. However, after further assessing the circumstances - including the violation itself, the risks it presents, and the steps required to resolve it - we have determined that an alternative timeline is appropriate. Based on that determination, we have updated the deadline, and will now require you to correct your add-on violations no later than {{ details.new_deadline }}.
{% endblock %}
15 changes: 12 additions & 3 deletions src/olympia/constants/abuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
('AMO_IGNORE', 11, 'Invalid report, so ignored'),
('AMO_CLOSED_NO_ACTION', 12, 'Content already removed (no action)'),
('AMO_LEGAL_FORWARD', 13, 'Forward add-on to legal'),
# Changing pending rejection date is not an available action for moderators
# in cinder - it is only performed by AMO Reviewers.
('AMO_CHANGE_PENDING_REJECTION_DATE', 14, 'Pending rejection date changed'),
)
DECISION_ACTIONS.add_subset(
'APPEALABLE_BY_AUTHOR',
Expand Down Expand Up @@ -51,7 +54,13 @@
'NON_OFFENDING', ('AMO_APPROVE', 'AMO_APPROVE_VERSION', 'AMO_IGNORE')
)
DECISION_ACTIONS.add_subset(
'SKIP_DECISION', ('AMO_APPROVE', 'AMO_APPROVE_VERSION', 'AMO_LEGAL_FORWARD')
'SKIP_DECISION',
(
'AMO_APPROVE',
'AMO_APPROVE_VERSION',
'AMO_LEGAL_FORWARD',
'AMO_CHANGE_PENDING_REJECTION_DATE',
),
)

# Illegal categories, only used when the reason is `illegal`. The constants
Expand Down Expand Up @@ -115,12 +124,12 @@
(
'HIDDEN_ADVERTISEMENT',
4,
'Hidden advertisement or commercial communication, including by ' 'influencers',
'Hidden advertisement or commercial communication, including by influencers',
),
(
'MISLEADING_INFO_GOODS_SERVICES',
5,
'Misleading information about the characteristics of the goods and ' 'services',
'Misleading information about the characteristics of the goods and services',
),
(
'MISLEADING_INFO_CONSUMER_RIGHTS',
Expand Down
1 change: 1 addition & 0 deletions src/olympia/constants/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,7 @@ class CHANGE_PENDING_REJECTION(_LOG):
keep = True
review_queue = True
reviewer_review_action = True
cinder_action = DECISION_ACTIONS.AMO_CHANGE_PENDING_REJECTION_DATE
# Not hidden to developers.


Expand Down
9 changes: 7 additions & 2 deletions src/olympia/reviewers/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,9 @@ def validate_review_attachment(value):
valid_extensions_string = '(%s)' % ', '.join(VALID_ATTACHMENT_EXTENSIONS)
raise forms.ValidationError(
gettext(
'Unsupported file type, please upload a '
'file {extensions}.'.format(extensions=valid_extensions_string)
'Unsupported file type, please upload a file {extensions}.'.format(
extensions=valid_extensions_string
)
)
)
if value.size >= settings.MAX_UPLOAD_SIZE:
Expand Down Expand Up @@ -523,6 +524,10 @@ def clean(self):
forms.ValidationError('This field is required.'),
)

# FIXME: if they chose to change a pending rejection date we need
# to check all versions had the same one or raise an error.
# FIXME: and versions is required in that case

return self.cleaned_data

def clean_delayed_rejection_date(self):
Expand Down
15 changes: 14 additions & 1 deletion src/olympia/reviewers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,18 +1546,21 @@ def change_pending_rejection_multiple_versions(self):
"""Change pending rejection on selected versions."""
self.file = None
self.version = None
extra_details = {}
if self.data.get('delayed_rejection') and self.data.get(
'delayed_rejection_date'
):
pending_rejection_deadline = self.data['delayed_rejection_date']
action = amo.LOG.CHANGE_PENDING_REJECTION
extra_details['new_deadline'] = str(pending_rejection_deadline)
else:
pending_rejection_deadline = None
action = amo.LOG.CLEAR_PENDING_REJECTION

for version in self.data['versions']:
# Do it one by one to trigger the post_save() for each version.
if version.pending_rejection:
extra_details['old_deadline'] = str(version.pending_rejection)
kwargs = {
'pending_rejection': pending_rejection_deadline,
}
Expand All @@ -1570,7 +1573,17 @@ def change_pending_rejection_multiple_versions(self):
)
version.reviewerflags.update(**kwargs)
# Record a single activity log.
self.log_action(action, versions=self.data['versions'])
self.log_action(
action, versions=self.data['versions'], extra_details=extra_details
)
if pending_rejection_deadline:
log.info('Sending email for %s' % (self.addon))
# We avoid calling record_decision() because this action doesn't
# affect the queue (or resolve jobs), we only want to notify the
# developer(s).
notify_addon_decision_to_cinder.delay(
log_entry_id=self.log_entry.id, addon_id=self.addon.id
)

def enable_addon(self):
"""Force enable the add-on."""
Expand Down

0 comments on commit dbcb1ee

Please sign in to comment.