Skip to content

Commit 790fb00

Browse files
committed
drop support for AMO_ESCALATE and forwarded jobs
1 parent c6ca50d commit 790fb00

File tree

14 files changed

+27
-494
lines changed

14 files changed

+27
-494
lines changed

src/olympia/abuse/actions.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,6 @@ def hold_action(self):
523523
)
524524

525525

526-
class ContentActionForwardToReviewers(ContentAction):
527-
valid_targets = (Addon,)
528-
529-
def process_action(self):
530-
from olympia.abuse.tasks import handle_escalate_action
531-
532-
handle_escalate_action.delay(job_pk=self.decision.cinder_job.pk)
533-
534-
535526
class ContentActionForwardToLegal(ContentAction):
536527
valid_targets = (Addon,)
537528

@@ -733,7 +724,6 @@ class ContentActionNotImplemented(AnyTargetMixin, NoActionMixin, ContentAction):
733724
DECISION_ACTIONS.AMO_REJECT_VERSION_WARNING_ADDON: (
734725
ContentActionRejectVersionDelayed
735726
),
736-
DECISION_ACTIONS.AMO_ESCALATE_ADDON: ContentActionForwardToReviewers,
737727
DECISION_ACTIONS.AMO_DELETE_COLLECTION: ContentActionDeleteCollection,
738728
DECISION_ACTIONS.AMO_DELETE_RATING: ContentActionDeleteRating,
739729
DECISION_ACTIONS.AMO_APPROVE: ContentActionApproveNoAction,

src/olympia/abuse/management/commands/backfill_cinder_escalations.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/olympia/abuse/models.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,6 @@ class CinderJob(ModelBase):
9393
to=Addon, blank=True, null=True, on_delete=models.deletion.SET_NULL
9494
)
9595
resolvable_in_reviewer_tools = models.BooleanField(default=None, null=True)
96-
forwarded_to_job = models.ForeignKey(
97-
to='self',
98-
null=True,
99-
on_delete=models.SET_NULL,
100-
related_name='forwarded_from_jobs',
101-
)
10296

10397
objects = CinderJobManager()
10498

@@ -247,45 +241,6 @@ def notify_reporters(self, action_helper):
247241
reporter_abuse_reports=appellants, is_appeal=True
248242
)
249243

