Commit 69ef5d61 authored by Mark Harding's avatar Mark Harding

(fix): do not report if tagged as nsfw correctly

parent a8615d03
No related merge requests found
Pipeline #65712681 (#748) pending with stages
......@@ -80,6 +80,13 @@ class Manager
if ($report->getState() === 'appeal_jury_decided' && $report->isUpheld()) {
return true; // Do not accept further reports if appeal jury uphols
}
if ($report->getReasonCode() == 2
&& $report->getEntity()->getNsfw()
&& in_array($report->getSubReasonCode(), $report->getEntity()->getNsfw())
) {
return true; // If the post is NSFW and tagged, do not allow report
}
if ($report->getState() !== 'reported') {
$report->setTimestamp(time()); // Create a new report
......
......@@ -9,6 +9,7 @@ use Minds\Core\Reports\UserReports\UserReport;
use Minds\Core\Reports\UserReports\Delegates;
use Minds\Core\Reports\Report;
use Minds\Core\Reports\Manager as ReportsManager;
use Minds\Entities\Activity;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
......@@ -56,4 +57,37 @@ class ManagerSpec extends ObjectBehavior
$this->add($userReport)
->shouldReturn(true);
}
function it_should_not_double_report_marked_nsfw_repository(Report $report)
{
$entity = new Activity();
$entity->setNsfw([ 3 ]);
$report->getReasonCode()
->willReturn(2);
$report->getSubReasonCode()
->willReturn(3);
$report->getEntity()
->willReturn($entity);
$report->getState()
->willReturn('reported');
$this->repository->add(Argument::type(UserReport::class))
->shouldNotBeCalled();
$this->reportsManager->getLatestReport(Argument::type(Report::class))
->shouldBeCalled()
->willReturn($report);
$this->notificationDelegate->onAction(Argument::type(UserReport::class))
->shouldNotBeCalled();
$userReport = new UserReport;
$userReport->setReport($report);
$this->add($userReport)
->shouldReturn(true);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment