mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-02-06 19:48:53 -06:00
(Update) New Follower Upload Message
Ref #388 - Moved from a Private Message (PM) to a Notification
This commit is contained in:
@@ -13,9 +13,12 @@
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class Follow extends Model
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* Belongs To A User
|
||||
*
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Notifications\NewFollowerUpload;
|
||||
use App\Torrent;
|
||||
use App\PrivateMessage;
|
||||
use App\Wish;
|
||||
use App\Follow;
|
||||
use App\User;
|
||||
use App\Achievements\UserMadeUpload;
|
||||
use App\Achievements\UserMade25Uploads;
|
||||
use App\Achievements\UserMade50Uploads;
|
||||
@@ -61,14 +63,7 @@ class TorrentHelper
|
||||
$followers = Follow::where('target_id', '=', $torrent->user_id)->get();
|
||||
if ($followers) {
|
||||
foreach ($followers as $follower) {
|
||||
// Send Private Message
|
||||
$pm = new PrivateMessage;
|
||||
$pm->sender_id = 1;
|
||||
$pm->receiver_id = $follower->user_id;
|
||||
$pm->subject = "New Upload Notice: {$torrent->name}";
|
||||
$pm->message = "We just wanted to let you know that the user, {$torrent->user->username}, whom you are following has uploaded a new torrent to {$appname}! You can view it [url={$appurl}/torrents/" . $torrent->slug . "." . $torrent->id . "] here. [/url]
|
||||
[color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]";
|
||||
$pm->save();
|
||||
User::find($follower->user_id)->notify(new NewFollowerUpload($torrent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
66
app/Notifications/NewFollowerUpload.php
Normal file
66
app/Notifications/NewFollowerUpload.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
* @author HDVinnie
|
||||
*/
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
use App\Torrent;
|
||||
|
||||
class NewFollowerUpload extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public $torrent;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @param Post $post
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Torrent $torrent)
|
||||
{
|
||||
$this->torrent = $torrent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['database'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
$appurl = config('app.url');
|
||||
return [
|
||||
'title' => "New Follower Upload Notice",
|
||||
'body' => "We just wanted to let you know that the user, {$this->torrent->user->username} , whom you are following has uploaded has uploaded {$this->torrent->name}",
|
||||
'url' => "{$appurl}/torrents/{$this->torrent->slug}.{$this->torrent->id}"
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user