250-
def handle_job_recreated(self, *, new_job_id, resolvable_in_reviewer_tools):
251-
from olympia.reviewers.models import NeedsHumanReview
252-
253-
new_job, created = CinderJob.objects.update_or_create(
254-
job_id=new_job_id,
255-
defaults={
256-
'resolvable_in_reviewer_tools': resolvable_in_reviewer_tools,
257-
'target_addon': self.target_addon,
258-
},
259-
)
260-
# If this forward has been combined with an existing non-forwarded job we need
261-
# to clear the NHR for reason:ABUSE_ADDON_VIOLATION, because it now has a NHR
262-
# for reason:CINDER_ESCALATION.
263-
if not created and not new_job.forwarded_from_jobs.exists():
264-
has_unresolved_abuse_report_jobs = (
265-
self.__class__.objects.for_addon(new_job.target_addon)
266-
.exclude(
267-
id=new_job.id,
268-
forwarded_from_jobs__isnull=True,
269-
appealed_decisions__isnull=True,
270-
)
271-
.unresolved()
272-
.resolvable_in_reviewer_tools()
273-
.exists()
274-
)
275-
# But only if there aren't other jobs that should legitimately have a NHR
276-
# for reason:ABUSE_ADDON_VIOLATION
277-
if not has_unresolved_abuse_report_jobs:
278-
NeedsHumanReview.objects.filter(
279-
version__addon_id=new_job.target_addon.id,
280-
is_active=True,
281-
reason=NeedsHumanReview.REASONS.ABUSE_ADDON_VIOLATION,
282-
).update(is_active=False)
283-
new_job.target_addon.update_all_due_dates()
284-
# Update our fks to connected objects
285-
AbuseReport.objects.filter(cinder_job=self).update(cinder_job=new_job)
286-
ContentDecision.objects.filter(appeal_job=self).update(appeal_job=new_job)
287-
self.update(forwarded_to_job=new_job)
288-
289244
def process_decision(
290245
self,
291246
*,
@@ -368,14 +323,6 @@ def clear_needs_human_review_flags(self):
368323
decisions__overridden_by__isnull=True,
369324
).exists()
370325
reasons = {NeedsHumanReview.REASONS.SECOND_LEVEL_REQUEUE}
371-
elif self.forwarded_from_jobs.exists():
372-
has_unresolved_jobs_with_similar_reason = base_unresolved_jobs_qs.filter(
373-
forwarded_from_jobs__isnull=False
374-
).exists()
375-
reasons = {
376-
NeedsHumanReview.REASONS.CINDER_ESCALATION,
377-
NeedsHumanReview.REASONS.CINDER_APPEAL_ESCALATION,
378-
}
379326
elif self.queue_moves.exists():
380327
has_unresolved_jobs_with_similar_reason = base_unresolved_jobs_qs.filter(
381328
queue_moves__id__gt=0

src/olympia/abuse/tasks.py

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,6 @@ def mark_used_orphaned_policies(policies_in_cinder):
210210
mark_used_orphaned_policies(policies_in_cinder)
211211

212212

213-
@task
214-
@use_primary_db
215-
def handle_escalate_action(*, job_pk, from_2nd_level=False):
216-
old_job = CinderJob.objects.get(id=job_pk)
217-
entity_helper = CinderJob.get_entity_helper(
218-
old_job.target, resolved_in_reviewer_tools=True
219-
)
220-
job_id = entity_helper.workflow_recreate(
221-
notes=old_job.final_decision.notes, job=old_job, from_2nd_level=from_2nd_level
222-
)
223-
224-
old_job.handle_job_recreated(new_job_id=job_id, resolvable_in_reviewer_tools=True)
225-
226-
227213
@task
228214
@use_primary_db
229215
def handle_forward_to_legal_action(*, decision_pk):
@@ -232,15 +218,15 @@ def handle_forward_to_legal_action(*, decision_pk):
232218
entity_helper = CinderAddonHandledByLegal(decision.addon)
233219
job_id = entity_helper.workflow_recreate(notes=decision.notes, job=old_job)
234220

221+
new_job, _ = CinderJob.objects.update_or_create(
222+
job_id=job_id,
223+
defaults={
224+
'resolvable_in_reviewer_tools': False,
225+
'target_addon': decision.addon,
226+
},
227+
)
228+
235229
if old_job:
236-
old_job.handle_job_recreated(
237-
new_job_id=job_id, resolvable_in_reviewer_tools=False
238-
)
239-
else:
240-
CinderJob.objects.update_or_create(
241-
job_id=job_id,
242-
defaults={
243-
'resolvable_in_reviewer_tools': False,
244-
'target_addon': decision.addon,
245-
},
246-
)
230+
# Update fks to connected objects
231+
AbuseReport.objects.filter(cinder_job=old_job).update(cinder_job=new_job)
232+
ContentDecision.objects.filter(appeal_job=old_job).update(appeal_job=new_job)

src/olympia/abuse/tests/test_actions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,9 +848,7 @@ def test_forward_from_reviewers_with_job(self):
848848
new_cinder_job = CinderJob.objects.get(job_id='1234-xyz')
849849
assert new_cinder_job != self.cinder_job
850850
assert new_cinder_job.job_id == '1234-xyz'
851-
# The old cinder_job should have a reference to the new job
852-
assert self.cinder_job.reload().forwarded_to_job == new_cinder_job
853-
# And the reports should now be part of the new job instead
851+
# The reports should now be part of the new job instead
854852
assert self.abuse_report_auth.reload().cinder_job == new_cinder_job
855853
assert self.abuse_report_no_auth.reload().cinder_job == new_cinder_job
856854
request_body = json.loads(responses.calls[0].request.body)

src/olympia/abuse/tests/test_cinder.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,26 +1308,6 @@ def test_report_with_ongoing_appeal(self):
13081308
# The add-on does not get flagged again while the appeal is ongoing.
13091309
assert addon.current_version.needshumanreview_set.count() == 0
13101310

1311-
def test_report_with_ongoing_forwarded_appeal(self):
1312-
addon = self._create_dummy_target()
1313-
job = CinderJob.objects.create(job_id='1234-xyz')
1314-
CinderJob.objects.create(forwarded_to_job=job)
1315-
job.appealed_decisions.add(
1316-
ContentDecision.objects.create(
1317-
addon=addon,
1318-
cinder_id='1234-decision',
1319-
action=DECISION_ACTIONS.AMO_REJECT_VERSION_ADDON,
1320-
)
1321-
)
1322-
# Trigger switch_is_active to ensure it's cached to make db query
1323-
# count more predictable.
1324-
waffle.switch_is_active('dsa-abuse-reports-review')
1325-
self._test_report(addon)
1326-
cinder_instance = self.CinderClass(addon)
1327-
cinder_instance.post_report(job)
1328-
# The add-on does not get flagged again while the appeal is ongoing.
1329-
assert addon.current_version.needshumanreview_set.count() == 0
1330-
13311311
def test_create_decision(self):
13321312
target = self._create_dummy_target()
13331313

src/olympia/abuse/tests/test_commands.py

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4,80 +4,9 @@
44
import pytest
55
import responses
66

7-
from olympia.amo.tests import addon_factory, user_factory
8-
from olympia.constants.abuse import DECISION_ACTIONS
7+
from olympia.amo.tests import addon_factory
98

10-
from ..models import AbuseReport, CinderJob, ContentDecision
11-
12-
13-
@pytest.mark.django_db
14-
def test_backfill_cinder_escalations():
15-
user = user_factory(pk=settings.TASK_USER_ID)
16-
addon = addon_factory(users=[user])
17-
job_with_reports = CinderJob.objects.create(
18-
job_id='1',
19-
decision=ContentDecision.objects.create(
20-
action=DECISION_ACTIONS.AMO_ESCALATE_ADDON, addon=addon
21-
),
22-
)
23-
abuse = AbuseReport.objects.create(guid=addon.guid, cinder_job=job_with_reports)
24-
appeal_job = CinderJob.objects.create(
25-
job_id='2',
26-
decision=ContentDecision.objects.create(
27-
action=DECISION_ACTIONS.AMO_ESCALATE_ADDON, addon=addon
28-
),
29-
)
30-
appealled_decision = ContentDecision.objects.create(
31-
action=DECISION_ACTIONS.AMO_DISABLE_ADDON, addon=addon, appeal_job=appeal_job
32-
)
33-
34-
# And some jobs/decisions that should be skipped:
35-
# decision that wasn't an escalation (or isn't any longer)
36-
CinderJob.objects.create(
37-
job_id='3',
38-
decision=ContentDecision.objects.create(
39-
action=DECISION_ACTIONS.AMO_APPROVE, addon=addon
40-
),
41-
)
42-
# decision without an associated cinder job (shouldn't occur, but its handled)
43-
ContentDecision.objects.create(
44-
action=DECISION_ACTIONS.AMO_ESCALATE_ADDON, addon=addon
45-
)
46-
# decision that already has a forwarded job created, so we don't need to backfill
47-
CinderJob.objects.create(
48-
job_id='4',
49-
decision=ContentDecision.objects.create(
50-
action=DECISION_ACTIONS.AMO_ESCALATE_ADDON, addon=addon
51-
),
52-
forwarded_to_job=CinderJob.objects.create(job_id='5'),
53-
)
54-
assert CinderJob.objects.count() == 5
55-
assert ContentDecision.objects.count() == 6
56-
responses.add(
57-
responses.POST,
58-
f'{settings.CINDER_SERVER_URL}create_report',
59-
json={'job_id': '6'},
60-
status=201,
61-
)
62-
responses.add(
63-
responses.POST,
64-
f'{settings.CINDER_SERVER_URL}create_report',
65-
json={'job_id': '7'},
66-
status=201,
67-
)
68-
69-
call_command('backfill_cinder_escalations')
70-
assert CinderJob.objects.count() == 7
71-
assert ContentDecision.objects.count() == 6
72-
73-
new_job_with_reports = job_with_reports.reload().forwarded_to_job
74-
assert new_job_with_reports
75-
assert new_job_with_reports.resolvable_in_reviewer_tools is True
76-
assert abuse.reload().cinder_job == new_job_with_reports
77-
new_appeal_job = appeal_job.reload().forwarded_to_job
78-
assert new_appeal_job
79-
assert new_appeal_job.resolvable_in_reviewer_tools is True
80-
assert appealled_decision.reload().appeal_job == new_appeal_job
9+
from ..models import AbuseReport, CinderJob
8110

8211

8312
@pytest.mark.django_db

0 commit comments

Comments
 (0)