Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Akismet False Positives Triggered by Flag Removal #3921

Closed
rafaucau opened this issue Nov 3, 2023 · 0 comments · Fixed by #3930
Closed

Akismet False Positives Triggered by Flag Removal #3921

rafaucau opened this issue Nov 3, 2023 · 0 comments · Fixed by #3930
Labels

Comments

@rafaucau
Copy link
Contributor

rafaucau commented Nov 3, 2023

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

  • Flarum version: 1.8.3
  • PHP version: 8.2

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?

<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Akismet\Listener;
use Flarum\Akismet\Akismet;
use Flarum\Approval\Event\PostWasApproved;
class SubmitHam
{
/**
* @var Akismet
*/
protected $akismet;
public function __construct(Akismet $akismet)
{
$this->akismet = $akismet;
}
public function handle(PostWasApproved $event)
{
if (! $this->akismet->isConfigured()) {
return;
}
$post = $event->post;
if ($post->is_spam) {
$this->akismet
->withContent($post->content)
->withIp($post->ip_address)
->withAuthorName($post->user->username)
->withAuthorEmail($post->user->email)
->withType($post->number === 1 ? 'forum-post' : 'reply')
->submitHam();
}
}
}

@rafaucau rafaucau changed the title Akismet Integration Issue - High False Positives Akismet False Positives Triggered by Flag Removal Nov 3, 2023
@SychO9 SychO9 modified the milestone: 1.8.1 Nov 17, 2023
@rafaucau rafaucau reopened this Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants