From 9c4114249aa731cf290fb14ef5879a52f1c6dfff Mon Sep 17 00:00:00 2001 From: erleibiazzio Date: Mon, 2 Sep 2024 17:00:05 -0300 Subject: [PATCH] =?UTF-8?q?Revert=20"Garante=20que=20o=20metadado=20spam?= =?UTF-8?q?=5Fsent=5Femail=20esteja=20sempre=20registrados=20nos=20momento?= =?UTF-8?q?s=20de=20a=C3=A7=C3=A3o=20do=20plugin=20Ref.:=20#1"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit a300d9dedbd8c8eca9863531bbe6af768ada1458. --- Plugin.php | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/Plugin.php b/Plugin.php index 29e12d3..6182ee6 100644 --- a/Plugin.php +++ b/Plugin.php @@ -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']); @@ -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(); @@ -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)