Skip to content

Commit

Permalink
Ajustada o save do status da entidade para lixeira Ref.: #1
Browse files Browse the repository at this point in the history
  • Loading branch information
israelmelo committed Sep 6, 2024
1 parent 599e7f3 commit a892d70
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,12 @@ public function _init()
/** @var Entity $this */
if($plugin->getSpamTerms($this, $plugin->config['termsBlock'])) {
$this->spamBlock = true;
$this->setStatus(-10);
}
});

// 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) {
$app->hook("entity(<<{$hooks}>>).save:after", function () use ($plugin, $last_spam_sent, $app) {
/** @var Entity $this */

$users = $plugin->getAdminUsers($this);
$terms = array_merge($plugin->config['termsBlock'], $plugin->config['terms']);

Expand All @@ -151,6 +149,12 @@ public function _init()
$notification->message = $message;
$notification->save(true);
}

if($this->spamBlock) {
$conn = $app->em->getConnection();
$table = $plugin->dictTable($this);
$conn->executeQuery("UPDATE {$table} SET status = -10 WHERE id = {$this->id}");
}
});

// Garante que o termo encontrado fique salvo e o e-mail seja disparado
Expand Down

0 comments on commit a892d70

Please sign in to comment.