- send notification to native user when file request was sent via email

- updated mysql dump
This commit is contained in:
Čarodej
2022-05-18 09:50:21 +02:00
parent 3c28da2613
commit aa30b519fa
9 changed files with 84 additions and 12 deletions

View File

@@ -19,7 +19,7 @@ DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
DB_MYSQLDUMP_PATH=
DB_MYSQLDUMP_PATH=/usr/bin
BROADCAST_DRIVER=null
CACHE_DRIVER=file

View File

@@ -954,5 +954,6 @@ return [
'remote_download_finished' => 'Remote upload was successfully finished',
'remote_upload_progress' => 'Uploading Remotely - {processed} / {total}',
'remote_upload_failed_count' => 'Failed: {count}',
'file_request_notify_center_description' => 'Please click on the link below and upload your files for :name.',
],
];

View File

@@ -1,7 +1,7 @@
<?php
return [
'version' => '2.1.3',
'version' => '2.2',
'is_demo' => env('APP_DEMO', false),
@@ -69,5 +69,6 @@ return [
'2_0_16',
'2_1_1',
'2_1_2',
'2_2_0',
],
];

View File

@@ -82,6 +82,20 @@
</span>
<chevron-right-icon size="16" class="text-theme vue-feather" />
</router-link>
<!--Open Link-->
<a
@click.native="closeCenter"
v-if="action && action.type === 'url'"
:target="action.params.target === 'blank' ? '_blank' : '_self'"
:href="action.params.url"
class="mt-4 flex items-center"
>
<span class="mr-2 whitespace-nowrap text-xs font-bold">
{{ action.params.button }}
</span>
<chevron-right-icon size="16" class="text-theme vue-feather" />
</a>
</div>
</article>
</template>

View File

@@ -59,7 +59,7 @@ const actions = {
.delete(`/api/file-request/${router.currentRoute.params.token}`)
.then((response) => {
commit('LOADING_STATE', { loading: false, data: [] })
commit('SET_UPLOAD_REQUEST', response.data)
commit('SET_UPLOAD_REQUEST_AS_FILLED')
})
.catch(() => this.$isSomethingWrong())
},
@@ -69,6 +69,9 @@ const mutations = {
SET_UPLOAD_REQUEST(state, payload) {
state.uploadRequest = payload
},
SET_UPLOAD_REQUEST_AS_FILLED(state) {
state.uploadRequest.data.attributes.status = 'filled'
},
}
const getters = {

View File

@@ -1,7 +1,7 @@
<?php
namespace Domain\UploadRequest\Controllers;
use Auth;
use App\Users\Models\User;
use Gate;
use Notification;
use Domain\Folders\Models\Folder;
@@ -28,7 +28,7 @@ class CreateUploadRequestController extends Controller
}
// Create upload request
$uploadRequest = Auth::user()->uploadRequest()->create([
$uploadRequest = auth()->user()->uploadRequest()->create([
'folder_id' => $request->input('folder_id'),
'email' => $request->input('email'),
'notes' => $request->input('notes'),
@@ -37,9 +37,17 @@ class CreateUploadRequestController extends Controller
// If user type email, notify by email
if ($request->has('email')) {
// Check if user exists
$user = User::where('email', $uploadRequest->email)
->first();
if ($user) {
$user->notify(new UploadRequestNotification($uploadRequest));
} else {
Notification::route('mail', $uploadRequest->email)
->notify(new UploadRequestNotification($uploadRequest));
}
}
return response()->json(new UploadRequestResource($uploadRequest), 201);
}

View File

@@ -29,7 +29,7 @@ class UploadRequestNotification extends Notification implements ShouldQueue
*/
public function via($notifiable)
{
return ['mail'];
return ['mail', 'database', 'broadcast'];
}
/**
@@ -56,13 +56,21 @@ class UploadRequestNotification extends Notification implements ShouldQueue
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
public function toArray(mixed $notifiable): array
{
return [
'category' => 'file-request',
'title' => __t('file_request_notify_title', ['name' => $this->uploadRequest->user->settings->first_name]),
'description' => __t('file_request_notify_center_description', ['name' => $this->uploadRequest->user->settings->first_name]),
'action' => [
'type' => 'url',
'params' => [
'target' => 'blank',
'url' => url("/request/{$this->uploadRequest->id}/upload"),
'button' => __t('upload_files'),
],
],
];
}
}

View File

@@ -22,6 +22,13 @@ class UpgradingVersionsController
) {
}
public function upgrade_to_2_2_0(): void
{
setEnvironmentValue([
'DB_MYSQLDUMP_PATH' => '/usr/bin',
]);
}
public function upgrade_to_2_1_2(): void
{
($this->updateLanguageStrings)([

View File

@@ -58,6 +58,36 @@ class UploadRequestTest extends TestCase
Notification::assertTimesSent(1, UploadRequestNotification::class);
}
/**
* @test
*/
public function user_create_upload_request_with_native_user_email()
{
$user = User::factory()
->hasSettings()
->create();
$recipient = User::factory()
->hasSettings()
->create();
$folder = Folder::factory()
->create([
'user_id' => $user->id,
]);
$this
->actingAs($user)
->postJson('/api/file-request', [
'folder_id' => $folder->id,
'email' => $recipient->email,
'notes' => 'Please send me your files...',
])
->assertCreated();
Notification::assertSentTo($recipient, UploadRequestNotification::class);
}
/**
* @test
*/