mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
added email notification about fulfilling upload request
This commit is contained in:
2
resources/js/store/modules/uploadRequest.js
vendored
2
resources/js/store/modules/uploadRequest.js
vendored
@@ -42,7 +42,7 @@ const actions = {
|
|||||||
resolve(response)
|
resolve(response)
|
||||||
|
|
||||||
// Stop loading spinner
|
// Stop loading spinner
|
||||||
if (response.data.data.attributes.status === 'active')
|
if (['active', 'filled', 'expired'].includes(response.data.data.attributes.status) )
|
||||||
commit('LOADING_STATE', { loading: false, data: [] })
|
commit('LOADING_STATE', { loading: false, data: [] })
|
||||||
|
|
||||||
commit('SET_UPLOAD_REQUEST', response.data)
|
commit('SET_UPLOAD_REQUEST', response.data)
|
||||||
|
|||||||
@@ -194,11 +194,14 @@ export default {
|
|||||||
isFolder() {
|
isFolder() {
|
||||||
return this.item && this.item.data.type === 'folder'
|
return this.item && this.item.data.type === 'folder'
|
||||||
},
|
},
|
||||||
|
userName() {
|
||||||
|
return this.uploadRequest.data.relationships.user.data.attributes.name
|
||||||
|
},
|
||||||
emptyPageTitle() {
|
emptyPageTitle() {
|
||||||
// Todo: add name into translation
|
// Todo: add name into translation
|
||||||
return {
|
return {
|
||||||
active: this.$t('{name} Request You for File Upload', {name: this.uploadRequest.data.relationships.user.data.attributes.name}),
|
active: this.$t('{name} Request You for File Upload', {name: this.userName}),
|
||||||
filled: this.$t('Upload Request for {name} was Fulfilled Successfully', {name: this.uploadRequest.data.relationships.user.data.attributes.name}),
|
filled: this.$t('Upload Request for {name} was Fulfilled Successfully', {name: this.userName}),
|
||||||
expired: this.$t('Upload Request Expired'),
|
expired: this.$t('Upload Request Expired'),
|
||||||
}[this.uploadRequest.data.attributes.status]
|
}[this.uploadRequest.data.attributes.status]
|
||||||
},
|
},
|
||||||
@@ -218,7 +221,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
uploadingDone() {
|
uploadingDone() {
|
||||||
events.$emit('confirm:open', {
|
events.$emit('confirm:open', {
|
||||||
title: this.$t('Are you sure you uploaded all files you want for {name}?', {name: this.uploadRequest.data.relationships.user.data.attributes.name}),
|
title: this.$t('Are you sure you uploaded all files you want for {name}?', {name: this.userName}),
|
||||||
message: this.$t("You won't be able to upload any files here once again."),
|
message: this.$t("You won't be able to upload any files here once again."),
|
||||||
action: {
|
action: {
|
||||||
id: this.$router.currentRoute.params.token,
|
id: this.$router.currentRoute.params.token,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\UploadRequest\Controllers;
|
namespace Domain\UploadRequest\Controllers;
|
||||||
|
|
||||||
|
use Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Domain\UploadRequest\Models\UploadRequest;
|
use Domain\UploadRequest\Models\UploadRequest;
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
@@ -15,6 +16,9 @@ class SetUploadRequestAsFilledController
|
|||||||
'status' => 'filled',
|
'status' => 'filled',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Send user notification
|
||||||
|
$uploadRequest->user->notify(new UploadRequestFulfilledNotification($uploadRequest));
|
||||||
|
|
||||||
return response(new UploadRequestResource($uploadRequest), 201);
|
return response(new UploadRequestResource($uploadRequest), 201);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ class UploadRequest extends Model
|
|||||||
return $this->hasOne(Folder::class, 'id', 'id');
|
return $this->hasOne(Folder::class, 'id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function parent(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(Folder::class, 'id', 'folder_id');
|
||||||
|
}
|
||||||
|
|
||||||
protected static function boot()
|
protected static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
namespace Domain\UploadRequest\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Domain\UploadRequest\Models\UploadRequest;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
|
||||||
|
class UploadRequestFulfilledNotification extends Notification implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
public UploadRequest $uploadRequest
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function via($notifiable)
|
||||||
|
{
|
||||||
|
return ['mail'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
|
*/
|
||||||
|
public function toMail($notifiable)
|
||||||
|
{
|
||||||
|
// TODO: add to language strings
|
||||||
|
return (new MailMessage)
|
||||||
|
->subject("Your file request was fulfilled in your '{$this->uploadRequest->parent->name}' folder")
|
||||||
|
->greeting('Hello')
|
||||||
|
->line("We are emailing you because your file request was fulfilled. Please click on the link below to show uploaded files.")
|
||||||
|
->action('Show Files', url("/platform/files/{$this->uploadRequest->id}"))
|
||||||
|
->line('Thank you for using our application!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($notifiable)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Tests\Domain\UploadRequest;
|
namespace Tests\Domain\UploadRequest;
|
||||||
|
|
||||||
|
use Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification;
|
||||||
use Storage;
|
use Storage;
|
||||||
use Notification;
|
use Notification;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -194,6 +195,8 @@ class UploadRequestTest extends TestCase
|
|||||||
'id' => $uploadRequest->id,
|
'id' => $uploadRequest->id,
|
||||||
'status' => 'filled',
|
'status' => 'filled',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
Notification::assertSentTo($user, UploadRequestFulfilledNotification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user