mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-07 19:49:59 -05:00
fix: notification setting logic when notification doesn't exist
This commit is contained in:
@@ -53,17 +53,17 @@ class NewBon extends Notification implements ShouldQueue
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_bon_gift) {
|
||||
if ($notifiable->notification?->show_bon_gift === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->gift->sender->group_id, $notifiable->notification->json_bon_groups, true);
|
||||
return ! \in_array($this->gift->sender->group_id, $notifiable->notification?->json_bon_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,28 +64,28 @@ class NewComment extends Notification
|
||||
}
|
||||
|
||||
// Evaluate general settings
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Evaluate model based settings
|
||||
switch (true) {
|
||||
case $this->model instanceof Torrent:
|
||||
if (!$notifiable->notification?->show_torrent_comment) {
|
||||
if ($notifiable->notification?->show_torrent_comment === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->comment->user->group_id, $notifiable->notification->json_torrent_groups, true);
|
||||
return ! \in_array($this->comment->user->group_id, $notifiable->notification?->json_torrent_groups ?? [], true);
|
||||
case $this->model instanceof TorrentRequest:
|
||||
if (!$notifiable->notification?->show_request_comment) {
|
||||
if ($notifiable->notification?->show_request_comment === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->comment->user->group_id, $notifiable->notification->json_request_groups, true);
|
||||
return ! \in_array($this->comment->user->group_id, $notifiable->notification?->json_request_groups ?? [], true);
|
||||
case $this->model instanceof Ticket:
|
||||
return ! ($this->model->staff_id === $this->comment->id && $this->model->staff_id !== null)
|
||||
;
|
||||
|
||||
@@ -66,39 +66,39 @@ class NewCommentTag extends Notification implements ShouldQueue
|
||||
}
|
||||
|
||||
// Evaluate general settings
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Evaluate model based settings
|
||||
switch (true) {
|
||||
case $this->model instanceof Torrent:
|
||||
if (!$notifiable->notification?->show_mention_torrent_comment) {
|
||||
if ($notifiable->notification?->show_mention_torrent_comment === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->comment->user->group_id, $notifiable->notification->json_mention_groups, true);
|
||||
return ! \in_array($this->comment->user->group_id, $notifiable->notification?->json_mention_groups ?? [], true);
|
||||
case $this->model instanceof TorrentRequest:
|
||||
if (!$notifiable->notification?->show_mention_request_comment) {
|
||||
if ($notifiable->notification?->show_mention_request_comment === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->comment->user->group_id, $notifiable->notification->json_mention_groups, true);
|
||||
return ! \in_array($this->comment->user->group_id, $notifiable->notification?->json_mention_groups ?? [], true);
|
||||
case $this->model instanceof Ticket:
|
||||
return ! ($this->model->staff_id === $this->comment->id);
|
||||
case $this->model instanceof Playlist:
|
||||
case $this->model instanceof Article:
|
||||
if (!$notifiable->notification?->show_mention_article_comment) {
|
||||
if ($notifiable->notification?->show_mention_article_comment === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->comment->user->group_id, $notifiable->notification->json_mention_groups, true);
|
||||
return ! \in_array($this->comment->user->group_id, $notifiable->notification?->json_mention_groups ?? [], true);
|
||||
case $this->model instanceof Collection:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -47,17 +47,17 @@ class NewFollow extends Notification implements ShouldQueue
|
||||
*/
|
||||
public function shouldSend(User $notifiable): bool
|
||||
{
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_account_follow) {
|
||||
if ($notifiable->notification?->show_account_follow === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->follower->group_id, $notifiable->notification->json_following_groups, true);
|
||||
return ! \in_array($this->follower->group_id, $notifiable->notification?->json_following_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,7 +64,7 @@ class NewPost extends Notification implements ShouldQueue
|
||||
default => 'show_forum_topic',
|
||||
};
|
||||
|
||||
if (!$notifiable->notification?->$targetNotification) {
|
||||
if ($notifiable->notification?->$targetNotification === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class NewPost extends Notification implements ShouldQueue
|
||||
return true;
|
||||
}
|
||||
|
||||
return ! \in_array($this->post->user->group_id, $notifiable->notification->$targetGroup, true);
|
||||
return ! \in_array($this->post->user->group_id, $notifiable->notification?->$targetGroup ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,17 +58,17 @@ class NewPostTag extends Notification implements ShouldQueue
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_mention_forum_post) {
|
||||
if ($notifiable->notification?->show_mention_forum_post === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->post->user->group_id, $notifiable->notification->json_mention_groups, true);
|
||||
return ! \in_array($this->post->user->group_id, $notifiable->notification?->json_mention_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,17 +53,17 @@ class NewRequestBounty extends Notification implements ShouldQueue
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_request_bounty) {
|
||||
if ($notifiable->notification?->show_request_bounty === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->bounty->user->group_id, $notifiable->notification->json_request_groups, true);
|
||||
return ! \in_array($this->bounty->user->group_id, $notifiable->notification?->json_request_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,17 +53,17 @@ class NewRequestClaim extends Notification implements ShouldQueue
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_request_claim) {
|
||||
if ($notifiable->notification?->show_request_claim === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->claim->user->group_id, $notifiable->notification->json_request_groups, true);
|
||||
return ! \in_array($this->claim->user->group_id, $notifiable->notification?->json_request_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,17 +53,17 @@ class NewRequestFill extends Notification implements ShouldQueue
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_request_fill) {
|
||||
if ($notifiable->notification?->show_request_fill === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->torrentRequest->filler->group_id, $notifiable->notification->json_request_groups, true);
|
||||
return ! \in_array($this->torrentRequest->filler->group_id, $notifiable->notification?->json_request_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,17 +53,17 @@ class NewRequestFillApprove extends Notification implements ShouldQueue
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_request_fill_approve) {
|
||||
if ($notifiable->notification?->show_request_fill_approve === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->torrentRequest->approver->group_id, $notifiable->notification->json_request_groups, true);
|
||||
return ! \in_array($this->torrentRequest->approver->group_id, $notifiable->notification?->json_request_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,17 +53,17 @@ class NewRequestFillReject extends Notification implements ShouldQueue
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_request_fill_reject) {
|
||||
if ($notifiable->notification?->show_request_fill_reject === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->torrentRequest->user->group_id, $notifiable->notification->json_request_groups, true);
|
||||
return ! \in_array($this->torrentRequest->user->group_id, $notifiable->notification?->json_request_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,17 +53,17 @@ class NewRequestUnclaim extends Notification implements ShouldQueue
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_request_unclaim) {
|
||||
if ($notifiable->notification?->show_request_unclaim === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->torrentRequestClaim->user->group_id, $notifiable->notification->json_request_groups, true);
|
||||
return ! \in_array($this->torrentRequestClaim->user->group_id, $notifiable->notification?->json_request_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,17 +48,17 @@ class NewTopic extends Notification implements ShouldQueue
|
||||
*/
|
||||
public function shouldSend(User $notifiable): bool
|
||||
{
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_subscription_forum) {
|
||||
if ($notifiable->notification?->show_subscription_forum === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->user->group_id, $notifiable->notification->json_subscription_groups, true);
|
||||
return ! \in_array($this->user->group_id, $notifiable->notification?->json_subscription_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,17 +47,17 @@ class NewUnfollow extends Notification implements ShouldQueue
|
||||
*/
|
||||
public function shouldSend(User $notifiable): bool
|
||||
{
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_account_unfollow) {
|
||||
if ($notifiable->notification?->show_account_unfollow === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->unfollower->group_id, $notifiable->notification->json_account_groups, true);
|
||||
return ! \in_array($this->unfollower->group_id, $notifiable->notification?->json_account_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,17 +52,17 @@ class NewUpload extends Notification implements ShouldQueue
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($notifiable->notification?->block_notifications == 1) {
|
||||
if ($notifiable->notification?->block_notifications === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$notifiable->notification?->show_following_upload) {
|
||||
if ($notifiable->notification?->show_following_upload === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the sender's group ID is found in the "Block all notifications from the selected groups" array,
|
||||
// the expression will return false.
|
||||
return ! \in_array($this->torrent->user->group_id, $notifiable->notification->json_following_groups, true);
|
||||
return ! \in_array($this->torrent->user->group_id, $notifiable->notification?->json_following_groups ?? [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user