Skip to content

Commit 89d5c82

Browse files
committed
fix: filter unverified comments in panel and notifications
1 parent f637af0 commit 89d5c82

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

lib/KommentModeration.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ class KommentModeration
88
{
99
private $storage;
1010

11-
public function __construct(private ?string $storageType = null)
11+
public function __construct(private ?string $storageType = null, private ?bool $filterUnverified = null,)
1212
{
1313
$this->storage = StorageFactory::create($storageType);
14+
$this->filterUnverified = $filterUnverified ?? option('mauricerenck.komments.spam.verification.filterUnverfied', true);
1415
}
1516

1617
public function getComment(string $id): mixed
@@ -135,7 +136,10 @@ public function replyToComment(string $id, array $formData)
135136
public function getPendingComments(?bool $published = false, ?string $type = null): mixed
136137
{
137138
$comments = $this->storage->getCommentsOfSite();
138-
$filteredComments = $comments->filterBy('published', $published)->sortBy('updatedAt', 'desc');
139+
$filters = $this->filterUnverified ? 'VERIFIED' : 'PENDING';
140+
$filters = $published ? 'PUBLISHED' : $filters;
141+
142+
$filteredComments = $comments->filterBy('verification_status', $filters)->sortBy('updatedAt', 'desc');
139143

140144
if ($type) {
141145
$filteredComments = $filteredComments->filterBy('type', $type);

lib/KommentReceiver.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public function __construct(
1717
private ?bool $debug = null,
1818
private ?array $spamKeywords = null,
1919
private ?array $spamPhrases = null,
20-
private ?bool $verificationEnabled = null,
21-
private ?bool $verificationTtl = null,
22-
private ?bool $verificationSecret = null
2320
) {
2421
$this->autoPublish = $autoPublish ?? option('mauricerenck.komments.moderation.autoPublish', []);
2522
$this->autoPublishVerified = $autoPublishVerified ?? option('mauricerenck.komments.moderation.publish-verified', false);

site/config/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
'delete' => false,
4848
'verification' => [
4949
'enabled' => true,
50+
'filterUnverfied' => true,
5051
'ttl' => 1,
5152
'secret' => 'my-extremly-secure-secret',
5253
'autoPublish' => false,

vendor/composer/installed.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php return array(
22
'root' => array(
33
'name' => 'mauricerenck/komments',
4-
'pretty_version' => '3.7.1',
5-
'version' => '3.7.1.0',
4+
'pretty_version' => '3.7.3',
5+
'version' => '3.7.3.0',
66
'reference' => null,
77
'type' => 'kirby-plugin',
88
'install_path' => __DIR__ . '/../../',
@@ -29,8 +29,8 @@
2929
'dev_requirement' => false,
3030
),
3131
'mauricerenck/komments' => array(
32-
'pretty_version' => '3.7.1',
33-
'version' => '3.7.1.0',
32+
'pretty_version' => '3.7.3',
33+
'version' => '3.7.3.0',
3434
'reference' => null,
3535
'type' => 'kirby-plugin',
3636
'install_path' => __DIR__ . '/../../',

0 commit comments

Comments
 (0)