Skip to content

Commit

Permalink
Merge branch 'feature/admin-team-user-invites' of https://github.com/…
Browse files Browse the repository at this point in the history
…openfoodfoundation/vine into feature/admin-team-user-invites
  • Loading branch information
ok200paul committed Aug 20, 2024
2 parents 5f6babe + 259f11f commit d5a54c5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function update(string $id)

$this->responseCode = 400;
$this->message = $validator->errors()
->first();
->first();

}
else {
Expand All @@ -161,14 +161,12 @@ public function update(string $id)
$this->message = ApiResponse::RESPONSE_NOT_FOUND->value;

}
else{
else {

if($this->request->has('send_invite_email'))
{
if ($this->request->has('send_invite_email')) {
$sendInviteEmail = $this->request->get('send_invite_email');

if($sendInviteEmail)
{
if ($sendInviteEmail) {
$model->invitation_sent_at = now();
$model->save();

Expand All @@ -180,7 +178,6 @@ public function update(string $id)
$this->data = $model;
}


}
catch (Exception $e) {

Expand Down
13 changes: 4 additions & 9 deletions app/Jobs/TeamUsers/SendTeamUserInvitationEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
use App\Models\User;
use App\Notifications\Mail\TeamUsers\SendTeamUserInvitationEmailNotification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;

class SendTeamUserInvitationEmail implements ShouldQueue
Expand All @@ -18,11 +15,10 @@ class SendTeamUserInvitationEmail implements ShouldQueue

/**
* Create a new job instance.
*
* @param TeamUser $teamUser
*/
public function __construct(public TeamUser $teamUser)
{
//
}
public function __construct(public TeamUser $teamUser) {}

/**
* Execute the job.
Expand All @@ -31,8 +27,7 @@ public function handle(): void
{
$userToNotify = User::find($this->teamUser->user_id);

if($userToNotify)
{
if ($userToNotify) {
$userToNotify->current_team_id = $this->teamUser->team_id;
$userToNotify->saveQuietly();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ class SendTeamUserInvitationEmailNotification extends Notification implements Sh

/**
* Create a new notification instance.
*
* @param TeamUser $teamUser
*/
public function __construct(public TeamUser $teamUser)
{
//
}
public function __construct(public TeamUser $teamUser) {}

/**
* Get the notification's delivery channels.
*
* @param object $notifiable
*
* @return array<int, string>
*/
public function via(object $notifiable): array
Expand All @@ -33,29 +34,33 @@ public function via(object $notifiable): array

/**
* Get the mail representation of the notification.
*
* @param object $notifiable
*/
public function toMail(object $notifiable): MailMessage
{
$team = Team::find($this->teamUser->team_id);

return (new MailMessage)
->subject('You have been invited to join ' . $team->name. ' - '.config('app.name'))
->line('You have been invited to join team "' . $team->name. '" on '.config('app.name').'.')
->line('An account has been created for you on the team, but if you have never logged in to use the system, you may need to reset your password in order to log in.')
->line('Please follow the button below to reset your password and log in.')
->action('Reset your password & log in', url('/forgot-password'))
->line('Thank you for using our application!');
return (new MailMessage())
->subject('You have been invited to join ' . $team->name . ' - ' . config('app.name'))
->line('You have been invited to join team "' . $team->name . '" on ' . config('app.name') . '.')
->line('An account has been created for you on the team, but if you have never logged in to use the system, you may need to reset your password in order to log in.')
->line('Please follow the button below to reset your password and log in.')
->action('Reset your password & log in', url('/forgot-password'))
->line('Thank you for using our application!');
}

/**
* Get the array representation of the notification.
*
* @param object $notifiable
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//

];
}
}

0 comments on commit d5a54c5

Please sign in to comment.