Commit 8f04f993 authored by Mark Harding's avatar Mark Harding

(feat): strike email

1 merge request!100Epic/reporting and moderation
Pipeline #62356210 failed with stages
in 4 minutes and 12 seconds
Your <?php echo $vars['type'] ?> has been **<?php echo $vars['action']; ?>** because it was determined to violate our Content Policy. To appeal this decision to a jury of your peers, please [log in](https://www.minds.com/settings/reported-content) and submit an appeal from the Reported Content section of your settings. More can be learned about how the Appeals process works [here](https://www.minds.com/content-policy).
......@@ -5,9 +5,10 @@
namespace Minds\Core\Reports\Strikes\Delegates;
use Minds\Core\Di\Di;
use Minds\Core\Reports\Verdict\Verdict;
use Minds\Core\Reports\Strikes\Strike;
use Minds\Core\Events\EventsDispatcher;
use Minds\Common\Urn;
use Minds\Core\Email\Campaigns\Custom;
class EmailDelegate
{
......@@ -37,9 +38,30 @@ class EmailDelegate
$entityGuid = $this->urn->setUrn($entityUrn)->getNss();
$entity = $this->entitiesBuilder->single($entityGuid);
$owner = $entity->type === 'user' ? $entity : $this->entitiesBuilder->single($entity->getOwnerGuid());
$type = $entity->type;
if ($type === 'object') {
$type = $entity->subtype;
}
$action = 'removed';
switch ($strike->getReasonCode()) {
case 2:
$action = 'marked as nsfw';
break;
}
$this->campaign->setUser($owner);
$this->campaign->setTemplate('moderation-strike.md');
$this->campaign->setSubject('You have received a strike');
$this->campaign->setVars([
'type' => $type,
'action' => $action,
//'reason' => $reason,
]);
$this->campaign->send();
}
}
......@@ -22,13 +22,18 @@ class Manager
/** @var ReportsManager */
private $reportsManager;
/** @var Delegates\EmailDelegate */
private $emailDelegate;
public function __construct(
$repository = null,
$reportsManager = null
$reportsManager = null,
$emailDelegate = null
)
{
$this->repository = $repository ?: new Repository;
$this->reportsManager = $reportsManager ?: new ReportsManager();
$this->emailDelegate = $emailDelaget ?: new Delegates\EmailDelegate();
}
/**
......@@ -84,7 +89,11 @@ class Manager
*/
public function add($strike)
{
return $this->repository->add($strike);
$success = $this->repository->add($strike);
$this->emailDelegate->onStrike($strike);
return $success;
}
/**
......
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