mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-29 03:10:51 +00:00
team invitation notification with broadcasting
This commit is contained in:
@@ -898,7 +898,7 @@ class SetupDevEnvironment extends Command
|
||||
])
|
||||
->each(function ($file) use ($users, $financeDocumentsFolder, $otherDocuments) {
|
||||
$user = $users[rand(0, 2)];
|
||||
$folder = [$financeDocumentsFolder, $otherDocuments][rand(0,1)];
|
||||
$folder = [$financeDocumentsFolder, $otherDocuments][rand(0, 1)];
|
||||
|
||||
$basename = Str::random(12) . '-' . $file['basename'];
|
||||
|
||||
@@ -1120,7 +1120,7 @@ class SetupDevEnvironment extends Command
|
||||
'Smart Watch 3D Device Pack for Element 3D.mp4',
|
||||
])
|
||||
->each(function ($file) use ($users, $videos) {
|
||||
$user = $users[rand(0,1)];
|
||||
$user = $users[rand(0, 1)];
|
||||
|
||||
$basename = Str::random(12) . '-' . $file;
|
||||
|
||||
@@ -1151,7 +1151,7 @@ class SetupDevEnvironment extends Command
|
||||
->each(function ($file) use ($users, $folder) {
|
||||
$basename = Str::random(12) . '-' . $file['basename'];
|
||||
|
||||
$user = $users[rand(0,1)];
|
||||
$user = $users[rand(0, 1)];
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Fruitcake\Cors\HandleCors;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Users\Controllers\Authentication;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Users\Resources;
|
||||
|
||||
use Domain\Notifications\Resources\NotificationCollection;
|
||||
use Domain\Folders\Resources\FolderCollection;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Users\Actions\FormatUsageEstimatesAction;
|
||||
use Domain\Notifications\Resources\NotificationCollection;
|
||||
use VueFileManager\Subscription\Domain\Credits\Resources\BalanceResource;
|
||||
use VueFileManager\Subscription\Domain\CreditCards\Resources\CreditCardCollection;
|
||||
use VueFileManager\Subscription\Domain\BillingAlerts\Resources\BillingAlertResource;
|
||||
@@ -49,16 +48,16 @@ class UserResource extends JsonResource
|
||||
'settings' => new SettingsResource($this->settings),
|
||||
'favourites' => new FolderCollection($this->favouriteFolders),
|
||||
'creditCards' => new CreditCardCollection($this->creditCards),
|
||||
$this->mergeWhen($this->hasSubscription(), fn() => [
|
||||
$this->mergeWhen($this->hasSubscription(), fn () => [
|
||||
'subscription' => new SubscriptionResource($this->subscription),
|
||||
]),
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn() => [
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
|
||||
'balance' => new BalanceResource($this->balance),
|
||||
]),
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn() => [
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
|
||||
'alert' => new BillingAlertResource($this->billingAlert),
|
||||
]),
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn() => [
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
|
||||
'failedPayments' => new FailedPaymentsCollection($this->failedPayments),
|
||||
]),
|
||||
],
|
||||
@@ -70,13 +69,13 @@ class UserResource extends JsonResource
|
||||
'canCreateTeamFolder' => $this->canCreateTeamFolder(),
|
||||
'canInviteTeamMembers' => $this->canInviteTeamMembers(),
|
||||
],
|
||||
$this->mergeWhen($isFixedSubscription, fn() => [
|
||||
$this->mergeWhen($isFixedSubscription, fn () => [
|
||||
'limitations' => $this->limitations->summary(),
|
||||
]),
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn() => [
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
|
||||
'usages' => $this->getUsageEstimates(),
|
||||
]),
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn() => [
|
||||
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
|
||||
'totalDebt' => [
|
||||
'formatted' => format_currency($this->failedPayments->sum('amount'), $this->subscription->plan->currency),
|
||||
'amount' => $this->failedPayments->sum('amount'),
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Users\Resources;
|
||||
|
||||
use ByteUnits\Metric;
|
||||
use Carbon\CarbonPeriod;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -23,18 +20,18 @@ class UserStorageResource extends JsonResource
|
||||
|
||||
$totalCapacity = match (get_settings('subscription_type')) {
|
||||
'metered' => $this->usedCapacity / 1000000000,
|
||||
'fixed' => $this->limitations->max_storage_amount,
|
||||
default => $this->limitations->max_storage_amount,
|
||||
'fixed' => $this->limitations->max_storage_amount,
|
||||
default => $this->limitations->max_storage_amount,
|
||||
};
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this->id,
|
||||
'id' => (string) $this->id,
|
||||
'type' => 'storage',
|
||||
'attributes' => [
|
||||
'used' => Metric::bytes($this->usedCapacity)->format(),
|
||||
'capacity' => format_gigabytes($totalCapacity),
|
||||
'percentage' => (float)get_storage_percentage($this->usedCapacity, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($this->usedCapacity, $totalCapacity),
|
||||
],
|
||||
'meta' => [
|
||||
'traffic' => [
|
||||
@@ -47,23 +44,23 @@ class UserStorageResource extends JsonResource
|
||||
],
|
||||
'images' => [
|
||||
'used' => Metric::bytes($images)->format(),
|
||||
'percentage' => (float)get_storage_percentage($images, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($images, $totalCapacity),
|
||||
],
|
||||
'audios' => [
|
||||
'used' => Metric::bytes($audios)->format(),
|
||||
'percentage' => (float)get_storage_percentage($audios, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($audios, $totalCapacity),
|
||||
],
|
||||
'videos' => [
|
||||
'used' => Metric::bytes($videos)->format(),
|
||||
'percentage' => (float)get_storage_percentage($videos, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($videos, $totalCapacity),
|
||||
],
|
||||
'documents' => [
|
||||
'used' => Metric::bytes($documents)->format(),
|
||||
'percentage' => (float)get_storage_percentage($documents, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($documents, $totalCapacity),
|
||||
],
|
||||
'others' => [
|
||||
'used' => Metric::bytes($others)->format(),
|
||||
'percentage' => (float)get_storage_percentage($others, $totalCapacity),
|
||||
'percentage' => (float) get_storage_percentage($others, $totalCapacity),
|
||||
],
|
||||
],
|
||||
],
|
||||
@@ -134,12 +131,12 @@ class UserStorageResource extends JsonResource
|
||||
->where('created_at', '>', $period)
|
||||
->orderBy('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);
|
||||
|
||||
$upload = $mappedTrafficRecords->map(fn($record) => [
|
||||
$upload = $mappedTrafficRecords->map(fn ($record) => [
|
||||
'created_at' => $record->created_at,
|
||||
'amount' => Metric::bytes($record->upload)->format(),
|
||||
'percentage' => intval($uploadMax) !== 0
|
||||
@@ -147,7 +144,7 @@ class UserStorageResource extends JsonResource
|
||||
: 0,
|
||||
]);
|
||||
|
||||
$download = $mappedTrafficRecords->map(fn($record) => [
|
||||
$download = $mappedTrafficRecords->map(fn ($record) => [
|
||||
'created_at' => $record->created_at,
|
||||
'amount' => Metric::bytes($record->download)->format(),
|
||||
'percentage' => intval($downloadMax) !== 0
|
||||
|
||||
@@ -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,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Support\Middleware;
|
||||
|
||||
use Closure;
|
||||
@@ -16,7 +15,7 @@ class AdminCheck
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
// Check if user have access to administration settings
|
||||
if ( $request->user()->role !== 'admin') {
|
||||
if ($request->user()->role !== 'admin') {
|
||||
abort(403, 'You don\'t have access for this operation!');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace Support\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
|
||||
@@ -27,9 +27,13 @@ if (! function_exists('getListOfLatestLogs')) {
|
||||
return array_slice(
|
||||
array_reverse(
|
||||
array_filter(
|
||||
scandir(storage_path() . '/logs'), fn($fn) => !str_starts_with($fn, '.')
|
||||
scandir(storage_path() . '/logs'),
|
||||
fn ($fn) => ! str_starts_with($fn, '.')
|
||||
)
|
||||
), 0, 5, true
|
||||
),
|
||||
0,
|
||||
5,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -687,6 +691,7 @@ if (! function_exists('mapTrafficRecords')) {
|
||||
$records->add($record);
|
||||
}
|
||||
}
|
||||
|
||||
return $records;
|
||||
}
|
||||
}
|
||||
@@ -1126,13 +1131,13 @@ if (! function_exists('replace_occurrence')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('formatGPSCoordinates')) {
|
||||
if (! function_exists('formatGPSCoordinates')) {
|
||||
/**
|
||||
* Format GPS coordinates
|
||||
*/
|
||||
function formatGPSCoordinates($coordinates, $ref): string|null
|
||||
{
|
||||
if (!$coordinates && !$ref) {
|
||||
if (! $coordinates && ! $ref) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user