Skip to content

Give ContentAction classes an action attribute#24785

Merged
diox merged 3 commits intomozilla:masterfrom
diox:abuse-actions-class-action-attribute
Apr 21, 2026
Merged

Give ContentAction classes an action attribute#24785
diox merged 3 commits intomozilla:masterfrom
diox:abuse-actions-class-action-attribute

Conversation

@diox
Copy link
Copy Markdown
Member

@diox diox commented Apr 20, 2026

This will allow us to have some logic inside the content action classes that depend on the action being executed by that class, e.g. we could have ContentActionDisableAddon look at past AMO_DISABLE_ADDON actions when processing and deciding not to do it again.

Pre-requisite for mozilla/addons#16123

@diox diox force-pushed the abuse-actions-class-action-attribute branch from 07ee7c0 to 754dd51 Compare April 20, 2026 13:08
@diox diox requested a review from eviljeff April 20, 2026 13:08
def test_notify_reporters_reporters_provided(self):
action = self.ActionClass(self.decision)
action.notify_reporters(reporter_abuse_reports=[self.abuse_report_no_auth])
action_helper = self.ActionClass(self.decision)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to make the tests in this file more consistent by:

  • Naming the content action class variable ActionClass everywhere
  • Naming the variable with the instance of the action class action_helper
  • Naming the variable with the actual action action

That's why I ended up with +261-252 in this test file.

Copy link
Copy Markdown
Member

@eviljeff eviljeff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .action change is sensible; the .target_versions change seems to be introducing footguns with different values for target_versions on self and self.decision :/

Comment thread src/olympia/abuse/actions.py
Comment thread src/olympia/abuse/actions.py
Comment thread src/olympia/abuse/actions.py Outdated
Comment thread src/olympia/abuse/actions.py Outdated
diox added 2 commits April 21, 2026 11:41
This will allow us to have some logic inside the content action
classes that depend on the action being executed by that class,
e.g. we could have ContentActionDisableAddon look at past
AMO_DISABLE_ADDON actions when processing and deciding not to
do it again.

Similarly having an actual target_versions attribute rather than
a property depending on the decision will allow us to have logic
that depends on the target versions inside the action class but
still allow the target versions considered for that logic to be
set by the caller before a decision has been made.
@diox diox force-pushed the abuse-actions-class-action-attribute branch from 754dd51 to 19d7979 Compare April 21, 2026 10:44
@diox diox force-pushed the abuse-actions-class-action-attribute branch from 19d7979 to 3a5e6fe Compare April 21, 2026 10:45
@diox diox requested a review from eviljeff April 21, 2026 12:24
@diox diox changed the title Give ContentAction classes an action (and target_versions) attribute Give ContentAction classes an action attribute Apr 21, 2026
)

# There should be at least as many DECISION_ACTIONS as there are classes,
# except for AMO_ESCALATE_ADDON (which is obsolete) and AMO_REQUEUE (which
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just thinking out loud at this point, but we should probably create an empty class for AMO_REQUEUE (that possibly raises in it's process_action), and delete AMO_ESCALATE_ADDON.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I almost did but decided it was not worth spending the time on that right now...

@diox diox merged commit 17e4522 into mozilla:master Apr 21, 2026
79 of 172 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants