queueable email sharing

This commit is contained in:
Peter Papp
2021-07-23 18:13:58 +02:00
parent c2771be913
commit f8cb879e42
9 changed files with 103 additions and 16 deletions

View File

@@ -31,6 +31,7 @@
"madnest/madzipper": "^1.1.0",
"spatie/laravel-backup": "^6.16.1",
"spatie/laravel-query-builder": "^3.5",
"spatie/laravel-queueable-action": "^2.12",
"spatie/laravel-tail": "^4.3.3",
"teamtnt/laravel-scout-tntsearch-driver": "^11.5.0.0",
"vimeo/psalm": "^4.8.1"

86
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "50eedc067d37499da24bee315d3008da",
"content-hash": "e4a7f5591e1c7216ee06ab20feba09d3",
"packages": [
{
"name": "amphp/amp",
@@ -7284,6 +7284,90 @@
],
"time": "2021-07-05T14:17:44+00:00"
},
{
"name": "spatie/laravel-queueable-action",
"version": "2.12.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-queueable-action.git",
"reference": "27c156a8b41d2d5ef191594fc91f2bed73f4c2e1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-queueable-action/zipball/27c156a8b41d2d5ef191594fc91f2bed73f4c2e1",
"reference": "27c156a8b41d2d5ef191594fc91f2bed73f4c2e1",
"shasum": ""
},
"require": {
"laravel/framework": "^8.0",
"php": "^7.4|^8.0"
},
"require-dev": {
"mockery/mockery": "^1.4",
"orchestra/testbench": "^4.0|^5.0|^6.0",
"phpunit/phpunit": "^8.4|^9.3"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Spatie\\QueueableAction\\QueueableActionServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Spatie\\QueueableAction\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Brent Roose",
"email": "brent@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
{
"name": "Alex Vanderbist",
"email": "alex@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
{
"name": "Sebastian De Deyne",
"email": "sebastian@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
},
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Queueable action support in Laravel",
"homepage": "https://github.com/spatie/laravel-queueable-action",
"keywords": [
"laravel-queueable-action",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-queueable-action/issues",
"source": "https://github.com/spatie/laravel-queueable-action/tree/2.12.0"
},
"funding": [
{
"url": "https://spatie.be/open-source/support-us",
"type": "custom"
}
],
"time": "2021-06-01T11:45:12+00:00"
},
{
"name": "spatie/laravel-tail",
"version": "4.3.3",

View File

@@ -121,7 +121,8 @@ class Folder extends Model
public function getCreatedAtAttribute(): string
{
return format_date(
set_time_by_user_timezone($this->attributes['created_at']), __t('time')
set_time_by_user_timezone($this->attributes['created_at']),
__t('time')
);
}
@@ -135,7 +136,8 @@ class Folder extends Model
}
return format_date(
set_time_by_user_timezone($this->attributes['deleted_at']), __t('time')
set_time_by_user_timezone($this->attributes['deleted_at']),
__t('time')
);
}

View File

@@ -1,20 +1,21 @@
<?php
namespace Domain\Sharing\Actions;
use Spatie\QueueableAction\QueueableAction;
use Illuminate\Support\Facades\Notification;
use Domain\Sharing\Notifications\SharedSendViaEmail;
class SendViaEmailAction
{
use QueueableAction;
public function __invoke(
array $emails,
string $token,
): void {
foreach ($emails as $email) {
Notification::route('mail', $email)
->notify(
new SharedSendViaEmail($token)
);
->notify(new SharedSendViaEmail($token));
}
}
}

View File

@@ -41,9 +41,9 @@ class ShareController extends Controller
// Send shared link via email
if ($request->has('emails')) {
($sendLinkToEmailAction)(
$request->input('emails'),
$shared->token
$sendLinkToEmailAction->onQueue()->execute(
emails: $request->input('emails'),
token: $shared->token
);
}

View File

@@ -17,7 +17,7 @@ class ShareViaEmailController extends Controller
Request $request,
string $token,
): Response {
($this->sendLinkToEmailAction)(
($this->sendLinkToEmailAction)->onQueue()->execute(
emails: $request->input('emails'),
token: $token,
);

View File

@@ -927,7 +927,7 @@ if (! function_exists('set_time_by_user_timezone')) {
/**
* Set time by user timezone GMT
*/
function set_time_by_user_timezone(string $time): string|Carbon
function set_time_by_user_timezone(string $time): string | Carbon
{
$user = Auth::user();

View File

@@ -1,11 +1,11 @@
<?php
namespace Tests\Feature\Accounts;
use Domain\Folders\Models\Folder;
use Storage;
use Notification;
use Tests\TestCase;
use App\Users\Models\User;
use Domain\Folders\Models\Folder;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\URL;
use Illuminate\Auth\Notifications\VerifyEmail;
@@ -42,17 +42,17 @@ class UserAccountTest extends TestCase
Folder::factory(Folder::class)
->create([
'user_id' => $user->id,
'user_id' => $user->id,
'created_at' => now(),
]);
$user->settings()->update([
'timezone' => '2.0'
'timezone' => '2.0',
]);
$this
->actingAs($user)
->getJson("/api/browse/folders/undefined")
->getJson('/api/browse/folders/undefined')
->assertJsonFragment([
'created_at' => '01. January. 2021 at 02:00',
]);

View File

@@ -1,5 +1,4 @@
<?php
namespace Tests\Domain\Files;
use Storage;