mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-05 10:11:25 -05:00
update: pass types directly into some notifications
Only the request notifications for now, but they should all get done with time.
This commit is contained in:
@@ -82,7 +82,7 @@ class ApprovedRequestFillController extends Controller
|
||||
}
|
||||
|
||||
if ($filler->acceptsNotification($approver, $filler, 'request', 'show_request_fill_approve')) {
|
||||
$filler->notify(new NewRequestFillApprove('torrent', $approver->username, $torrentRequest));
|
||||
$filler->notify(new NewRequestFillApprove($torrentRequest));
|
||||
}
|
||||
|
||||
return to_route('requests.show', ['torrentRequest' => $torrentRequest])
|
||||
|
||||
@@ -46,7 +46,7 @@ class BountyController extends Controller
|
||||
|
||||
$user->decrement('seedbonus', $request->integer('seedbonus'));
|
||||
|
||||
$torrentRequest->bounties()->create(['user_id' => $user->id] + $request->validated());
|
||||
$bounty = $torrentRequest->bounties()->create(['user_id' => $user->id] + $request->validated());
|
||||
|
||||
$torrentRequest->votes++;
|
||||
$torrentRequest->bounty += $request->integer('seedbonus');
|
||||
@@ -83,11 +83,10 @@ class BountyController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
$sender = $request->boolean('anon') ? 'Anonymous' : $request->user()->username;
|
||||
$requester = $torrentRequest->user;
|
||||
|
||||
if ($requester->acceptsNotification($request->user(), $requester, 'request', 'show_request_bounty')) {
|
||||
$requester->notify(new NewRequestBounty('torrent', $sender, $request->integer('seedbonus'), $torrentRequest));
|
||||
$requester->notify(new NewRequestBounty($bounty));
|
||||
}
|
||||
|
||||
return to_route('requests.show', ['torrentRequest' => $torrentRequest])
|
||||
|
||||
@@ -36,17 +36,16 @@ class ClaimController extends Controller
|
||||
->withErrors(trans('request.already-claimed'));
|
||||
}
|
||||
|
||||
$torrentRequest->claim()->create(['user_id' => $request->user()->id] + $request->validated());
|
||||
$claim = $torrentRequest->claim()->create(['user_id' => $request->user()->id] + $request->validated());
|
||||
|
||||
$torrentRequest->update([
|
||||
'claimed' => true,
|
||||
]);
|
||||
|
||||
$claimer = $request->boolean('anon') ? 'Anonymous' : $request->user()->username;
|
||||
$requester = $torrentRequest->user;
|
||||
|
||||
if ($requester->acceptsNotification($request->user(), $requester, 'request', 'show_request_claim')) {
|
||||
$requester->notify(new NewRequestClaim('torrent', $claimer, $torrentRequest));
|
||||
$requester->notify(new NewRequestClaim($claim));
|
||||
}
|
||||
|
||||
return to_route('requests.show', ['torrentRequest' => $torrentRequest])
|
||||
|
||||
@@ -50,7 +50,7 @@ class RequestFillController extends Controller
|
||||
$requester = $torrentRequest->user;
|
||||
|
||||
if ($requester->acceptsNotification($request->user(), $requester, 'request', 'show_request_fill')) {
|
||||
$requester->notify(new NewRequestFill('torrent', $sender, $torrentRequest));
|
||||
$requester->notify(new NewRequestFill($torrentRequest));
|
||||
}
|
||||
|
||||
return to_route('requests.show', ['torrentRequest' => $torrentRequest])
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\TorrentRequest;
|
||||
use App\Models\TorrentRequestBounty;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Notification;
|
||||
@@ -25,7 +25,7 @@ class NewRequestBounty extends Notification implements ShouldQueue
|
||||
/**
|
||||
* NewRequestBounty Constructor.
|
||||
*/
|
||||
public function __construct(public string $type, public string $sender, public int $amount, public TorrentRequest $torrentRequest)
|
||||
public function __construct(public TorrentRequestBounty $bounty)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -46,10 +46,12 @@ class NewRequestBounty extends Notification implements ShouldQueue
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
$this->bounty->load('user');
|
||||
|
||||
return [
|
||||
'title' => $this->sender.' Has Added A Bounty Of '.$this->amount.' To A Requested Torrent',
|
||||
'body' => $this->sender.' has added a bounty to one of your Requested Torrents '.$this->torrentRequest->name,
|
||||
'url' => sprintf('/requests/%s', $this->torrentRequest->id),
|
||||
'title' => ($this->bounty->anon ? 'Anonymous' : $this->bounty->user->username).' Has Added A Bounty Of '.$this->bounty->seedbonus.' To A Requested Torrent',
|
||||
'body' => ($this->bounty->anon ? 'Anonymous' : $this->bounty->user->username).' has added a bounty to one of your Requested Torrents '.$this->bounty->request->name,
|
||||
'url' => sprintf('/requests/%s', $this->bounty->requests_id),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\TorrentRequest;
|
||||
use App\Models\TorrentRequestClaim;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Notification;
|
||||
@@ -25,7 +25,7 @@ class NewRequestClaim extends Notification implements ShouldQueue
|
||||
/**
|
||||
* NewRequestClaim Constructor.
|
||||
*/
|
||||
public function __construct(public string $type, public string $sender, public TorrentRequest $torrentRequest)
|
||||
public function __construct(public TorrentRequestClaim $claim)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -46,10 +46,12 @@ class NewRequestClaim extends Notification implements ShouldQueue
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
$this->claim->load('user');
|
||||
|
||||
return [
|
||||
'title' => $this->sender.' Has Claimed One Of Your Requested Torrents',
|
||||
'body' => $this->sender.' has claimed your Requested Torrent '.$this->torrentRequest->name,
|
||||
'url' => sprintf('/requests/%s', $this->torrentRequest->id),
|
||||
'title' => ($this->claim->anon ? 'Anonymous' : $this->claim->user->username).' Has Claimed One Of Your Requested Torrents',
|
||||
'body' => ($this->claim->anon ? 'Anonymous' : $this->claim->user->username).' has claimed your Requested Torrent '.$this->claim->request->name,
|
||||
'url' => sprintf('/requests/%s', $this->claim->request_id),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class NewRequestFill extends Notification implements ShouldQueue
|
||||
/**
|
||||
* NewRequestFill Constructor.
|
||||
*/
|
||||
public function __construct(public string $type, public string $sender, public TorrentRequest $torrentRequest)
|
||||
public function __construct(public TorrentRequest $torrentRequest)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -46,9 +46,11 @@ class NewRequestFill extends Notification implements ShouldQueue
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
$this->torrentRequest->load('filler');
|
||||
|
||||
return [
|
||||
'title' => $this->sender.' Has Filled One Of Your Torrent Requests',
|
||||
'body' => $this->sender.' has filled one of your Requested Torrents '.$this->torrentRequest->name,
|
||||
'title' => ($this->torrentRequest->filled_anon ? 'Anonymous' : $this->torrentRequest->filler->username).' Has Filled One Of Your Torrent Requests',
|
||||
'body' => ($this->torrentRequest->filled_anon ? 'Anonymous' : $this->torrentRequest->filler->username).' has filled one of your Requested Torrents '.$this->torrentRequest->name,
|
||||
'url' => sprintf('/requests/%s', $this->torrentRequest->id),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class NewRequestFillApprove extends Notification implements ShouldQueue
|
||||
/**
|
||||
* NewRequestFillApprove Constructor.
|
||||
*/
|
||||
public function __construct(public string $type, public string $sender, public TorrentRequest $torrentRequest)
|
||||
public function __construct(public TorrentRequest $torrentRequest)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,9 +47,11 @@ class NewRequestFillApprove extends Notification implements ShouldQueue
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
if ($this->torrentRequest->anon == 0) {
|
||||
$this->torrentRequest->load('approver');
|
||||
|
||||
return [
|
||||
'title' => $this->sender.' Has Approved Your Fill Of A Requested Torrent',
|
||||
'body' => $this->sender.' has approved your fill of Requested Torrent '.$this->torrentRequest->name,
|
||||
'title' => $this->torrentRequest->approver->username.' Has Approved Your Fill Of A Requested Torrent',
|
||||
'body' => $this->torrentRequest->approver->username.' has approved your fill of Requested Torrent '.$this->torrentRequest->name,
|
||||
'url' => sprintf('/requests/%s', $this->torrentRequest->id),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user