Skip to content

Commit

Permalink
Revert "Garante que o metadado spam_sent_email esteja sempre registra…
Browse files Browse the repository at this point in the history
…dos nos momentos de ação do plugin Ref.: #1"

This reverts commit a300d9d.
  • Loading branch information
erleibiazzio committed Sep 2, 2024
1 parent a300d9d commit 9c41142
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public function _init()
// Verifica se existem termos maliciosos e dispara o e-mail e a notificação
$app->hook("entity(<<{$hooks}>>).save:after", function () use ($plugin, $last_spam_sent) {
/** @var Entity $this */
$plugin->registerSpamSentEmailMetadata($this);
$users = $plugin->getAdminUsers($this);
$terms = array_merge($plugin->config['termsBlock'], $plugin->config['terms']);

Expand Down Expand Up @@ -130,7 +129,6 @@ public function _init()
// remove a permissão de publicar caso encontre termos que estão na lista de termos elegível a bloqueio
$app->hook("entity(<<{$hooks}>>).canUser(publish)", function ($user, &$result) use($plugin, &$last_spam_sent) {
/** @var Entity $this */
$plugin->registerSpamSentEmailMetadata($this);
if($plugin->getSpamTerms($this, $plugin->config['termsBlock']) && !$user->is('admin')) {
$last_spam_sent = $this->spam_sent_email ?? null;
$this->spam_sent_email = new DateTime();
Expand All @@ -141,27 +139,18 @@ public function _init()
});
}

public function register()
{
public function register() {
$entities = $this->config['entities'];
foreach($entities as $entity) {
$this->registerSpamSentEmailMetadata($entity);
}
}

/**
* @param string $entity
* @return void
*/
public function registerSpamSentEmailMetadata(string $entity): void
{
$namespace = "MapasCulturais\\Entities\\{$entity}";
foreach($entities as $entity) {
$namespace = "MapasCulturais\\Entities\\{$entity}";

$this->registerMetadata($namespace,'spam_sent_email', [
'label' => i::__('Data de envio do e-mail'),
'type' => 'DateTime',
'default' => null,
]);
$this->registerMetadata($namespace,'spam_sent_email', [
'label' => i::__('Data de envio do e-mail'),
'type' => 'DateTime',
'default' => null,
]);
}
}

public function createNotification($recipient, $entity, $spam_detections)
Expand Down

0 comments on commit 9c41142

Please sign in to comment.