refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
This commit is contained in:
48
app/Notifications/EmailMessaging.php
Normal file
48
app/Notifications/EmailMessaging.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\User\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class EmailMessaging
|
||||
{
|
||||
/**
|
||||
* Get the mail representation to verify an email.
|
||||
*
|
||||
* @param User $user
|
||||
* @return MailMessage
|
||||
*/
|
||||
public static function verifyEmailMail(User $user, $verificationUrl): MailMessage
|
||||
{
|
||||
App::setLocale($user->locale);
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(trans('mail.confirmation_email_title'))
|
||||
->line(trans('mail.confirmation_email_title'))
|
||||
->line(trans('mail.confirmation_email_intro'))
|
||||
->action(trans('mail.confirmation_email_button'), $verificationUrl)
|
||||
->line(trans('mail.confirmation_email_bottom'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation to reset a password.
|
||||
*
|
||||
* @param User $user
|
||||
* @return MailMessage
|
||||
*/
|
||||
public static function resetPasswordMail(User $user, $token): MailMessage
|
||||
{
|
||||
App::setLocale($user->locale);
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(trans('mail.password_reset_title'))
|
||||
->line(trans('mail.password_reset_title'))
|
||||
->line(trans('mail.password_reset_intro'))
|
||||
->action(trans('mail.password_reset_button'), url(Str::of(config('app.url'))->ltrim('/').route('password.reset', ['token' => $token, 'email' => $user->getEmailForPasswordReset()], false)))
|
||||
->line(trans('mail.password_reset_expiration', ['count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')]))
|
||||
->line(trans('mail.password_reset_bottom'));
|
||||
}
|
||||
}
|
||||
65
app/Notifications/ExportAccountDone.php
Normal file
65
app/Notifications/ExportAccountDone.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\User\User;
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use App\Models\Account\ExportJob;
|
||||
use App\Interfaces\MailNotification;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class ExportAccountDone extends Notification implements ShouldQueue, MailNotification
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var ExportJob
|
||||
*/
|
||||
public $exportJob;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param ExportJob $exportJob
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ExportJob $exportJob)
|
||||
{
|
||||
$this->exportJob = $exportJob->withoutRelations();
|
||||
$this->afterCommit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function via()
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param User $user
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail(User $user): MailMessage
|
||||
{
|
||||
$date = Carbon::parse($this->exportJob->created_at)
|
||||
->setTimezone($user->timezone);
|
||||
|
||||
return (new MailMessage)
|
||||
->success()
|
||||
->subject(trans('mail.export_title'))
|
||||
->greeting(trans('mail.greetings', ['username' => $user->first_name]))
|
||||
->line(trans('mail.export_description', ['date' => DateHelper::getShortDate($date)]))
|
||||
->action(trans('mail.export_download'), route('settings.export.index'));
|
||||
}
|
||||
}
|
||||
62
app/Notifications/InvitationMail.php
Normal file
62
app/Notifications/InvitationMail.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use App\Models\Account\Invitation;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification as LaravelNotification;
|
||||
|
||||
class InvitationMail extends LaravelNotification implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable;
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function via()
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param Invitation $invitation
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail(Invitation $invitation): MailMessage
|
||||
{
|
||||
$user = $invitation->invitedBy;
|
||||
$acceptInvitationUrl = $this->acceptInvitationUrl($invitation);
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(trans('mail.invitation_title', ['name' => $user->name]))
|
||||
->line(trans('mail.invitation_intro', ['name' => $user->name, 'email' => $user->email]))
|
||||
->line(trans('mail.invitation_link'))
|
||||
->action(trans('mail.invitation_button'), $acceptInvitationUrl)
|
||||
->line(trans('mail.invitation_expiration', ['count' => Config::get('auth.invitation.expire', 2)]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the verification URL for the given notifiable.
|
||||
*
|
||||
* @param Invitation $invitation
|
||||
* @return string
|
||||
*/
|
||||
protected function acceptInvitationUrl(Invitation $invitation)
|
||||
{
|
||||
return URL::temporarySignedRoute(
|
||||
'invitations.accept',
|
||||
now()->addDays(Config::get('auth.invitation.expire', 2)),
|
||||
['key' => $invitation->invitation_key]
|
||||
);
|
||||
}
|
||||
}
|
||||
53
app/Notifications/NewUserAlert.php
Normal file
53
app/Notifications/NewUserAlert.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\User\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class NewUserAlert extends Notification implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable;
|
||||
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function via()
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @return MailMessage
|
||||
*/
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
return (new MailMessage)
|
||||
->subject("New registration: {$this->user->first_name} {$this->user->last_name}")
|
||||
->greeting('New registration')
|
||||
->line("User: {$this->user->first_name} {$this->user->last_name}")
|
||||
->line("ID: {$this->user->id}")
|
||||
->line("Email: {$this->user->email}");
|
||||
}
|
||||
}
|
||||
73
app/Notifications/StayInTouchEmail.php
Normal file
73
app/Notifications/StayInTouchEmail.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\User\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use App\Models\Contact\Contact;
|
||||
use App\Interfaces\MailNotification;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification as LaravelNotification;
|
||||
|
||||
class StayInTouchEmail extends LaravelNotification implements ShouldQueue, MailNotification
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Contact
|
||||
*/
|
||||
protected $contact;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Contact $contact)
|
||||
{
|
||||
$this->contact = $contact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function via()
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param User $user
|
||||
* @return MailMessage
|
||||
*/
|
||||
public function toMail(User $user): MailMessage
|
||||
{
|
||||
return (new MailMessage)
|
||||
->subject(trans('mail.stay_in_touch_subject_line', ['name' => $this->contact->name]))
|
||||
->greeting(trans('mail.greetings', ['username' => $user->first_name]))
|
||||
->line(trans_choice('mail.stay_in_touch_subject_description', $this->contact->stay_in_touch_frequency, [
|
||||
'name' => $this->contact->name,
|
||||
'frequency' => $this->contact->stay_in_touch_frequency,
|
||||
]))
|
||||
->action(trans('mail.footer_contact_info2', ['name' => $this->contact->name]), $this->contact->getLink());
|
||||
}
|
||||
|
||||
/**
|
||||
* Use in test to check the parameter notification.
|
||||
*
|
||||
* @param Contact $contact
|
||||
* @return bool
|
||||
*/
|
||||
public function assertSentFor(Contact $contact): bool
|
||||
{
|
||||
return $contact->id == $this->contact->id;
|
||||
}
|
||||
}
|
||||
83
app/Notifications/UserNotified.php
Normal file
83
app/Notifications/UserNotified.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\User\User;
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use App\Models\Contact\Contact;
|
||||
use App\Models\Contact\Reminder;
|
||||
use App\Interfaces\MailNotification;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification as LaravelNotification;
|
||||
|
||||
class UserNotified extends LaravelNotification implements ShouldQueue, MailNotification
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Reminder
|
||||
*/
|
||||
public $reminder;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
public $numberDaysBefore;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param Reminder $reminder
|
||||
* @param int|null $numberDaysBefore
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Reminder $reminder, ?int $numberDaysBefore)
|
||||
{
|
||||
$this->reminder = $reminder;
|
||||
$this->numberDaysBefore = $numberDaysBefore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function via()
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param User $user
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail(User $user): MailMessage
|
||||
{
|
||||
$contact = Contact::where('account_id', $user->account_id)
|
||||
->findOrFail($this->reminder->contact_id);
|
||||
|
||||
$message = (new MailMessage)
|
||||
->subject(trans('mail.subject_line', ['contact' => $contact->name]))
|
||||
->greeting(trans('mail.greetings', ['username' => $user->first_name]))
|
||||
->line(trans_choice('mail.notification_description', $this->numberDaysBefore, [
|
||||
'count' => $this->numberDaysBefore,
|
||||
'date' => DateHelper::getShortDate($this->reminder->calculateNextExpectedDate()),
|
||||
]))
|
||||
->line($this->reminder->title)
|
||||
->line(trans('mail.for', ['name' => $contact->name]))
|
||||
->action(trans('mail.footer_contact_info2', ['name' => $contact->name]), $contact->getLink());
|
||||
|
||||
if (! is_null($this->reminder->description)) {
|
||||
$message = $message
|
||||
->line(trans('mail.comment', ['comment' => $this->reminder->description]));
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
71
app/Notifications/UserReminded.php
Normal file
71
app/Notifications/UserReminded.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\User\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use App\Models\Contact\Contact;
|
||||
use App\Models\Contact\Reminder;
|
||||
use App\Interfaces\MailNotification;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification as LaravelNotification;
|
||||
|
||||
class UserReminded extends LaravelNotification implements ShouldQueue, MailNotification
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Reminder
|
||||
*/
|
||||
public $reminder;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Reminder $reminder)
|
||||
{
|
||||
$this->reminder = $reminder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function via()
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param User $user
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail(User $user): MailMessage
|
||||
{
|
||||
$contact = Contact::where('account_id', $user->account_id)
|
||||
->findOrFail($this->reminder->contact_id);
|
||||
|
||||
$message = (new MailMessage)
|
||||
->subject(trans('mail.subject_line', ['contact' => $contact->name]))
|
||||
->greeting(trans('mail.greetings', ['username' => $user->first_name]))
|
||||
->line(trans('mail.want_reminded_of', ['reason' => $this->reminder->title]))
|
||||
->line(trans('mail.for', ['name' => $contact->name]))
|
||||
->action(trans('mail.footer_contact_info2', ['name' => $contact->name]), $contact->getLink());
|
||||
|
||||
if (! is_null($this->reminder->description)) {
|
||||
$message = $message
|
||||
->line(trans('mail.comment', ['comment' => $this->reminder->description]));
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user