flarum / framework

Simple forum software for building great communities.
http://flarum.org/
6.24k stars 828 forks source link

Akismet False Positives Triggered by Flag Removal #3921

Closed rafaucau closed 8 months ago

rafaucau commented 8 months ago

Current Behavior

I've noticed an increased number of false-positives in Akismet. It appears that when a moderator marks a user as a spammer using the FriendsOfFlarum Spamblock extension, the spam is reported as a false-positive. This happens because when the flag is removed, the PostWasApproved event from the flarum/approval extension is triggered, which leads to the Ham submission to Akismet. I have an extension that logs all events on the forum, and it confirms my observations.

https://github.com/FriendsOfFlarum/spamblock/blob/5f5aa0ce42068342d3e78612bd75e87eebe0cb49/src/Controllers/MarkAsSpammerController.php#L97

Steps to Reproduce

  1. Wait for Akismet to identify a post as spam.
  2. Hide the identified spam post.
  3. Remove the flag from the post using DeleteFlags command from flarum/flags.

Expected Behavior

The Approval extension shouldn't trigger the PostWasApproved event when a flag is removed but only when the post is genuinely approved.

Screenshots

image

Environment

Possible Solution

I can create a PR for 1.x. However, I am uncertain whether I should fix this in flarum/approval or flarum/akismet?

https://github.com/flarum/framework/blob/f07336e204aef7876170174865e0b04c0ee7d16d/extensions/akismet/src/Listener/SubmitHam.php#L1-L45