#124: Converted the comment-related e-mails to be queueable
This commit is contained in:
parent
e794f99ead
commit
4905dd1caa
@ -6,14 +6,13 @@ use App\Album;
|
||||
use App\Facade\Theme;
|
||||
use App\Facade\UserConfig;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\PhotoCommentApproved;
|
||||
use App\Mail\PhotoCommentApprovedUser;
|
||||
use App\Mail\PhotoCommentRepliedTo;
|
||||
use App\Notifications\PhotoCommentApproved;
|
||||
use App\Notifications\PhotoCommentApprovedUser;
|
||||
use App\Notifications\PhotoCommentRepliedTo;
|
||||
use App\Photo;
|
||||
use App\PhotoComment;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class PhotoCommentController extends Controller
|
||||
@ -344,16 +343,17 @@ class PhotoCommentController extends Controller
|
||||
*/
|
||||
private function notifyAlbumOwnerAndPoster(Album $album, Photo $photo, PhotoComment $comment)
|
||||
{
|
||||
/** @var User $owner */
|
||||
$owner = $album->user;
|
||||
|
||||
Mail::to($owner)->send(new PhotoCommentApproved($owner, $album, $photo, $comment));
|
||||
$owner->notify(new PhotoCommentApproved($album, $photo, $comment));
|
||||
|
||||
// Also send a notification to the comment poster
|
||||
$poster = new User();
|
||||
$poster->name = $comment->authorDisplayName();
|
||||
$poster->email = $comment->authorEmail();
|
||||
|
||||
Mail::to($poster)->send(new PhotoCommentApprovedUser($poster, $album, $photo, $comment));
|
||||
$poster->notify(new PhotoCommentApprovedUser($album, $photo, $comment));
|
||||
|
||||
// Send notification to the parent comment owner (if this is a reply)
|
||||
if (!is_null($comment->parent_comment_id))
|
||||
@ -369,7 +369,7 @@ class PhotoCommentController extends Controller
|
||||
$parentPoster->name = $parentComment->authorDisplayName();
|
||||
$parentPoster->email = $parentComment->authorEmail();
|
||||
|
||||
Mail::to($parentPoster)->send(new PhotoCommentRepliedTo($parentPoster, $album, $photo, $comment));
|
||||
$parentPoster->notify(new PhotoCommentRepliedTo($album, $photo, $comment));
|
||||
}
|
||||
}
|
||||
}
|
@ -8,21 +8,16 @@ use App\Facade\UserConfig;
|
||||
use App\Helpers\DbHelper;
|
||||
use App\Helpers\PermissionsHelper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StorePhotoCommentRequest;
|
||||
use App\Mail\ModeratePhotoComment;
|
||||
use App\Mail\PhotoCommentApproved;
|
||||
use App\Mail\PhotoCommentApprovedUser;
|
||||
use App\Mail\PhotoCommentRepliedTo;
|
||||
use App\Permission;
|
||||
use App\Notifications\ModeratePhotoComment;
|
||||
use App\Notifications\PhotoCommentApproved;
|
||||
use App\Notifications\PhotoCommentApprovedUser;
|
||||
use App\Notifications\PhotoCommentRepliedTo;
|
||||
use App\Photo;
|
||||
use App\PhotoComment;
|
||||
use App\User;
|
||||
use App\UserActivity;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class PhotoCommentController extends Controller
|
||||
@ -315,7 +310,7 @@ class PhotoCommentController extends Controller
|
||||
/** @var User $moderator */
|
||||
foreach ($moderators as $moderator)
|
||||
{
|
||||
Mail::to($moderator)->send(new ModeratePhotoComment($moderator, $album, $photo, $comment));
|
||||
$moderator->notify(new ModeratePhotoComment($album, $photo, $comment));
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,16 +322,17 @@ class PhotoCommentController extends Controller
|
||||
*/
|
||||
private function notifyAlbumOwnerAndPoster(Album $album, Photo $photo, PhotoComment $comment)
|
||||
{
|
||||
/** @var User $owner */
|
||||
$owner = $album->user;
|
||||
|
||||
Mail::to($owner)->send(new PhotoCommentApproved($owner, $album, $photo, $comment));
|
||||
$owner->notify(new PhotoCommentApproved($album, $photo, $comment));
|
||||
|
||||
// Also send a notification to the comment poster
|
||||
$poster = new User();
|
||||
$poster->name = $comment->authorDisplayName();
|
||||
$poster->email = $comment->authorEmail();
|
||||
|
||||
Mail::to($poster)->send(new PhotoCommentApprovedUser($poster, $album, $photo, $comment));
|
||||
$poster->notify(new PhotoCommentApprovedUser($album, $photo, $comment));
|
||||
|
||||
// Send notification to the parent comment owner (if this is a reply)
|
||||
if (!is_null($comment->parent_comment_id))
|
||||
@ -352,7 +348,7 @@ class PhotoCommentController extends Controller
|
||||
$parentPoster->name = $parentComment->authorDisplayName();
|
||||
$parentPoster->email = $parentComment->authorEmail();
|
||||
|
||||
Mail::to($parentPoster)->send(new PhotoCommentRepliedTo($parentPoster, $album, $photo, $comment));
|
||||
$parentPoster->notify(new PhotoCommentRepliedTo($album, $photo, $comment));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,9 @@ use App\Photo;
|
||||
use App\PhotoComment;
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ModeratePhotoComment extends Mailable
|
||||
class ModeratePhotoComment extends MailableBase
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
|
@ -8,14 +8,13 @@ use App\Photo;
|
||||
use App\PhotoComment;
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* E-mail notification to the owner of an album that is sent when a new comment has been approved in their album.
|
||||
* @package App\Mail
|
||||
*/
|
||||
class PhotoCommentApproved extends Mailable
|
||||
class PhotoCommentApproved extends MailableBase
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
|
@ -8,14 +8,13 @@ use App\Photo;
|
||||
use App\PhotoComment;
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* E-mail notification to the poster of a comment that is sent when it has been approved.
|
||||
* @package App\Mail
|
||||
*/
|
||||
class PhotoCommentApprovedUser extends Mailable
|
||||
class PhotoCommentApprovedUser extends MailableBase
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
|
48
app/Notifications/ModeratePhotoComment.php
Normal file
48
app/Notifications/ModeratePhotoComment.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Album;
|
||||
use App\Mail\MailableBase;
|
||||
use App\Mail\ModeratePhotoComment as ModeratePhotoCommentMailable;
|
||||
use App\Photo;
|
||||
use App\PhotoComment;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class ModeratePhotoComment extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
use DatabaseEmailNotification;
|
||||
|
||||
private $album;
|
||||
private $comment;
|
||||
private $photo;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Album $album, Photo $photo, PhotoComment $comment)
|
||||
{
|
||||
$this->album = $album;
|
||||
$this->photo = $photo;
|
||||
$this->comment = $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage|MailableBase
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$mailable = new ModeratePhotoCommentMailable($notifiable, $this->album, $this->photo, $this->comment);
|
||||
|
||||
$this->setPropertiesOnMailable($mailable, $notifiable);
|
||||
|
||||
return $mailable;
|
||||
}
|
||||
}
|
48
app/Notifications/PhotoCommentApproved.php
Normal file
48
app/Notifications/PhotoCommentApproved.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Album;
|
||||
use App\Mail\MailableBase;
|
||||
use App\Mail\PhotoCommentApproved as PhotoCommentApprovedMailable;
|
||||
use App\Photo;
|
||||
use App\PhotoComment;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class PhotoCommentApproved extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
use DatabaseEmailNotification;
|
||||
|
||||
private $album;
|
||||
private $comment;
|
||||
private $photo;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Album $album, Photo $photo, PhotoComment $comment)
|
||||
{
|
||||
$this->album = $album;
|
||||
$this->photo = $photo;
|
||||
$this->comment = $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage|MailableBase
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$mailable = new PhotoCommentApprovedMailable($notifiable, $this->album, $this->photo, $this->comment);
|
||||
|
||||
$this->setPropertiesOnMailable($mailable, $notifiable);
|
||||
|
||||
return $mailable;
|
||||
}
|
||||
}
|
48
app/Notifications/PhotoCommentApprovedUser.php
Normal file
48
app/Notifications/PhotoCommentApprovedUser.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Album;
|
||||
use App\Mail\MailableBase;
|
||||
use App\Mail\PhotoCommentApprovedUser as PhotoCommentApprovedUserMailable;
|
||||
use App\Photo;
|
||||
use App\PhotoComment;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class PhotoCommentApprovedUser extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
use DatabaseEmailNotification;
|
||||
|
||||
private $album;
|
||||
private $comment;
|
||||
private $photo;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Album $album, Photo $photo, PhotoComment $comment)
|
||||
{
|
||||
$this->album = $album;
|
||||
$this->photo = $photo;
|
||||
$this->comment = $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage|MailableBase
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$mailable = new PhotoCommentApprovedUserMailable($notifiable, $this->album, $this->photo, $this->comment);
|
||||
|
||||
$this->setPropertiesOnMailable($mailable, $notifiable);
|
||||
|
||||
return $mailable;
|
||||
}
|
||||
}
|
48
app/Notifications/PhotoCommentRepliedTo.php
Normal file
48
app/Notifications/PhotoCommentRepliedTo.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Album;
|
||||
use App\Mail\MailableBase;
|
||||
use App\Mail\PhotoCommentRepliedTo as PhotoCommentRepliedToMailable;
|
||||
use App\Photo;
|
||||
use App\PhotoComment;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class PhotoCommentRepliedTo extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
use DatabaseEmailNotification;
|
||||
|
||||
private $album;
|
||||
private $comment;
|
||||
private $photo;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Album $album, Photo $photo, PhotoComment $comment)
|
||||
{
|
||||
$this->album = $album;
|
||||
$this->photo = $photo;
|
||||
$this->comment = $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage|MailableBase
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$mailable = new PhotoCommentRepliedToMailable($notifiable, $this->album, $this->photo, $this->comment);
|
||||
|
||||
$this->setPropertiesOnMailable($mailable, $notifiable);
|
||||
|
||||
return $mailable;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user