Skip to content

Commit

Permalink
Stop banned or suspended users from notification creation on posts an…
Browse files Browse the repository at this point in the history
…d entries (#1007)
  • Loading branch information
debounced authored Aug 8, 2024
1 parent 4c7182f commit 8949499
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -828,11 +828,21 @@ public function softDelete(): void
$this->visibility = self::VISIBILITY_SOFT_DELETED;
}

public function isSoftDeleted(): bool
{
return self::VISIBILITY_SOFT_DELETED === $this->visibility;
}

public function trash(): void
{
$this->visibility = self::VISIBILITY_TRASHED;
}

public function isTrashed(): bool
{
return self::VISIBILITY_TRASHED === $this->visibility;
}

public function restore(): void
{
$this->visibility = VisibilityInterface::VISIBILITY_VISIBLE;
Expand Down
4 changes: 4 additions & 0 deletions src/Service/Notification/EntryCommentNotificationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function __construct(
// @todo check if author is on the block list
public function sendCreated(ContentInterface $subject): void
{
if ($subject->user->isBanned || $subject->user->isDeleted || $subject->user->isTrashed() || $subject->user->isSoftDeleted()) {
return;
}

/**
* @var EntryComment $subject
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Service/Notification/EntryNotificationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public function __construct(
// @todo check if author is on the block list
public function sendCreated(ContentInterface $subject): void
{
if ($subject->user->isBanned || $subject->user->isDeleted || $subject->user->isTrashed() || $subject->user->isSoftDeleted()) {
return;
}

/*
* @var Entry $subject
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Service/Notification/PostCommentNotificationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function __construct(
// @todo check if author is on the block list
public function sendCreated(ContentInterface $subject): void
{
if ($subject->user->isBanned || $subject->user->isDeleted || $subject->user->isTrashed() || $subject->user->isSoftDeleted()) {
return;
}

/**
* @var PostComment $subject
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Service/Notification/PostNotificationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public function __construct(
// @todo check if author is on the block list
public function sendCreated(ContentInterface $subject): void
{
if ($subject->user->isBanned || $subject->user->isDeleted || $subject->user->isTrashed() || $subject->user->isSoftDeleted()) {
return;
}

/*
* @var Post $subject
*/
Expand Down

0 comments on commit 8949499

Please sign in to comment.