mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-28 11:00:39 +00:00
team invitation notification with broadcasting
This commit is contained in:
@@ -65,7 +65,7 @@ class GetDashboardDataController extends Controller
|
||||
)
|
||||
->groupBy('created_at')
|
||||
->get(['upload', 'download', 'created_at'])
|
||||
->each(fn($record) => $record->created_at = format_date($record->created_at, 'd. M. Y'))
|
||||
->each(fn ($record) => $record->created_at = format_date($record->created_at, 'd. M. Y'))
|
||||
->keyBy('created_at');
|
||||
|
||||
$mappedTrafficRecords = mapTrafficRecords($trafficRecords);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Files\Actions;
|
||||
|
||||
class StoreFileExifMetadataAction
|
||||
@@ -9,33 +8,31 @@ class StoreFileExifMetadataAction
|
||||
// Get exif metadata
|
||||
$exif_data = get_image_meta_data($file);
|
||||
|
||||
if($exif_data) {
|
||||
|
||||
if ($exif_data) {
|
||||
// Conver array to collection
|
||||
$data = json_decode(json_encode($exif_data)) ;
|
||||
$data = json_decode(json_encode($exif_data));
|
||||
|
||||
$item->exif()->create([
|
||||
'date_time_original' => $data->DateTimeOriginal ?? null,
|
||||
'artist' => $data->OwnerName ?? null,
|
||||
'width' => $data->COMPUTED->Width ?? null,
|
||||
'height' => $data->COMPUTED->Height ?? null,
|
||||
'x_resolution' => $data->XResolution ?? null,
|
||||
'y_resolution' => $data->YResolution ?? null,
|
||||
'color_space' => $data->ColorSpace ?? null,
|
||||
'camera' => $data->Make ?? null,
|
||||
'model' => $data->Model ?? null,
|
||||
'aperture_value' => $data->ApertureValue ?? null,
|
||||
'exposure_time' => $data->ExposureTime ?? null,
|
||||
'focal_length' => $data->FocalLength ?? null,
|
||||
'iso' => $data->ISOSpeedRatings ?? null,
|
||||
'aperture_f_number' => $data->COMPUTED->ApertureFNumber ?? null,
|
||||
'ccd_width' => $data->COMPUTED->CCDWidth ?? null,
|
||||
'longitude' => $data->GPSLongitude ?? null,
|
||||
'latitude' => $data->GPSLatitude ?? null,
|
||||
'longitude_ref' => $data->GPSLongitudeRef ?? null,
|
||||
'latitude_ref' => $data->GPSLatitudeRef ?? null
|
||||
'date_time_original' => $data->DateTimeOriginal ?? null,
|
||||
'artist' => $data->OwnerName ?? null,
|
||||
'width' => $data->COMPUTED->Width ?? null,
|
||||
'height' => $data->COMPUTED->Height ?? null,
|
||||
'x_resolution' => $data->XResolution ?? null,
|
||||
'y_resolution' => $data->YResolution ?? null,
|
||||
'color_space' => $data->ColorSpace ?? null,
|
||||
'camera' => $data->Make ?? null,
|
||||
'model' => $data->Model ?? null,
|
||||
'aperture_value' => $data->ApertureValue ?? null,
|
||||
'exposure_time' => $data->ExposureTime ?? null,
|
||||
'focal_length' => $data->FocalLength ?? null,
|
||||
'iso' => $data->ISOSpeedRatings ?? null,
|
||||
'aperture_f_number' => $data->COMPUTED->ApertureFNumber ?? null,
|
||||
'ccd_width' => $data->COMPUTED->CCDWidth ?? null,
|
||||
'longitude' => $data->GPSLongitude ?? null,
|
||||
'latitude' => $data->GPSLatitude ?? null,
|
||||
'longitude_ref' => $data->GPSLongitudeRef ?? null,
|
||||
'latitude_ref' => $data->GPSLatitudeRef ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Traffic\Actions\RecordUploadAction;
|
||||
use App\Users\Exceptions\InvalidUserActionException;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Domain\Files\Actions\StoreFileExifMetadataAction;
|
||||
|
||||
class UploadFileAction
|
||||
{
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Files\Models;
|
||||
namespace Domain\Files\Models;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Exif extends Model
|
||||
{
|
||||
@@ -22,7 +20,7 @@ class Exif extends Model
|
||||
|
||||
protected $casts = [
|
||||
'longitude' => 'array',
|
||||
'latitude' => 'array',
|
||||
'latitude' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -226,10 +226,10 @@ class File extends Model
|
||||
$file->id = (string) Str::uuid();
|
||||
});
|
||||
|
||||
static::deleting(function($file) {
|
||||
if($file->isForceDeleting()) {
|
||||
static::deleting(function ($file) {
|
||||
if ($file->isForceDeleting()) {
|
||||
$file->exif()->forceDelete();
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class FileResource extends JsonResource
|
||||
],
|
||||
],
|
||||
]),
|
||||
$this->mergeWhen($this->exif, fn() => [
|
||||
$this->mergeWhen($this->exif, fn () => [
|
||||
'exif' => [
|
||||
'data' => [
|
||||
'type' => 'exif',
|
||||
@@ -88,8 +88,8 @@ class FileResource extends JsonResource
|
||||
'latitude' => formatGPSCoordinates($this->exif->latitude, $this->exif->latitude_ref),
|
||||
],
|
||||
],
|
||||
]
|
||||
])
|
||||
],
|
||||
]),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Notifications\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class FlushUserNotificationsController extends Controller
|
||||
{
|
||||
@@ -20,4 +19,4 @@ class FlushUserNotificationsController extends Controller
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Notifications\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
@@ -13,4 +12,4 @@ class GetUserNotificationsController extends Controller
|
||||
auth()->user()->notifications
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Notifications\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class MarkUserNotificationsAsReadController extends Controller
|
||||
{
|
||||
@@ -20,4 +19,4 @@ class MarkUserNotificationsAsReadController extends Controller
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
namespace Domain\Notifications\Events;
|
||||
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
class TestUpdate implements ShouldBroadcast
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Notifications\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Settings\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class DownloadLogController extends Controller
|
||||
@@ -22,7 +21,9 @@ class DownloadLogController extends Controller
|
||||
|
||||
// Download log
|
||||
return response()->download(
|
||||
storage_path("logs/$log"), $log, [
|
||||
storage_path("logs/$log"),
|
||||
$log,
|
||||
[
|
||||
'Accept-Ranges' => 'bytes',
|
||||
'Content-Type' => 'text/plain',
|
||||
'Content-Length' => File::size($logPath),
|
||||
@@ -31,4 +32,4 @@ class DownloadLogController extends Controller
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
namespace Domain\Settings\Controllers;
|
||||
|
||||
use Artisan;
|
||||
use Domain\Settings\Requests\StoreStorageCredentialsRequest;
|
||||
use Illuminate\Http\Response;
|
||||
use Domain\Settings\Requests\StoreEmailCredentialsRequest;
|
||||
use Domain\Settings\Requests\StoreStorageCredentialsRequest;
|
||||
|
||||
class StoreStorageCredentialsController
|
||||
{
|
||||
@@ -22,7 +21,7 @@ class StoreStorageCredentialsController
|
||||
'FILESYSTEM_DISK' => 'local',
|
||||
],
|
||||
's3' => [
|
||||
'FILESYSTEM_DISK' => 's3',
|
||||
'FILESYSTEM_DISK' => 's3',
|
||||
'S3_ACCESS_KEY_ID' => $request->input('storage.key') ?? null,
|
||||
'S3_SECRET_ACCESS_KEY' => $request->input('storage.secret') ?? null,
|
||||
'S3_DEFAULT_REGION' => $request->input('storage.region') ?? null,
|
||||
|
||||
@@ -20,7 +20,7 @@ class StoreEnvironmentSettingsController extends Controller
|
||||
'FILESYSTEM_DISK' => 'local',
|
||||
],
|
||||
's3' => [
|
||||
'FILESYSTEM_DISK' => 's3',
|
||||
'FILESYSTEM_DISK' => 's3',
|
||||
'S3_ACCESS_KEY_ID' => $request->input('storage.key') ?? null,
|
||||
'S3_SECRET_ACCESS_KEY' => $request->input('storage.secret') ?? null,
|
||||
'S3_DEFAULT_REGION' => $request->input('storage.region') ?? null,
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace Domain\Teams\Actions;
|
||||
|
||||
use DB;
|
||||
use App\Users\Models\User;
|
||||
use Domain\Teams\Models\TeamFolderInvitation;
|
||||
|
||||
class ClearActionInInvitationNotificationAction
|
||||
{
|
||||
public function __invoke(User $user, TeamFolderInvitation $invitation): void
|
||||
{
|
||||
if (is_demo_account()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get notification with invitation
|
||||
$notification = DB::table('notifications')
|
||||
->where('notifiable_id', $user->id)
|
||||
->where('data', 'LIKE', "%{$invitation->id}%")
|
||||
->first();
|
||||
|
||||
if ($notification) {
|
||||
// Get data
|
||||
$data = json_decode($notification->data);
|
||||
|
||||
// Clear action object
|
||||
$data->action = null;
|
||||
|
||||
// Update notification
|
||||
DB::table('notifications')
|
||||
->where('notifiable_id', $user->id)
|
||||
->where('data', 'LIKE', "%{$invitation->id}%")
|
||||
->update([
|
||||
'data' => json_encode($data),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Domain\Teams\Actions;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Spatie\QueueableAction\QueueableAction;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
@@ -25,9 +26,19 @@ class InviteMembersIntoTeamFolderAction
|
||||
'inviter_id' => $folder->user_id,
|
||||
]);
|
||||
|
||||
// Invite user
|
||||
Notification::route('mail', $member['email'])
|
||||
->notify(new InvitationIntoTeamFolder($folder, $invitation));
|
||||
// Get user
|
||||
$user = User::where('email', $member['email'])->first();
|
||||
|
||||
// Invite native user
|
||||
if ($user) {
|
||||
$user->notify(new InvitationIntoTeamFolder($folder, $invitation));
|
||||
}
|
||||
|
||||
// Invite guest
|
||||
if (! $user) {
|
||||
Notification::route('mail', $member['email'])
|
||||
->notify(new InvitationIntoTeamFolder($folder, $invitation));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace Domain\Teams\Controllers;
|
||||
|
||||
use Domain\Folders\Resources\FolderResource;
|
||||
use Illuminate\Http\Response;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
@@ -8,6 +8,7 @@ use Domain\Teams\Models\TeamFolderMember;
|
||||
use Domain\Teams\Models\TeamFolderInvitation;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Domain\Teams\Resources\TeamInvitationResource;
|
||||
use Domain\Teams\Actions\ClearActionInInvitationNotificationAction;
|
||||
|
||||
class InvitationsController extends Controller
|
||||
{
|
||||
@@ -21,22 +22,31 @@ class InvitationsController extends Controller
|
||||
}
|
||||
|
||||
public function update(
|
||||
TeamFolderInvitation $invitation
|
||||
): ResponseFactory | Response {
|
||||
$user = User::where('email', $invitation->email);
|
||||
TeamFolderInvitation $invitation,
|
||||
ClearActionInInvitationNotificationAction $clearActionInInvitationNotification,
|
||||
): ResponseFactory|Response {
|
||||
$user = User::where('email', $invitation->email)
|
||||
->first();
|
||||
|
||||
if ($user) {
|
||||
if (is_demo_account()) {
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
if ($user->exists()) {
|
||||
$invitation->accept();
|
||||
|
||||
// Store team member
|
||||
TeamFolderMember::create([
|
||||
'user_id' => $user->first()->id,
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $invitation->parent_id,
|
||||
'permission' => $invitation->permission,
|
||||
]);
|
||||
|
||||
// Clear action in existing notification
|
||||
$clearActionInInvitationNotification($user, $invitation);
|
||||
}
|
||||
|
||||
if ($user->doesntExist()) {
|
||||
if (! $user) {
|
||||
$invitation->update([
|
||||
'status' => 'waiting-for-registration',
|
||||
]);
|
||||
@@ -46,10 +56,24 @@ class InvitationsController extends Controller
|
||||
}
|
||||
|
||||
public function destroy(
|
||||
TeamFolderInvitation $invitation
|
||||
): ResponseFactory | Response {
|
||||
TeamFolderInvitation $invitation,
|
||||
ClearActionInInvitationNotificationAction $clearActionInInvitationNotification,
|
||||
): ResponseFactory|Response {
|
||||
$invitation->reject();
|
||||
|
||||
// Get user from invitation
|
||||
$user = User::where('email', $invitation->email)
|
||||
->first();
|
||||
|
||||
// Clear action in existing notification
|
||||
if ($user) {
|
||||
if (is_demo_account()) {
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
$clearActionInInvitationNotification($user, $invitation);
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class TeamFoldersController extends Controller
|
||||
->get();
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
$folders = Folder::where('parent_id', null)
|
||||
->where('team_folder', true)
|
||||
->where('user_id', Auth::id())
|
||||
|
||||
@@ -5,10 +5,11 @@ use App\Users\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Domain\Teams\Models\TeamFolderInvitation;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class InvitationIntoTeamFolder extends Notification
|
||||
class InvitationIntoTeamFolder extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
@@ -23,7 +24,7 @@ class InvitationIntoTeamFolder extends Notification
|
||||
*/
|
||||
public function via(): array
|
||||
{
|
||||
return ['mail'];
|
||||
return ['mail', 'database', 'broadcast'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,4 +52,22 @@ class InvitationIntoTeamFolder extends Notification
|
||||
->action('Join & Create an Account', url('/team-folder-invitation', ['id' => $this->invitation->id]))
|
||||
->salutation("Regards, $appTitle");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*/
|
||||
public function toArray(mixed $notifiable): array
|
||||
{
|
||||
return [
|
||||
'type' => 'team-invitation',
|
||||
'title' => 'New Team Invitation',
|
||||
'description' => "{$this->invitation->inviter->settings->name} invite you to join into Team Folder.",
|
||||
'action' => [
|
||||
'type' => 'invitation',
|
||||
'params' => [
|
||||
'id' => $this->invitation->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\UploadRequest\Controllers;
|
||||
|
||||
use Auth;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace Domain\UploadRequest\Controllers;
|
||||
|
||||
use Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification;
|
||||
use Illuminate\Http\Response;
|
||||
use Domain\UploadRequest\Models\UploadRequest;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Domain\UploadRequest\Resources\UploadRequestResource;
|
||||
use Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification;
|
||||
|
||||
class SetUploadRequestAsFilledController
|
||||
{
|
||||
@@ -17,7 +17,7 @@ class SetUploadRequestAsFilledController
|
||||
]);
|
||||
|
||||
// Send user notification
|
||||
if (!is_demo_account()) {
|
||||
if (! is_demo_account()) {
|
||||
$uploadRequest->user->notify(new UploadRequestFulfilledNotification($uploadRequest));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\UploadRequest\Controllers;
|
||||
|
||||
use DB;
|
||||
@@ -14,7 +13,8 @@ class UploadFilesForUploadRequestController
|
||||
{
|
||||
public function __construct(
|
||||
private UploadFileAction $uploadFile,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileNotFoundException
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\UploadRequest\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -19,7 +18,8 @@ class UploadRequestFulfilledNotification extends Notification implements ShouldQ
|
||||
*/
|
||||
public function __construct(
|
||||
public UploadRequest $uploadRequest
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
@@ -38,7 +38,7 @@ class UploadRequestFulfilledNotification extends Notification implements ShouldQ
|
||||
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.")
|
||||
->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!');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\UploadRequest\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
@@ -28,9 +28,9 @@ class UploadRequestResource extends JsonResource
|
||||
'id' => $this->user->id,
|
||||
'type' => 'user',
|
||||
'attributes' => [
|
||||
'name' => $this->user->settings->first_name,
|
||||
'name' => $this->user->settings->first_name,
|
||||
'color' => $this->user->settings->color,
|
||||
'avatar' => $this->user->settings->avatar,
|
||||
'avatar' => $this->user->settings->avatar,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user