Skip to content

Commit

Permalink
Code cleanup & improvements
Browse files Browse the repository at this point in the history
Co-authored-by: Roardom <[email protected]>
  • Loading branch information
Obi-Wana and Roardom committed Feb 1, 2025
1 parent a8c5fe9 commit 4ba4173
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 24 deletions.
9 changes: 0 additions & 9 deletions app/Http/Livewire/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,8 @@ final public function postComment(): void

break;
case $this->model instanceof Article:
User::find($this->model->user_id)?->notify(new NewComment($this->model, $comment));

break;
case $this->model instanceof Playlist:
User::find($this->model->user_id)?->notify(new NewComment($this->model, $comment));

break;
case $this->model instanceof TorrentRequest:
User::find($this->model->user_id)?->notify(new NewComment($this->model, $comment));

break;
case $this->model instanceof Torrent:
User::find($this->model->user_id)?->notify(new NewComment($this->model, $comment));

Expand Down
2 changes: 0 additions & 2 deletions app/Notifications/NewComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public function shouldSend(User $notifiable): bool
// 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);

case $this->model instanceof TorrentRequest:
if (!$notifiable->notification?->show_request_comment) {
return false;
Expand All @@ -76,7 +75,6 @@ public function shouldSend(User $notifiable): bool
// 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);

case $this->model instanceof Ticket:
return ! ($this->model->staff_id === $this->comment->id && $this->model->staff_id !== null)
;
Expand Down
3 changes: 0 additions & 3 deletions app/Notifications/NewCommentTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public function shouldSend(User $notifiable): bool
// 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);

case $this->model instanceof TorrentRequest:
if (!$notifiable->notification?->show_mention_request_comment) {
return false;
Expand All @@ -78,7 +77,6 @@ public function shouldSend(User $notifiable): bool
// 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);

case $this->model instanceof Ticket:
return ! ($this->model->staff_id === $this->comment->id);
case $this->model instanceof Playlist:
Expand All @@ -90,7 +88,6 @@ public function shouldSend(User $notifiable): bool
// 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);

case $this->model instanceof Collection:
break;
}
Expand Down
2 changes: 0 additions & 2 deletions app/Notifications/NewUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public function via(object $notifiable): array

/**
* Determine if the notification should be sent.
*
* @return bool
*/
public function shouldSend(User $notifiable): bool
{
Expand Down
17 changes: 9 additions & 8 deletions database/factories/UserNotificationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace Database\Factories;

use App\Models\Group;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\UserNotification;
Expand Down Expand Up @@ -57,14 +58,14 @@ public function definition(): array
'show_torrent_thank' => $this->faker->boolean(),
'show_account_follow' => $this->faker->boolean(),
'show_account_unfollow' => $this->faker->boolean(),
'json_account_groups' => $this->faker->word(),
'json_bon_groups' => $this->faker->word(),
'json_mention_groups' => $this->faker->word(),
'json_request_groups' => $this->faker->word(),
'json_torrent_groups' => $this->faker->word(),
'json_forum_groups' => $this->faker->word(),
'json_following_groups' => $this->faker->word(),
'json_subscription_groups' => $this->faker->word(),
'json_account_groups' => Group::factory()->count(3)->create()->pluck('id')->toArray(),
'json_bon_groups' => Group::factory()->count(3)->create()->pluck('id')->toArray(),
'json_mention_groups' => Group::factory()->count(3)->create()->pluck('id')->toArray(),
'json_request_groups' => Group::factory()->count(3)->create()->pluck('id')->toArray(),
'json_torrent_groups' => Group::factory()->count(3)->create()->pluck('id')->toArray(),
'json_forum_groups' => Group::factory()->count(3)->create()->pluck('id')->toArray(),
'json_following_groups' => Group::factory()->count(3)->create()->pluck('id')->toArray(),
'json_subscription_groups' => Group::factory()->count(3)->create()->pluck('id')->toArray(),
];
}
}

0 comments on commit 4ba4173

Please sign in to comment.