mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
team invitation notification with broadcasting
This commit is contained in:
@@ -38,7 +38,7 @@ return [
|
||||
'encrypted' => true,
|
||||
'host' => '192.168.1.112',
|
||||
'port' => 6001,
|
||||
'scheme' => 'http'
|
||||
'scheme' => 'http',
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
* Set a custom dashboard configuration
|
||||
*/
|
||||
@@ -48,7 +47,6 @@ return [
|
||||
* Leave this empty if you want to accept requests from all hosts.
|
||||
*/
|
||||
'allowed_origins' => [
|
||||
//
|
||||
],
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"/chunks/shared/authenticate.js": "/chunks/shared/authenticate.js?id=92c75a6c77689046",
|
||||
"/chunks/not-found.js": "/chunks/not-found.js?id=36763aa314e00327",
|
||||
"/chunks/temporary-unavailable.js": "/chunks/temporary-unavailable.js?id=a3906226272982b1",
|
||||
"/chunks/admin.js": "/chunks/admin.js?id=920613c2b7236639",
|
||||
"/chunks/admin.js": "/chunks/admin.js?id=a9cc617d7342978a",
|
||||
"/chunks/dashboard.js": "/chunks/dashboard.js?id=e7c6001687e641eb",
|
||||
"/chunks/invoices.js": "/chunks/invoices.js?id=85fd4514d3d85a71",
|
||||
"/chunks/subscriptions.js": "/chunks/subscriptions.js?id=9f970bdfc7583080",
|
||||
@@ -57,12 +57,12 @@
|
||||
"/chunks/sign-up.js": "/chunks/sign-up.js?id=098d7f41b85066bf",
|
||||
"/chunks/forgotten-password.js": "/chunks/forgotten-password.js?id=d6193ed0b07e7957",
|
||||
"/chunks/create-new-password.js": "/chunks/create-new-password.js?id=d00212636148a14b",
|
||||
"/chunks/settings.js": "/chunks/settings.js?id=f4a7bce3ff4c61a9",
|
||||
"/chunks/settings.js": "/chunks/settings.js?id=71ee8010419a7b69",
|
||||
"/chunks/profile.js": "/chunks/profile.js?id=1217f457145491ec",
|
||||
"/chunks/settings-password.js": "/chunks/settings-password.js?id=b6704f4cbf14c67d",
|
||||
"/chunks/settings-storage.js": "/chunks/settings-storage.js?id=90ba712f3728443b",
|
||||
"/chunks/billing.js": "/chunks/billing.js?id=27957f2477fdd121",
|
||||
"/chunks/platform.js": "/chunks/platform.js?id=85ee6709fe4e3b7e",
|
||||
"/chunks/platform.js": "/chunks/platform.js?id=4001e2c2fd8b27ce",
|
||||
"/chunks/files.js": "/chunks/files.js?id=0d4e7a1330328eae",
|
||||
"/chunks/recent-uploads.js": "/chunks/recent-uploads.js?id=2362f8fa4e3392e9",
|
||||
"/chunks/my-shared-items.js": "/chunks/my-shared-items.js?id=25e9d29dd3c29338",
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
{{ notification.data.attributes.description }}
|
||||
</p>
|
||||
|
||||
<div class="mb-4 flex items-center">
|
||||
<div class="flex items-center">
|
||||
<!--<MemberAvatar class="mr-2" :size="22" :is-border="false" :member="user" />-->
|
||||
<time class="block text-xs text-gray-400 dark:text-gray-400">
|
||||
{{ notification.data.attributes.created_at }}
|
||||
@@ -31,8 +31,9 @@
|
||||
</div>
|
||||
|
||||
<!--Accept or decline team invitation-->
|
||||
<div v-if="notification.data.attributes.type === 'team-invitation'" class="flex items-center space-x-3">
|
||||
<div v-if="action && action.type === 'invitation'" class="flex items-center space-x-3 mt-4">
|
||||
<div
|
||||
@click="acceptAction"
|
||||
class="flex cursor-pointer items-center rounded-xl py-1.5 px-2 transition-colors hover:bg-green-100 dark:hover:bg-green-900"
|
||||
>
|
||||
<check-icon size="16" class="vue-feather mr-2 text-green-600 dark:text-green-600" />
|
||||
@@ -42,6 +43,7 @@
|
||||
</div>
|
||||
|
||||
<div
|
||||
@click="declineAction"
|
||||
class="flex cursor-pointer items-center rounded-xl py-1.5 px-2 transition-colors hover:bg-rose-100 dark:hover:bg-rose-900"
|
||||
>
|
||||
<x-icon size="16" class="vue-feather mr-2 text-rose-600 dark:text-rose-600" />
|
||||
@@ -69,6 +71,7 @@
|
||||
<script>
|
||||
import { CheckIcon, XIcon, MailIcon, UserPlusIcon, UploadCloudIcon, ChevronRightIcon } from 'vue-feather-icons'
|
||||
import MemberAvatar from '../FilesView/MemberAvatar'
|
||||
import {events} from "../../bus";
|
||||
|
||||
export default {
|
||||
name: 'Notification',
|
||||
@@ -93,6 +96,28 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
acceptAction() {
|
||||
axios.put(`/api/teams/invitations/${this.notification.data.attributes.action.params.id}`)
|
||||
.then(() => {
|
||||
this.$store.commit('CLEAR_NOTIFICATION_ACTION_DATA', this.notification.data.id)
|
||||
|
||||
events.$emit('toaster', {
|
||||
type: 'success',
|
||||
message: this.$t('You successfully accepted invitation'),
|
||||
})
|
||||
})
|
||||
},
|
||||
declineAction() {
|
||||
axios.delete(`/api/teams/invitations/${this.notification.data.attributes.action.params.id}`)
|
||||
.then(() => {
|
||||
this.$store.commit('CLEAR_NOTIFICATION_ACTION_DATA', this.notification.data.id)
|
||||
|
||||
events.$emit('toaster', {
|
||||
type: 'success',
|
||||
message: this.$t('You successfully decline invitation'),
|
||||
})
|
||||
})
|
||||
},
|
||||
closeCenter() {
|
||||
this.$store.commit('TOGGLE_NOTIFICATION_CENTER')
|
||||
},
|
||||
|
||||
@@ -72,47 +72,6 @@ export default {
|
||||
return this.user.data.relationships.unreadNotifications.data
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
laterNotifications: [
|
||||
{
|
||||
id: 1,
|
||||
seen: 1,
|
||||
type: 'remote-upload-done',
|
||||
title: 'Remote Upload Finished',
|
||||
description: 'Your remote uploads has been done.',
|
||||
time: '09. Mar. 2022, 08:27',
|
||||
action: {
|
||||
id: '12-abc'
|
||||
}
|
||||
},
|
||||
],
|
||||
todayNotifications: [
|
||||
{
|
||||
id: 2,
|
||||
seen: 0,
|
||||
type: 'team-invitation',
|
||||
title: 'New Team Invitation',
|
||||
description: 'Jane Doe invite you to join into “Work Documents” Team Folder.',
|
||||
time: '09. Mar. 2022, 08:27',
|
||||
action: {
|
||||
id: '12-abc'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
seen: 0,
|
||||
type: 'file-request',
|
||||
title: 'File Request Filled',
|
||||
description: 'Your file request for “Videohive” folder was filled successfully.',
|
||||
time: '09. Mar. 2022, 07:12',
|
||||
action: {
|
||||
id: '12-abc'
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deleteAllNotifications() {
|
||||
axios.delete('/api/user/notifications')
|
||||
|
||||
17
resources/js/store/modules/userAuth.js
vendored
17
resources/js/store/modules/userAuth.js
vendored
@@ -180,6 +180,23 @@ const mutations = {
|
||||
state.user.data.relationships.readNotifications.data = []
|
||||
state.user.data.relationships.unreadNotifications.data = []
|
||||
},
|
||||
CLEAR_NOTIFICATION_ACTION_DATA(state, notificationId) {
|
||||
if (state.user.data.relationships.readNotifications.data.length) {
|
||||
state.user.data.relationships.readNotifications.data.map(notification => {
|
||||
if (notification.data.id === notificationId) {
|
||||
notification.data.attributes.action = undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (state.user.data.relationships.unreadNotifications.data.length) {
|
||||
state.user.data.relationships.unreadNotifications.data.map(notification => {
|
||||
if (notification.data.id === notificationId) {
|
||||
notification.data.attributes.action = undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
const getters = {
|
||||
|
||||
@@ -9,12 +9,12 @@ use Domain\Settings\Controllers\GetServerStatusController;
|
||||
use Domain\Settings\Controllers\GetSettingsValueController;
|
||||
use Domain\Admin\Controllers\Dashboard\GetNewbiesController;
|
||||
use Domain\Admin\Controllers\Users\ChangeUserRoleController;
|
||||
use Domain\Settings\Controllers\StoreStorageCredentialsController;
|
||||
use Domain\Settings\Controllers\UpdateSettingValueController;
|
||||
use Domain\Admin\Controllers\Users\ResetUserPasswordController;
|
||||
use Domain\Settings\Controllers\StoreEmailCredentialsController;
|
||||
use Domain\Transactions\Controllers\GetAllTransactionsController;
|
||||
use Domain\Admin\Controllers\Dashboard\GetDashboardDataController;
|
||||
use Domain\Settings\Controllers\StoreStorageCredentialsController;
|
||||
use Domain\Transactions\Controllers\GetUserTransactionsController;
|
||||
use Domain\Localization\Controllers\UpdateLanguageStringController;
|
||||
use Domain\Admin\Controllers\Users\ShowUserStorageCapacityController;
|
||||
|
||||
@@ -4,14 +4,14 @@ use App\Users\Controllers\Account\AccountDetailsController;
|
||||
use App\Users\Controllers\Account\UpdatePasswordController;
|
||||
use App\Users\Controllers\Account\StorageCapacityController;
|
||||
use App\Users\Controllers\Verification\VerifyEmailController;
|
||||
use Domain\Notifications\Controllers\FlushUserNotificationsController;
|
||||
use Domain\Notifications\Controllers\GetUserNotificationsController;
|
||||
use Domain\Notifications\Controllers\MarkUserNotificationsAsReadController;
|
||||
use Domain\Transactions\Controllers\GetTransactionsController;
|
||||
use App\Users\Controllers\Verification\ResendVerificationEmail;
|
||||
use App\Users\Controllers\Authentication\CheckAccountController;
|
||||
use App\Users\Controllers\Account\UpdateProfileSettingsController;
|
||||
use Domain\Notifications\Controllers\GetUserNotificationsController;
|
||||
use App\Users\Controllers\Authentication\AccountAccessTokenController;
|
||||
use Domain\Notifications\Controllers\FlushUserNotificationsController;
|
||||
use Domain\Notifications\Controllers\MarkUserNotificationsAsReadController;
|
||||
|
||||
Route::post('/check', CheckAccountController::class);
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
use Domain\Homepage\Controllers\IndexController;
|
||||
use Domain\Invoices\Controllers\GetInvoiceController;
|
||||
use Domain\Settings\Controllers\DownloadLogController;
|
||||
use Domain\Sharing\Controllers\SharePublicIndexController;
|
||||
use App\Socialite\Controllers\SocialiteCallbackController;
|
||||
use Domain\Sharing\Controllers\SharePublicIndexController;
|
||||
use Domain\Sharing\Controllers\WebCrawlerOpenGraphController;
|
||||
use Domain\Localization\Controllers\CurrentLocalizationController;
|
||||
|
||||
@@ -20,7 +20,6 @@ Route::get('/invoices/{invoice}', GetInvoiceController::class)
|
||||
Route::get('/admin/log/{log}', DownloadLogController::class)
|
||||
->middleware(['auth:sanctum', 'admin']);
|
||||
|
||||
|
||||
// Get og site for web crawlers
|
||||
if (Crawler::isCrawler()) {
|
||||
Route::get('/share/{share}', WebCrawlerOpenGraphController::class);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Files\Actions;
|
||||
|
||||
class StoreFileExifMetadataAction
|
||||
@@ -10,7 +9,6 @@ class StoreFileExifMetadataAction
|
||||
$exif_data = get_image_meta_data($file);
|
||||
|
||||
if ($exif_data) {
|
||||
|
||||
// Conver array to collection
|
||||
$data = json_decode(json_encode($exif_data));
|
||||
|
||||
@@ -33,9 +31,8 @@ class StoreFileExifMetadataAction
|
||||
'longitude' => $data->GPSLongitude ?? null,
|
||||
'latitude' => $data->GPSLatitude ?? null,
|
||||
'longitude_ref' => $data->GPSLongitudeRef ?? null,
|
||||
'latitude_ref' => $data->GPSLatitudeRef ?? 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;
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
@@ -229,7 +229,7 @@ class File extends Model
|
||||
static::deleting(function ($file) {
|
||||
if ($file->isForceDeleting()) {
|
||||
$file->exif()->forceDelete();
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Notifications\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
// 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
|
||||
TeamFolderInvitation $invitation,
|
||||
ClearActionInInvitationNotificationAction $clearActionInInvitationNotification,
|
||||
): ResponseFactory|Response {
|
||||
$user = User::where('email', $invitation->email);
|
||||
$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
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Support\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +391,6 @@ class FileTest extends TestCase
|
||||
*/
|
||||
public function it_store_file_exif_data_after_file_upload()
|
||||
{
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->image('fake-image.jpg', 2000, 2000);
|
||||
|
||||
@@ -417,5 +416,4 @@ class FileTest extends TestCase
|
||||
'width' => 2000,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Notifications;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use Tests\TestCase;
|
||||
use Str;
|
||||
use DB;
|
||||
use Str;
|
||||
use Tests\TestCase;
|
||||
use App\Users\Models\User;
|
||||
|
||||
class NotificationsTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Settings;
|
||||
|
||||
use Storage;
|
||||
|
||||
@@ -62,11 +62,41 @@ class TeamManagementTest extends TestCase
|
||||
'permission' => 'can-view',
|
||||
]);
|
||||
|
||||
DB::table('notifications')
|
||||
->insert([
|
||||
'id' => Str::uuid(),
|
||||
'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification',
|
||||
'notifiable_type' => 'App\Users\Models\User',
|
||||
'notifiable_id' => $member->id,
|
||||
'data' => json_encode([
|
||||
'type' => 'team-invitation',
|
||||
'title' => 'New Team Invitation',
|
||||
'description' => 'Jane Doe invite you to join into Team Folder..',
|
||||
'action' => [
|
||||
'type' => 'invitation',
|
||||
'params' => [
|
||||
'type' => 'invitation',
|
||||
'params' => [
|
||||
'id' => $invitation->id,
|
||||
],
|
||||
],
|
||||
],
|
||||
]),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($member)
|
||||
->putJson("/api/teams/invitations/{$invitation->id}")
|
||||
->assertNoContent();
|
||||
|
||||
// Get notification
|
||||
$notification = json_decode(DB::table('notifications')->first()->data);
|
||||
|
||||
// Check if action is null
|
||||
$this->assertEquals(null, $notification->action);
|
||||
|
||||
$this
|
||||
->assertDatabaseHas('team_folder_invitations', [
|
||||
'parent_id' => $folder->id,
|
||||
@@ -174,11 +204,41 @@ class TeamManagementTest extends TestCase
|
||||
'permission' => 'can-edit',
|
||||
]);
|
||||
|
||||
DB::table('notifications')
|
||||
->insert([
|
||||
'id' => Str::uuid(),
|
||||
'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification',
|
||||
'notifiable_type' => 'App\Users\Models\User',
|
||||
'notifiable_id' => $member->id,
|
||||
'data' => json_encode([
|
||||
'type' => 'team-invitation',
|
||||
'title' => 'New Team Invitation',
|
||||
'description' => 'Jane Doe invite you to join into Team Folder..',
|
||||
'action' => [
|
||||
'type' => 'invitation',
|
||||
'params' => [
|
||||
'type' => 'invitation',
|
||||
'params' => [
|
||||
'id' => $invitation->id,
|
||||
],
|
||||
],
|
||||
],
|
||||
]),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($member)
|
||||
->deleteJson("/api/teams/invitations/{$invitation->id}")
|
||||
->assertNoContent();
|
||||
|
||||
// Get notification
|
||||
$notification = json_decode(DB::table('notifications')->first()->data);
|
||||
|
||||
// Check if action is null
|
||||
$this->assertEquals(null, $notification->action);
|
||||
|
||||
$this
|
||||
->assertDatabaseHas('team_folder_invitations', [
|
||||
'parent_id' => $folder->id,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\UploadRequest;
|
||||
|
||||
use Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification;
|
||||
use Storage;
|
||||
use Notification;
|
||||
use Tests\TestCase;
|
||||
@@ -12,6 +10,7 @@ use Illuminate\Http\UploadedFile;
|
||||
use Domain\UploadRequest\Models\UploadRequest;
|
||||
use Support\Scheduler\Actions\ExpireUnfilledUploadRequestAction;
|
||||
use Domain\UploadRequest\Notifications\UploadRequestNotification;
|
||||
use Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification;
|
||||
|
||||
class UploadRequestTest extends TestCase
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user