Commit e40d62d3 authored by Mark Harding's avatar Mark Harding

(chore): spam check comments

parent 85de3a3c
No related merge requests found
Pipeline #63469182 passed with stages
in 8 minutes and 17 seconds
......@@ -43,6 +43,9 @@ class Manager
/** @var EntitiesBuilder */
protected $entitiesBuilder;
/** @var Security\Spam */
protected $spam;
/**
* Manager constructor.
* @param Repository|null $repository
......@@ -55,7 +58,8 @@ class Manager
$threadNotifications = null,
$createEventDispatcher = null,
$countCache = null,
$entitiesBuilder = null
$entitiesBuilder = null,
$spam = null
)
{
$this->repository = $repository ?: new Repository();
......@@ -66,6 +70,7 @@ class Manager
$this->createEventDispatcher = $createEventDispatcher ?: new Delegates\CreateEventDispatcher();
$this->countCache = $countCache ?: new Delegates\CountCache();
$this->entitiesBuilder = $entitiesBuilder ?: Di::_()->get('EntitiesBuilder');
$this->spam = $spam ?: Di::_()->get('Security\Spam');
}
public function get($entity_guid, $parent_path, $guid)
......@@ -130,6 +135,8 @@ class Manager
throw new \Exception();
}
$this->spam->check($comment);
if (
!$comment->getOwnerGuid() ||
!$this->acl->interact($entity, $owner)
......
......@@ -12,6 +12,7 @@ use Minds\Core\Comments\Repository;
use Minds\Core\EntitiesBuilder;
use Minds\Core\Luid;
use Minds\Core\Security\ACL;
use Minds\Core\Security\Spam;
use Minds\Entities\Entity;
use Minds\Entities\User;
use Minds\Exceptions\BlockedUserException;
......@@ -44,6 +45,9 @@ class ManagerSpec extends ObjectBehavior
/** @var EntitiesBuilder */
protected $entitiesBuilder;
/** @var Security\Spam */
protected $spam;
function let(
Repository $repository,
LegacyRepository $legacyRepository,
......@@ -52,7 +56,8 @@ class ManagerSpec extends ObjectBehavior
ThreadNotifications $threadNotifications,
CreateEventDispatcher $createEventDispatcher,
CountCache $countCache,
EntitiesBuilder $entitiesBuilder
EntitiesBuilder $entitiesBuilder,
Spam $spam
) {
$this->beConstructedWith(
$repository,
......@@ -62,7 +67,8 @@ class ManagerSpec extends ObjectBehavior
$threadNotifications,
$createEventDispatcher,
$countCache,
$entitiesBuilder
$entitiesBuilder,
$spam
);
$this->repository = $repository;
......@@ -73,6 +79,7 @@ class ManagerSpec extends ObjectBehavior
$this->createEventDispatcher = $createEventDispatcher;
$this->countCache = $countCache;
$this->entitiesBuilder = $entitiesBuilder;
$this->spam = $spam;
}
function it_is_initializable()
......
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