Skip to content

Commit

Permalink
Expose considers_illegal boolean with CinderReport entity (#21849)
Browse files Browse the repository at this point in the history
We already exposed the full text of the reason the convenience of moderators,
this is more for internal purposes for the EU transparency database integration
which specifically requires us to expose whether or not the reporter considered
the reported content illegal.
  • Loading branch information
diox committed Feb 12, 2024
1 parent 74c2636 commit d431832
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/olympia/abuse/cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ def get_attributes(self):
else None,
'message': self.abuse_report.message,
'locale': self.abuse_report.application_locale,
# We need a boolean to expose specifically if the reporter
# considered the content illegal, as that needs to be reflected in
# the SOURCE_TYPE in the transparency database.
'considers_illegal': self.abuse_report.reason
== self.abuse_report.REASONS.ILLEGAL,
}

def report(self, *args, **kwargs):
Expand Down
40 changes: 40 additions & 0 deletions src/olympia/abuse/tests/test_cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def test_build_report_payload(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
}
Expand Down Expand Up @@ -256,6 +257,7 @@ def test_build_report_payload(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -300,6 +302,7 @@ def test_build_report_payload(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -361,6 +364,7 @@ def test_build_report_payload_with_author(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -407,6 +411,7 @@ def test_build_report_payload_with_author(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -475,6 +480,7 @@ def test_build_report_payload_with_author_and_reporter_being_the_same(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -583,6 +589,7 @@ def test_build_report_payload_with_previews_and_icon(
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -673,6 +680,7 @@ def test_build_report_payload_with_theme_previews(
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -735,6 +743,7 @@ def test_build_report_payload_only_includes_first_batch_of_relationships(self):
'locale': None,
'message': 'report for lots of relationships',
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -1088,6 +1097,7 @@ def test_build_report_payload(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
}
Expand Down Expand Up @@ -1120,6 +1130,7 @@ def test_build_report_payload(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -1164,6 +1175,7 @@ def test_build_report_payload(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -1229,6 +1241,7 @@ def test_build_report_payload_with_author_and_reporter_being_the_same(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -1301,6 +1314,7 @@ def test_build_report_payload_addon_author(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -1351,6 +1365,7 @@ def test_build_report_payload_addon_author(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -1444,6 +1459,7 @@ def test_build_report_payload_with_picture(
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
}
Expand Down Expand Up @@ -1523,6 +1539,7 @@ def test_build_report_payload_only_includes_first_batch_of_relationships(self):
'locale': None,
'message': 'report for lots of relationships',
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -1741,6 +1758,7 @@ def test_build_report_payload(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -1803,6 +1821,7 @@ def test_build_report_payload_with_author_and_reporter_being_the_same(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -1887,6 +1906,7 @@ def test_build_report_payload_developer_reply(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -1972,6 +1992,7 @@ def test_build_report_payload(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -2039,6 +2060,7 @@ def test_build_report_payload_with_author_and_reporter_being_the_same(self):
'locale': None,
'message': message,
'reason': None,
'considers_illegal': False,
},
'entity_type': 'amo_report',
},
Expand Down Expand Up @@ -2096,6 +2118,7 @@ def test_reason_in_attributes(self):
'locale': None,
'message': '',
'reason': "DSA: It violates Mozilla's Add-on Policies",
'considers_illegal': False,
}

def test_locale_in_attributes(self):
Expand All @@ -2108,4 +2131,21 @@ def test_locale_in_attributes(self):
'locale': 'en_US',
'message': '',
'reason': None,
'considers_illegal': False,
}

def test_considers_illegal(self):
abuse_report = AbuseReport.objects.create(
guid=addon_factory().guid,
reason=AbuseReport.REASONS.ILLEGAL,
)
assert self.cinder_class(abuse_report).get_attributes() == {
'id': str(abuse_report.pk),
'created': str(abuse_report.created),
'locale': None,
'message': '',
'reason': (
'DSA: It violates the law or contains content that violates the law'
),
'considers_illegal': True,
}
2 changes: 2 additions & 0 deletions src/olympia/abuse/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def test_addon_report_to_cinder(statsd_incr_mock):
'reason': 'DSA: It violates the law '
'or contains content that '
'violates the law',
'considers_illegal': True,
},
'entity_type': 'amo_report',
}
Expand Down Expand Up @@ -336,6 +337,7 @@ def test_addon_report_to_cinder_different_locale():
'reason': 'DSA: It violates the law '
'or contains content that '
'violates the law',
'considers_illegal': True,
},
'entity_type': 'amo_report',
}
Expand Down

0 comments on commit d431832

Please sign in to comment.