deleted pro code

This commit is contained in:
Čarodej
2022-04-26 14:08:20 +02:00
parent 188d5613b7
commit f45c1eb576
76 changed files with 62 additions and 3048 deletions

View File

@@ -1,6 +1,6 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:fzZomRn3E8Rb6UDR8oqFiNo8Y4L5RyX4oVVli3KiWQA=
APP_KEY=base64:yQs3FfCdjY2KGHl1JpLP7L8LLVq8RNOIu/sygWVXUBM=
APP_DEBUG=true
APP_URL=http://localhost
APP_DEMO=false

View File

@@ -25,7 +25,6 @@ class FolderFactory extends Factory
'id' => $this->faker->uuid,
'user_id' => $this->faker->uuid,
'name' => $this->faker->word,
'team_folder' => false,
'author' => $this->faker->randomElement(
['user', 'member', 'visitor']
),

View File

@@ -24,7 +24,6 @@ class UserLimitationFactory extends Factory
return [
'user_id' => $this->faker->uuid,
'max_storage_amount' => $this->faker->randomElement([100, 200, 300]),
'max_team_members' => $this->faker->randomElement([10, 20, 30]),
];
}
}

View File

@@ -21,8 +21,6 @@ class CreateFoldersTable extends Migration
$table->string('color')->nullable();
$table->longText('emoji')->nullable();
$table->boolean('team_folder')->default(0);
$table->enum('author', ['user', 'member', 'visitor'])->default('user');
$table->softDeletes();

View File

@@ -1,39 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTeamFolderInvitationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('team_folder_invitations', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->uuid('parent_id');
$table->uuid('inviter_id');
$table->text('email');
$table->string('color')->nullable();
$table->enum('permission', ['can-edit', 'can-view', 'can-view-and-download']);
$table->enum('status', ['pending', 'accepted', 'waiting-for-registration', 'rejected'])->default('pending');
$table->timestamps();
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('invitations');
}
}

View File

@@ -1,34 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTeamFolderMembersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('team_folder_members', function (Blueprint $table) {
$table->uuid('parent_id');
$table->uuid('user_id');
$table->string('permission');
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('team_folder_members');
}
}

View File

@@ -16,7 +16,6 @@ class CreateUserLimitationsTable extends Migration
Schema::create('user_limitations', function (Blueprint $table) {
$table->uuid('user_id');
$table->text('max_storage_amount');
$table->text('max_team_members');
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
});

View File

@@ -1,39 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUploadRequestsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('upload_requests', function (Blueprint $table) {
$table->uuid('id');
$table->uuid('user_id');
$table->uuid('folder_id')->nullable();
$table->enum('status', ['active', 'filling', 'filled', 'expired'])->default('active');
$table->string('email')->nullable();
$table->text('name')->nullable();
$table->longText('notes')->nullable();
$table->timestamps();
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('upload_requests');
}
}

View File

@@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->string('notifiable_type');
$table->uuid('notifiable_id');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifications');
}
};

View File

@@ -1,16 +1,6 @@
@php
use VueFileManager\Subscription\Domain\Plans\Models\Plan;
use VueFileManager\Subscription\Domain\Transactions\Models\Transaction;
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
try {
// Subscription
$isEmptySubscriptions = Subscription::count() === 0;
$isEmptyTransactions = Transaction::count() === 0;
$isEmptyPlans = Plan::count() === 0;
$plan = Plan::where('status', 'active')
->where('type', 'metered');
// User
$isUser = auth()->check();
$user = Auth::user();
@@ -21,7 +11,6 @@
} catch (PDOException $e) {
[$isUser, $isEmptyPlans, $isEmptyTransactions, $isEmptySubscriptions] = false;
$plan = null;
$defaultEmoji = 'twemoji';
$defaultThemeMode = 'system';
}
@@ -71,19 +60,11 @@
<div id="app"></div>
<script>
// todo: refactoring
let config = {
host: '{{ url('/') }}',
api: '{{ url('/api') }}',
locale: '{{ app()->getLocale() }}',
broadcasting: '{{ config('broadcasting.default') }}',
broadcastingKey: '{{ config('broadcasting.connections.pusher.key') }}',
broadcastingHost: '{{ config('broadcasting.connections.pusher.options.host') }}',
broadcastingPort: '{{ config('broadcasting.connections.pusher.options.port') }}',
broadcastingCluster: '{{ config('broadcasting.connections.pusher.options.cluster') }}',
app_logo: '{{ $settings->app_logo ?? null }}',
app_logo_dark: '{{ $settings->app_logo_dark ?? null }}',
app_logo_horizontal: '{{ $settings->app_logo_horizontal ?? null }}',
@@ -94,9 +75,7 @@
app_name: '{{ $settings->app_title ?? 'VueFileManager' }}',
app_description: '{{ $settings->app_description ?? __t('app_description') }}',
allowHomepage: {{ $settings->allow_homepage ?? 1 }},
storageLimit: {{ $settings->storage_limitation ?? 1 }},
teamsDefaultMembers: {{ $settings->default_max_team_member ?? 10 }},
storageDefaultSpace: {{ $settings->default_max_storage_amount ?? 5 }},
storageDefaultSpaceFormatted: '{{ isset($settings->default_max_storage_amount) ? format_gigabytes($settings->default_max_storage_amount) : format_gigabytes(5) }}',
mimetypesBlacklist: '{{ isset($settings->mimetypes_blacklist) ? $settings->mimetypes_blacklist: null}}',
@@ -105,74 +84,23 @@
chunkSize: {{ isset($settings->chunk_size) ? format_bytes($settings->chunk_size) : format_bytes(64) }},
isAuthenticated: {{ $isUser ? 1 : 0 }},
isSaaS: {{ $settings && optional($settings)->license === 'extended' ? 1 : 0 }},
isDev: {{ is_dev() ? 1 : 0 }},
isDemo: {{ config('vuefilemanager.is_demo') ? 1 : 0 }},
legal: {!! $legal ?? 'undefined' !!},
installation: '{{ $installation ?? 'initial' }}',
statusCheck: {!! json_encode($status_check) ?? 'undefined' !!},
isSetupWizardDemo: {{ config('vuefilemanager.is_setup_wizard_demo') ? 1 : 0 }},
isSetupWizardDebug: {{ config('vuefilemanager.is_setup_wizard_debug') ? 1 : 0 }},
// States
isEmptyPlans: {{ $isEmptyPlans ? 1 : 0 }},
isEmptyTransactions: {{ $isEmptyTransactions ? 1 : 0 }},
isEmptySubscriptions: {{ $isEmptySubscriptions ? 1 : 0 }},
// Hidden set ups
isAdminVueFileManagerBar: {{ config('vuefilemanager.is_admin_vuefilemanager_bar', 1) ? 1 : 0 }},
// Metered
allowed_registration_bonus: {{ $settings->allowed_registration_bonus ?? 0 }},
registration_bonus_amount: {{ $settings->registration_bonus_amount ?? 0 }},
isCreatedMeteredPlan: {{ $plan && $plan->exists() ? 1 : 0 }},
meteredPlanId: '{{ $plan && $plan->exists() ? $plan->first()->id : null }}',
// Payments
allowed_payments: {{ $settings->allowed_payments ?? 0 }},
subscriptionType: '{{ $settings->subscription_type ?? 'none' }}',
// PayPal
isPayPal: {{ $settings->allowed_paypal ?? 0 }},
isPayPalLive: {{ config('subscription.credentials.paypal.is_live') ? 1 : 0 }},
paypal_client_id: '{{ config('subscription.credentials.paypal.id') }}',
paypal_payment_description: '{{ $settings->paypal_payment_description ?? '' }}',
// Paystack
isPaystack: {{ $settings->allowed_paystack ?? 0 }},
paystack_public_key: '{{ config('subscription.credentials.paystack.public_key') }}',
paystack_payment_description: '{{ $settings->paystack_payment_description ?? '' }}',
// Stripe
isStripe: {{ $settings->allowed_stripe ?? 0 }},
stripe_public_key: '{{ config('subscription.credentials.stripe.public_key') }}',
stripe_payment_description: '{{ $settings->stripe_payment_description ?? '' }}',
// ReCaptcha
recaptcha_client_id: '{{ config('services.recaptcha.client_id') }}',
allowedRecaptcha: {{ $settings->allowed_recaptcha ?? 0 }},
isRecaptchaConfigured: {{ config('services.recaptcha.client_id') ? 1 : 0 }},
// Social logins
allowedFacebookLogin: {{ $settings->allowed_facebook_login ?? 0 }},
isFacebookLoginConfigured: {{ config('services.facebook.client_id') ? 1 : 0 }},
allowedGoogleLogin: {{ $settings->allowed_google_login ?? 0 }},
isGoogleLoginConfigured: {{ config('services.google.client_id') ? 1 : 0 }},
allowedGithubLogin: {{ $settings->allowed_github_login ?? 0 }},
isGithubLoginConfigured: {{ config('services.github.client_id') ? 1 : 0 }},
// Adsense
allowedAdsense: {{ $settings?->allowed_adsense ?? 0 }},
adsenseClientId: '{{ $settings->adsense_client_id ?? '' }}',
adsenseBanner01: `{!! $settings->adsense_banner_01 ?? '' !!}`,
adsenseBanner02: `{!! $settings->adsense_banner_02 ?? '' !!}`,
adsenseBanner03: `{!! $settings->adsense_banner_03 ?? '' !!}`,
// User settings
defaultEmoji: '{{ $defaultEmoji }}',
defaultThemeMode: '{{ $defaultThemeMode }}',
@@ -203,14 +131,5 @@
{{--Application development script--}}
<script src="{{ mix('js/main.js') }}"></script>
@endif
{{--Adsense code--}}
@if(optional($settings)->allowed_adsense)
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client={{ $settings->adsense_client_id ?? '' }}" crossorigin="anonymous"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
@endif
</body>
</html>

View File

@@ -1 +0,0 @@
<p>{{ $request['message'] }}</p>

View File

@@ -1,307 +0,0 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<title>
{{ __t('invoice') }}
</title>
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@200;300;400;600;700;800;900&display=swap" rel="stylesheet">
<link href="{{ mix('css/tailwind.css') }}?v={{ get_version() }}" rel="stylesheet" type="text/css">
<style>
* {
outline: 0;
margin: 0;
padding: 0;
font-family: 'Nunito', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
box-sizing: border-box;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
font-size: 15px;
text-decoration: none;
color: #1B2539;
}
</style>
@include('vuefilemanager.others.color-template')
</head>
<body class="bg-light-background print:px-0 px-3">
<div class="rounded-xl max-w-3xl mx-auto my-5 print:hidden">
<button class="flex items-center bg-white py-1 px-2 rounded-lg" onclick="window.print();">
<svg class="transform scale-75" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 6 2 18 2 18 9"></polyline>
<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"></path>
<rect x="6" y="14" width="12" height="8"></rect>
</svg>
<span class="font-bold ml-2 text-sm">
{{ __t('print_button') }}
</span>
</button>
</div>
<div class="bg-white rounded-xl max-w-3xl mx-auto print:p-0 lg:p-10 p-4 lg:mb-0 print:mb-0 mb-10">
<!--Invoice Header-->
<header class="print:flex lg:flex justify-between items-start pb-4 mb-4 border-b dark:border-opacity-5 border-light border-dashed">
<div>
@if(isset($settings->app_logo_horizontal))
<img src="{{ url($settings->app_logo_horizontal) }}" alt="{{ $settings->app_title ?? 'VueFileManager' }}" class="h-8">
@else
<h1 class="text-2xl font-bold">
{{ $settings->app_title ?? 'VueFileManager' }}
</h1>
@endif
<b class="text-gray-800 text-sm">
{{ $settings->contact_email }}
</b>
</div>
<div class="print:text-right lg:text-right lg:mt-0 print:mt-0 mt-6">
<h1 class="text-2xl font-bold">
{{ __t('invoice') }}
</h1>
<b class="text-gray-800 text-sm">
{{ __t('number') }}: {{ $invoice->id }}
</b>
</div>
</header>
<!-- Invoice partners -->
<div class="lg:flex print:flex justify-between items-start lg:space-x-8 lg:space-y-0 space-y-5 pb-6 mb-6 border-b dark:border-opacity-5 border-light border-dashed">
<!-- Seller -->
<div>
<div class="mb-3">
<b class="text-theme text-base font-bold mb-1 block">
{{ __t('seller') }}:
</b>
@isset($settings->billing_name)
<span class="font-bold">
{{ $settings->billing_name }}
</span>
@endisset
</div>
<div class="mb-3">
<b class="text-theme text-base font-bold mb-1 block">
{{ __t('head_office') }}:
</b>
@isset($settings->billing_address)
<span class="font-bold block">
{{ $settings->billing_address }}
</span>
@endisset
@isset($settings->billing_city)
<span class="font-bold block">
{{ $settings->billing_city }}
</span>
@endisset
@isset($settings->billing_state)
<span class="font-bold block">
{{ $settings->billing_state }}
</span>
@endisset
@isset($settings->billing_postal_code)
<span class="font-bold block">
{{ $settings->billing_postal_code }}
</span>
@endisset
@isset($settings->billing_country)
<span class="font-bold block">
{{ $settings->billing_country }}
</span>
@endisset
@isset($settings->billing_phone_number)
<span class="font-bold block">
{{ $settings->billing_phone_number }}
</span>
@endisset
</div>
<div>
<b class="text-theme text-base font-bold mb-1 block">
{{ __t('billing_information') }}:
</b>
@isset($settings->billing_vat_number)
<span class="font-bold block">
{{ __t('vat_id') }}: {{ $settings->billing_vat_number }}
</span>
@endisset
{{--@if(isset($vat))
<span class="text-base">
{{ $vat }}
</span>
@endif--}}
</div>
</div>
<!--Client-->
<div>
<div class="bg-light-background rounded-xl p-4" style="width: 360px">
<b class="text-theme text-base font-bold mb-1.5 block">
{{ __t('client') }}:
</b>
@isset($invoice->user->settings->name)
<span class="font-bold block">
{{ $invoice->user->settings->name }}
</span>
@endisset
@isset($invoice->user->settings->address)
<span class="font-bold block">
{{ $invoice->user->settings->address }}
</span>
@endisset
@isset($invoice->user->settings->postal_code)
<span class="font-bold inline-block">
{{ $invoice->user->settings->postal_code }}
</span>
@endisset
@isset($invoice->user->settings->city)
<span class="font-bold inline-block">
{{ $invoice->user->settings->city }}
</span>,
@endisset
@isset($invoice->user->settings->state)
<span class="font-bold inline-block">
{{ $invoice->user->settings->state }}
</span>
@endisset
@isset($invoice->user->settings->country)
<span class="font-bold inline-block">
{{ $invoice->user->settings->country }}
</span>
@endisset
@isset($invoice->user->settings->phone_number)
<span class="font-bold block">
{{ $invoice->user->settings->phone_number }}
</span>
@endisset
</div>
<div class="font-bold block lg:text-right print:text-right pt-3 text-sm">
{{ __t('date_of_issue') }}: {{ format_date($invoice->created_at) }}
</div>
</div>
</div>
<!-- Invoice Items -->
<div class="pb-6 mb-6 border-b dark:border-opacity-5 border-light border-dashed">
<!--Items-->
<table class="w-full mb-12">
<thead>
<tr>
<td class="pb-5">
<span class="text-theme dark:text-gray-500 text-gray-400 text-xs font-bold">
{{ __t('description') }}
</span>
</td>
<td class="pb-5">
<span class="text-theme dark:text-gray-500 text-gray-400 text-xs font-bold">
{{ __t('period') }}
</span>
</td>
<td class="pb-5">
<span class="text-theme dark:text-gray-500 text-gray-400 text-xs font-bold">
{{ __t('usage') }}
</span>
</td>
<td class="pb-5 text-right">
<span class="text-theme dark:text-gray-500 text-gray-400 text-xs font-bold">
{{ __t('amount') }}
</span>
</td>
</tr>
</thead>
@if($invoice->metadata)
<tbody>
@foreach($invoice->metadata as $item)
<tr class="border-b dark:border-opacity-5 border-light border-dashed whitespace-nowrap {{ $loop->index % 2 ? 'bg-light-background' : '' }}">
<td class="py-1.5 px-3">
<span class="text-sm font-bold">
{{ __t($item['feature']) }}
</span>
</td>
<td class="py-1.5">
<span class="text-sm font-bold">
{{ $invoice->note }}
</span>
</td>
<td class="py-1.5">
<span class="text-sm font-bold">
{{ $item['usage'] }}
</span>
</td>
<td class="py-1.5 px-3 text-right">
<span class="text-sm font-bold">
{{ $item['cost'] }}
</span>
</td>
</tr>
@endforeach
</tbody>
@else
<tr class="whitespace-nowrap">
<td class="py-1.5 pr-3">
<span class="text-sm font-bold">
{{ __t('subscription') }}
</span>
</td>
<td class="py-1.5">
<span class="text-sm font-bold">
{{ $invoice->note }}
</span>
</td>
<td class="py-1.5">
<span class="text-sm font-bold">
1
</span>
</td>
<td class="py-1.5 pl-3 text-right">
<span class="text-sm font-bold">
{{ format_currency($invoice->amount, $invoice->currency) }}
</span>
</td>
</tr>
@endif
</table>
<!-- Invoice Total -->
<div class="print:text-right lg:text-right text-center">
<b class="text-2xl font-extrabold">
{{ __t('total') }} {{ format_currency($invoice->amount, $invoice->currency) }}
</b>
</div>
</div>
<!-- Invoice Items -->
<footer class="text-center">
<p class="font-bold">
{{ __t('generated_by') }} <a href="{{ url('/') }}" target="_blank" class="font-bold text-theme underline">{{ $settings->app_title }}</a>
</p>
</footer>
</div>
</body>
</html>

View File

@@ -1,11 +1,9 @@
<?php
use Domain\Admin\Controllers\Users\UserController;
use Domain\Pages\Controllers\AdminPagesController;
use Domain\Settings\Controllers\FlushCacheController;
use Domain\Localization\Controllers\LanguageController;
use Domain\Admin\Controllers\Users\DeleteUserController;
use Domain\Settings\Controllers\UpgradeLicenseController;
use Domain\Settings\Controllers\GetServerStatusController;
use Domain\Settings\Controllers\GetSettingsValueController;
use Domain\Admin\Controllers\Dashboard\GetNewbiesController;
@@ -13,21 +11,14 @@ use Domain\Admin\Controllers\Users\ChangeUserRoleController;
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;
use Domain\Admin\Controllers\Dashboard\GetLatestTransactionsController;
use Domain\Admin\Controllers\Users\ChangeUserStorageCapacityController;
use Domain\Settings\Controllers\StoreSocialServiceCredentialsController;
use Domain\Settings\Controllers\StorePaymentServiceCredentialsController;
use Domain\Settings\Controllers\StoreBroadcastServiceCredentialsController;
// Dashboard
Route::group(['prefix' => 'dashboard'], function () {
Route::get('/transactions', GetLatestTransactionsController::class);
Route::get('/newbies', GetNewbiesController::class);
Route::get('/', GetDashboardDataController::class);
});
@@ -36,14 +27,11 @@ Route::group(['prefix' => 'dashboard'], function () {
Route::group(['prefix' => 'users'], function () {
Route::patch('/{user}/capacity', ChangeUserStorageCapacityController::class);
Route::post('/{user}/reset-password', ResetUserPasswordController::class);
Route::get('/{user}/transactions', GetUserTransactionsController::class);
Route::get('/{user}/storage', ShowUserStorageCapacityController::class);
Route::patch('/{user}/role', ChangeUserRoleController::class);
Route::delete('/{user}/delete', DeleteUserController::class);
});
Route::get('/transactions', GetAllTransactionsController::class);
Route::apiResource('/pages', AdminPagesController::class);
Route::apiResource('/users', UserController::class);
// Settings
@@ -54,10 +42,6 @@ Route::group(['prefix' => 'settings'], function () {
Route::get('/flush-cache', FlushCacheController::class);
Route::post('/email', StoreEmailCredentialsController::class);
Route::post('/storage', StoreStorageCredentialsController::class);
Route::post('/payment-service', StorePaymentServiceCredentialsController::class);
Route::post('/social-service', StoreSocialServiceCredentialsController::class);
Route::post('/broadcast', StoreBroadcastServiceCredentialsController::class);
});
// Language
@@ -66,5 +50,3 @@ Route::apiResource('/languages', LanguageController::class);
// Server Status
Route::get('/status', GetServerStatusController::class);
Route::post('/upgrade-license', UpgradeLicenseController::class);

View File

@@ -1,7 +1,6 @@
<?php
use Domain\Zip\Controllers\ZipController;
use Domain\Pages\Controllers\PagesController;
use Domain\Sharing\Controllers\ShareController;
use Domain\Trash\Controllers\DumpTrashController;
use App\Users\Controllers\ResetPasswordController;
@@ -14,7 +13,6 @@ use Domain\Browsing\Controllers\BrowseFolderController;
use Domain\Sharing\Controllers\ShareViaEmailController;
use Domain\Folders\Controllers\NavigationTreeController;
use Domain\Items\Controllers\MoveFileOrFolderController;
use App\Socialite\Controllers\SocialiteRedirectController;
use Domain\Browsing\Controllers\SpotlightSearchController;
use Domain\Items\Controllers\DeleteFileOrFolderController;
use Domain\Items\Controllers\RenameFileOrFolderController;
@@ -23,27 +21,14 @@ use Domain\Trash\Controllers\RestoreTrashContentController;
use Domain\Browsing\Controllers\BrowseLatestFilesController;
use Domain\Browsing\Controllers\BrowseSharedItemsController;
use Domain\Browsing\Controllers\BrowseTrashContentController;
use Domain\Homepage\Controllers\SendContactMessageController;
use Domain\RemoteUpload\Controllers\RemoteUploadFileController;
use Domain\Sharing\Controllers\GetShareLinkViaQrCodeController;
use App\Users\Controllers\Authentication\RegisterUserController;
// Ping Pong
Route::get('/ping', PingAPIController::class);
// Pages
Route::apiResource('/page', PagesController::class);
// Homepage
Route::post('/contact', SendContactMessageController::class);
Route::get('/settings', GetSettingsValueController::class);
// Register user
Route::post('/register', RegisterUserController::class);
// Socialite
Route::get('/socialite/{provider}/redirect', SocialiteRedirectController::class);
// Password reset
Route::group(['prefix' => 'password'], function () {
Route::post('/email', [ForgotPasswordController::class, 'sendResetLinkEmail']);
@@ -79,7 +64,6 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
// User master,editor routes
Route::group(['middleware' => ['auth:sanctum']], function () {
Route::post('/upload/remote', RemoteUploadFileController::class);
Route::post('/create-folder', CreateFolderController::class);
Route::post('/upload', UploadFileController::class);

View File

@@ -1,7 +1,5 @@
<?php
use Support\Scheduler\Actions\ReportUsageAction;
/*
|--------------------------------------------------------------------------
| Console Routes
@@ -12,6 +10,3 @@ use Support\Scheduler\Actions\ReportUsageAction;
| simple approach to interacting with each command's IO methods.
|
*/
Artisan::command('report:usage', fn () => resolve(ReportUsageAction::class)())
->describe('Store user usage estimates for metered billing');

View File

@@ -6,18 +6,10 @@ use Domain\Files\Controllers\FileAccess\GetFileController;
use Domain\Files\Controllers\FileAccess\GetThumbnailController;
use Domain\Files\Controllers\FileAccess\VisitorGetFileController;
use Domain\Files\Controllers\FileAccess\VisitorGetThumbnailController;
use Domain\UploadRequest\Controllers\FileAccess\GetFileFromUploadRequestController;
use Domain\UploadRequest\Controllers\FileAccess\GetThumbnailFromUploadRequestController;
Route::get('/avatars/{avatar}', GetAvatarController::class);
Route::get('/system/{image}', GetAppImageController::class);
// Get Upload request thumbnails and files
Route::group(['middleware' => ['upload-request']], function () {
Route::get('/thumbnail/{name}/upload-request/{uploadRequest}', GetThumbnailFromUploadRequestController::class);
Route::get('/file/{name}/upload-request/{uploadRequest}', GetFileFromUploadRequestController::class);
});
// Get public thumbnails and files
Route::get('/thumbnail/{name}/shared/{shared}', VisitorGetThumbnailController::class);
Route::get('/file/{name}/shared/{shared}', VisitorGetFileController::class);

View File

@@ -12,12 +12,10 @@ use Domain\Items\Controllers\VisitorDeleteFileOrFolderController;
use Domain\Items\Controllers\VisitorRenameFileOrFolderController;
use Domain\Sharing\Controllers\VisitorUnlockLockedShareController;
use Domain\Folders\Controllers\VisitorNavigationFolderTreeController;
use Domain\RemoteUpload\Controllers\VisitorRemoteUploadFileController;
use Domain\Browsing\Controllers\VisitorSearchFilesAndFoldersController;
// Browse functions
Route::group(['prefix' => 'editor'], function () {
Route::post('/upload/remote/{shared}', VisitorRemoteUploadFileController::class);
Route::post('/create-folder/{shared}', VisitorCreateFolderController::class);
Route::post('/upload/{shared}', VisitorUploadFileController::class);

View File

@@ -4,14 +4,10 @@ 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\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);
@@ -26,14 +22,8 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
// User Access Token
Route::apiResource('/tokens', AccountAccessTokenController::class);
// Notifications
Route::post('/notifications/read', MarkUserNotificationsAsReadController::class);
Route::delete('/notifications', FlushUserNotificationsController::class);
Route::get('/notifications', GetUserNotificationsController::class);
// Account
Route::patch('/settings', UpdateProfileSettingsController::class);
Route::get('/transactions', GetTransactionsController::class);
Route::post('/password', UpdatePasswordController::class);
Route::get('/storage', StorageCapacityController::class);
Route::get('/', AccountDetailsController::class);

View File

@@ -1,23 +1,15 @@
<?php
use Domain\Homepage\Controllers\IndexController;
use Domain\Invoices\Controllers\GetInvoiceController;
use Domain\Settings\Controllers\DownloadLogController;
use App\Socialite\Controllers\SocialiteCallbackController;
use Domain\Sharing\Controllers\SharePublicIndexController;
use Domain\Sharing\Controllers\WebCrawlerOpenGraphController;
use Domain\Sharing\Controllers\DirectlyDownloadFileController;
use Domain\Localization\Controllers\CurrentLocalizationController;
Route::get('/socialite/{provider}/callback', SocialiteCallbackController::class);
// Translations
Route::get('/translations/{lang}', CurrentLocalizationController::class);
// Invoices
Route::get('/invoices/{invoice}', GetInvoiceController::class)
->middleware('auth:sanctum');
Route::get('/admin/log/{log}', DownloadLogController::class)
->middleware(['auth:sanctum', 'admin']);

View File

@@ -11,8 +11,6 @@ use Illuminate\Support\Facades\DB;
use Domain\Settings\Models\Setting;
use Illuminate\Support\Facades\Storage;
use Illuminate\Foundation\Testing\WithFaker;
use Domain\Teams\Models\TeamFolderInvitation;
use Domain\Pages\Actions\SeedDefaultPagesAction;
use Intervention\Image\ImageManagerStatic as Image;
use Domain\Settings\Actions\SeedDefaultSettingsAction;
use Domain\Localization\Actions\SeedDefaultLanguageAction;
@@ -25,7 +23,7 @@ class SetupDevEnvironment extends Command
/**
* The name and signature of the console command.
*/
protected $signature = 'setup:dev {license=extended}';
protected $signature = 'setup:dev';
/**
* The console command description.
@@ -36,7 +34,6 @@ class SetupDevEnvironment extends Command
private CreateDiskDirectoriesAction $createDiskDirectories,
private SeedDefaultSettingsAction $seedDefaultSettings,
private SeedDefaultLanguageAction $seedDefaultLanguage,
private SeedDefaultPagesAction $seedDefaultPages,
) {
parent::__construct();
$this->setUpFaker();
@@ -56,8 +53,7 @@ class SetupDevEnvironment extends Command
$this->migrate_and_generate();
$this->info('Storing default settings and content...');
($this->seedDefaultPages)();
($this->seedDefaultSettings)($this->argument('license'));
($this->seedDefaultSettings)();
($this->seedDefaultLanguage)();
$this->store_default_settings();
@@ -69,15 +65,9 @@ class SetupDevEnvironment extends Command
$this->info('Creating default demo content...');
$this->create_admin_default_content();
$this->create_team_folders_content();
$this->create_share_with_me_team_folders_content();
$this->create_share_records();
$this->generate_traffic();
$this->generateCommonNotification();
$this->generateTeamInvitationNotification();
$this->generateFileRequestFilledNotification();
$this->info('Clearing application cache...');
$this->clear_cache();
@@ -91,135 +81,6 @@ class SetupDevEnvironment extends Command
$this->info('Everything is done, congratulations! 🥳🥳🥳');
}
private function generateCommonNotification()
{
$howdy = User::whereEmail('howdy@hi5ve.digital')
->first();
DB::table('notifications')
->insert([
'id' => Str::uuid(),
'type' => 'App\Users\Notifications\RegistrationBonusAddedNotification',
'notifiable_type' => 'App\Users\Models\User',
'notifiable_id' => $howdy->id,
'data' => json_encode([
'category' => 'gift',
'title' => 'You Received $10.00',
'description' => 'You received credit bonus $10.00 for your registration. Happy spending!',
]),
'read_at' => now()->subMinutes(5),
'created_at' => now()->subMinutes(5),
'updated_at' => now()->subMinutes(5),
]);
}
private function generateTeamInvitationNotification()
{
$alice = User::whereEmail('alice@hi5ve.digital')
->first();
$howdy = User::whereEmail('howdy@hi5ve.digital')
->first();
$newV2Wallpaper = Folder::factory()
->create([
'user_id' => $alice->id,
'team_folder' => true,
'name' => 'New v2 Wallpaper',
]);
$invitation = TeamFolderInvitation::factory()
->create([
'email' => 'howdy@hi5ve.digital',
'parent_id' => $newV2Wallpaper->id,
'inviter_id' => $newV2Wallpaper->user_id,
'status' => 'pending',
'permission' => 'can-edit',
]);
DB::table('notifications')
->insert([
'id' => Str::uuid(),
'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification',
'notifiable_type' => 'App\Users\Models\User',
'notifiable_id' => $howdy->id,
'data' => json_encode([
'category' => 'team-invitation',
'title' => 'New Team Invitation',
'description' => 'Jane Doe invite you to join into Team Folder.',
'action' => [
'type' => 'invitation',
'params' => [
'id' => $invitation->id,
],
],
]),
'read_at' => now(),
'created_at' => now(),
'updated_at' => now(),
]);
}
private function generateFileRequestFilledNotification()
{
$howdy = User::whereEmail('howdy@hi5ve.digital')
->first();
$sharedFolder = Folder::where('name', 'Shared Folder')
->first();
$fileRequestFolder = Folder::factory()
->create([
'parent_id' => $sharedFolder->id,
'user_id' => $howdy->id,
'team_folder' => false,
'name' => 'Upload Request from 10. Mar. 2022',
]);
DB::table('notifications')
->insert([
'id' => Str::uuid(),
'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification',
'notifiable_type' => 'App\Users\Models\User',
'notifiable_id' => $howdy->id,
'data' => json_encode([
'category' => 'file-request',
'title' => 'File Request Filled',
'description' => "Your file request for 'Shared Folder' folder was filled successfully.",
'action' => [
'type' => 'route',
'params' => [
'route' => 'Files',
'button' => 'Show Files',
'id' => $fileRequestFolder->id,
],
],
]),
'created_at' => now(),
'updated_at' => now(),
]);
// Get meme gallery
collect([
'demo/request/v2-wallpaper.jpg',
])
->each(function ($file) use ($howdy, $fileRequestFolder) {
$thumbnail = $this->generate_thumbnails($file, $howdy);
// Create file record
File::create([
'parent_id' => $fileRequestFolder->id,
'user_id' => $howdy->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
}
/**
* Create default admin account
*/
@@ -830,527 +691,6 @@ class SetupDevEnvironment extends Command
});
}
private function create_team_folders_content(): void
{
$user = User::whereEmail('howdy@hi5ve.digital')
->first();
$alice = User::whereEmail('alice@hi5ve.digital')
->first();
$johan = User::whereEmail('johan@hi5ve.digital')
->first();
$users = [$user, $alice, $johan];
// 1. Company project
$companyProjectFolder = Folder::factory()
->create([
'user_id' => $user->id,
'team_folder' => true,
'name' => 'Company Project',
]);
$presentationMaterial = Folder::factory()
->create([
'user_id' => $user->id,
'parent_id' => $companyProjectFolder->id,
'name' => 'Presentation Materials',
'team_folder' => true,
]);
$teamGallery = Folder::factory()
->create([
'user_id' => $user->id,
'parent_id' => $companyProjectFolder->id,
'name' => 'Team Gallery',
'team_folder' => true,
]);
collect([
'demo/images/team-gallery/photo-1.jpeg',
'demo/images/team-gallery/photo-2.jpeg',
'demo/images/team-gallery/photo-3.jpeg',
])
->each(function ($file) use ($users, $user, $teamGallery) {
$author = $users[rand(0, 2)];
$thumbnail = $this->generate_thumbnails($file, $user);
// Create file record
File::create([
'parent_id' => $teamGallery->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
collect([
'demo/images/presentation/photo-1.jpeg',
'demo/images/presentation/photo-2.jpeg',
])
->each(function ($file) use ($users, $user, $presentationMaterial) {
$author = $users[rand(0, 2)];
$thumbnail = $this->generate_thumbnails($file, $user);
// Create file record
File::create([
'parent_id' => $presentationMaterial->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
// 2. Finance Documents
$financeDocumentsFolder = Folder::factory()
->create([
'user_id' => $user->id,
'team_folder' => true,
'name' => 'Finance Documents',
]);
$reserves = Folder::factory()
->create([
'user_id' => $user->id,
'parent_id' => $financeDocumentsFolder->id,
'name' => 'Reserves',
'team_folder' => true,
]);
$otherDocuments = Folder::factory()
->create([
'user_id' => $user->id,
'parent_id' => $financeDocumentsFolder->id,
'name' => 'Other Documents',
'team_folder' => true,
]);
collect([
'demo/images/finance-documents/photo-1.jpeg',
'demo/images/finance-documents/photo-2.jpeg',
'demo/images/finance-documents/photo-3.jpeg',
])
->each(function ($file) use ($users, $user, $financeDocumentsFolder) {
$author = $users[rand(0, 2)];
$thumbnail = $this->generate_thumbnails($file, $user);
// Create file record
File::create([
'parent_id' => $financeDocumentsFolder->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
collect([
'demo/images/finance-documents/photo-4.jpeg',
'demo/images/finance-documents/photo-5.jpeg',
])
->each(function ($file) use ($users, $user, $reserves) {
$author = $users[rand(0, 2)];
$thumbnail = $this->generate_thumbnails($file, $user);
// Create file record
File::create([
'parent_id' => $reserves->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
// Get documents to root directory
collect([
[
'name' => 'Next Year Projection',
'basename' => 'Licence.pdf',
'mimetype' => 'pdf',
],
[
'name' => 'Budget.pdf',
'basename' => 'Project Notes.pdf',
'mimetype' => 'pdf',
],
[
'name' => '2022 Yearly Report.pages',
'basename' => 'School Report.pages',
'mimetype' => 'pages',
],
[
'name' => 'Company Project Notes.pages',
'basename' => 'Stories of the Night Skies.pages',
'mimetype' => 'pages',
],
[
'name' => 'Finance Stories.pages',
'basename' => 'Stories of the Night Skies.pages',
'mimetype' => 'pages',
],
])
->each(function ($file) use ($users, $user, $financeDocumentsFolder, $otherDocuments) {
$author = $users[rand(0, 2)];
$folder = [$financeDocumentsFolder, $otherDocuments][rand(0, 1)];
$basename = Str::random(12) . '-' . $file['basename'];
// Copy file into app storage
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
// Create file record
File::create([
'parent_id' => $folder->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
// 3. Holiday 2022
$holiday2022Folder = Folder::factory()
->create([
'user_id' => $user->id,
'team_folder' => true,
'name' => 'Holiday 2022',
]);
$destinationGallery = Folder::factory()
->create([
'user_id' => $user->id,
'parent_id' => $holiday2022Folder->id,
'name' => 'Destination Gallery',
'team_folder' => true,
]);
collect([
'demo/images/destination-gallery/photo-1.jpeg',
'demo/images/destination-gallery/photo-2.jpeg',
'demo/images/destination-gallery/photo-3.jpeg',
'demo/images/destination-gallery/photo-4.jpeg',
'demo/images/destination-gallery/photo-5.jpeg',
])
->each(function ($file) use ($users, $user, $destinationGallery) {
$author = $users[rand(0, 2)];
$thumbnail = $this->generate_thumbnails($file, $user);
// Create file record
File::create([
'parent_id' => $destinationGallery->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
// Get documents to root directory
collect([
[
'name' => 'Finance.pages',
'basename' => 'Licence.pdf',
'mimetype' => 'pdf',
],
[
'name' => 'Fly tickets.pdf',
'basename' => 'Project Notes.pdf',
'mimetype' => 'pdf',
],
[
'name' => 'Documentation.pdf',
'basename' => 'School Report.pages',
'mimetype' => 'pages',
],
])
->each(function ($file) use ($users, $user, $holiday2022Folder) {
$author = $users[rand(0, 2)];
$basename = Str::random(12) . '-' . $file['basename'];
// Copy file into app storage
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
// Create file record
File::create([
'parent_id' => $holiday2022Folder->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
collect([$companyProjectFolder, $financeDocumentsFolder, $holiday2022Folder])
->each(function ($folder) use ($user) {
DB::table('team_folder_members')
->insert([
'parent_id' => $folder->id,
'user_id' => $user->id,
'permission' => 'owner',
]);
});
// Attach members
$members = User::whereNotIn('email', ['howdy@hi5ve.digital'])
->get();
collect([$members[0]->id, $members[1]->id, $members[5]->id])
->each(
fn ($id) => DB::table('team_folder_members')
->insert([
'parent_id' => $companyProjectFolder->id,
'user_id' => $id,
'permission' => 'can-edit',
])
);
collect([$members[3]->id, $members[2]->id])
->each(
fn ($id) => DB::table('team_folder_members')
->insert([
'parent_id' => $financeDocumentsFolder->id,
'user_id' => $id,
'permission' => 'can-edit',
])
);
collect([$members[2]->id, $members[3]->id, $members[5]->id, $members[0]->id])
->each(
fn ($id) => DB::table('team_folder_members')
->insert([
'parent_id' => $holiday2022Folder->id,
'user_id' => $id,
'permission' => 'can-edit',
])
);
// Create invitations
collect([$members[4], $members[5]])
->each(
fn ($user) => TeamFolderInvitation::factory()
->create([
'email' => $user->email,
'parent_id' => $companyProjectFolder->id,
'inviter_id' => $companyProjectFolder->user_id,
'status' => 'pending',
'permission' => 'can-edit',
])
);
}
public function create_share_with_me_team_folders_content(): void
{
$member = User::whereEmail('howdy@hi5ve.digital')
->first();
$owner = User::whereEmail('alice@hi5ve.digital')
->first();
$johan = User::whereEmail('johan@hi5ve.digital')
->first();
$users = [$member, $johan];
$folder = Folder::factory()
->create([
'user_id' => $owner->id,
'team_folder' => true,
'name' => "Alice's Project Files",
]);
$videos = Folder::factory()
->create([
'user_id' => $owner->id,
'parent_id' => $folder->id,
'name' => 'Videos',
'team_folder' => true,
]);
$hug = Folder::factory()
->create([
'user_id' => $owner->id,
'parent_id' => $folder->id,
'name' => 'Digital Hug',
'team_folder' => true,
]);
DB::table('team_folder_members')
->insert([
[
'parent_id' => $folder->id,
'user_id' => $member->id,
'permission' => 'can-edit',
],
[
'parent_id' => $folder->id,
'user_id' => $owner->id,
'permission' => 'owner',
],
[
'parent_id' => $folder->id,
'user_id' => $johan->id,
'permission' => 'can-edit',
],
]);
// Get videos
collect([
'Apple Watch App Video Promotion.mp4',
'Smart Watch 3D Device Pack for Element 3D.mp4',
])
->each(function ($file) use ($users, $owner, $videos) {
$author = $users[rand(0, 1)];
$basename = Str::random(12) . '-' . $file;
// Copy file into app storage
Storage::putFileAs("files/$owner->id", storage_path("demo/video/$file"), $basename, 'private');
// Create file record
File::create([
'parent_id' => $videos->id,
'user_id' => $owner->id,
'creator_id' => $author->id,
'name' => $file,
'basename' => $basename,
'type' => 'video',
'mimetype' => 'mp4',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
collect([
[
'name' => 'Notes',
'basename' => 'Licence.pdf',
'mimetype' => 'pdf',
],
])
->each(function ($file) use ($users, $owner, $folder) {
$basename = Str::random(12) . '-' . $file['basename'];
$author = $users[rand(0, 1)];
// Copy file into app storage
Storage::putFileAs("files/$owner->id", storage_path("demo/documents/{$file['basename']}"), $basename, 'private');
// Create file record
File::create([
'parent_id' => $folder->id,
'user_id' => $owner->id,
'creator_id' => $author->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
// Get meme gallery
collect([
'demo/images/memes/Sofishticated.jpg',
'demo/images/memes/whaaaaat.jpg',
])
->each(function ($file) use ($owner, $folder) {
$thumbnail = $this->generate_thumbnails($file, $owner);
// Create file record
File::create([
'parent_id' => $folder->id,
'user_id' => $owner->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
// Get meme gallery
collect([
'demo/images/memes/You Are My Sunshine.jpg',
])
->each(function ($file) use ($johan, $owner, $folder) {
$thumbnail = $this->generate_thumbnails($file, $owner);
// Create file record
File::create([
'parent_id' => $folder->id,
'user_id' => $owner->id,
'creator_id' => $johan->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
collect([
'demo/images/memes/Eggcited bro.jpg',
'demo/images/memes/Get a Rest.jpg',
])
->each(function ($file) use ($member, $owner, $hug) {
$thumbnail = $this->generate_thumbnails($file, $owner);
// Create file record
File::create([
'parent_id' => $hug->id,
'user_id' => $owner->id,
'creator_id' => $member->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
}
private function create_share_records(): void
{
$user = User::whereEmail('howdy@hi5ve.digital')
@@ -1450,14 +790,6 @@ class SetupDevEnvironment extends Command
'name' => 'registration',
'value' => 1,
],
[
'name' => 'user_verification',
'value' => 0,
],
[
'name' => 'allowed_payments',
'value' => 1,
],
[
'name' => 'storage_limitation',
'value' => 1,
@@ -1466,17 +798,13 @@ class SetupDevEnvironment extends Command
'name' => 'default_max_storage_amount',
'value' => 5,
],
[
'name' => 'default_max_team_member',
'value' => 10,
],
[
'name' => 'setup_wizard_success',
'value' => 1,
],
[
'name' => 'license',
'value' => $this->argument('license'),
'value' => 'regular',
],
[
'name' => 'purchase_code',
@@ -1514,30 +842,6 @@ class SetupDevEnvironment extends Command
'name' => 'billing_vat_number',
'value' => '41241241234',
],
[
'name' => 'allowed_registration_bonus',
'value' => 1,
],
[
'name' => 'registration_bonus_amount',
'value' => 10,
],
[
'name' => 'allowed_paypal',
'value' => 1,
],
[
'name' => 'allowed_paystack',
'value' => 1,
],
[
'name' => 'allowed_stripe',
'value' => 1,
],
[
'name' => 'subscription_type',
'value' => 'none',
],
[
'name' => 'allowed_recaptcha',
'value' => 0,

View File

@@ -5,7 +5,6 @@ use App\Users\Models\User;
use Illuminate\Console\Command;
use Domain\Settings\Models\Setting;
use Illuminate\Foundation\Testing\WithFaker;
use Domain\Pages\Actions\SeedDefaultPagesAction;
use Domain\Settings\Actions\SeedDefaultSettingsAction;
use Domain\Localization\Actions\SeedDefaultLanguageAction;
use Domain\SetupWizard\Actions\CreateDiskDirectoriesAction;
@@ -17,7 +16,7 @@ class SetupProdEnvironment extends Command
/**
* The name and signature of the console command.
*/
protected $signature = 'setup:prod {license=extended}';
protected $signature = 'setup:prod';
/**
* The console command description.
@@ -30,7 +29,6 @@ class SetupProdEnvironment extends Command
private CreateDiskDirectoriesAction $createDiskDirectories,
private SeedDefaultSettingsAction $seedDefaultSettings,
private SeedDefaultLanguageAction $seedDefaultLanguage,
private SeedDefaultPagesAction $seedDefaultPages,
) {
parent::__construct();
$this->setUpFaker();
@@ -54,7 +52,6 @@ class SetupProdEnvironment extends Command
$this->info('Storing default settings and content...');
$this->store_default_settings();
($this->seedDefaultPages)();
($this->seedDefaultSettings)($this->argument('license'));
($this->seedDefaultLanguage)();
@@ -129,14 +126,6 @@ class SetupProdEnvironment extends Command
'name' => 'contact_email',
'value' => null,
],
[
'name' => 'registration',
'value' => 0,
],
[
'name' => 'user_verification',
'value' => 0,
],
[
'name' => 'storage_limitation',
'value' => 1,
@@ -145,17 +134,13 @@ class SetupProdEnvironment extends Command
'name' => 'default_max_storage_amount',
'value' => 5,
],
[
'name' => 'default_max_team_member',
'value' => 10,
],
[
'name' => 'setup_wizard_success',
'value' => 1,
],
[
'name' => 'license',
'value' => $this->argument('license'),
'value' => 'regular',
],
[
'name' => 'purchase_code',
@@ -203,20 +188,6 @@ class SetupProdEnvironment extends Command
'value' => $col['value'],
]);
});
if ($this->argument('license') === 'extended') {
$choice = $this->choice('Choose subscription type', [
'metered' => 'Metered',
'fixed' => 'Fixed',
'none' => 'None',
]);
Setting::updateOrCreate([
'name' => 'subscription_type',
], [
'value' => $choice,
]);
}
}
/**

View File

@@ -4,16 +4,12 @@ namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use App\Console\Commands\SetupDevEnvironment;
use App\Console\Commands\SetupProdEnvironment;
use Support\Scheduler\Actions\ReportUsageAction;
use Support\Upgrading\Actions\UpdateSystemAction;
use Support\Demo\Actions\ClearHowdyDemoDataAction;
use App\Console\Commands\SetupWebsocketEnvironment;
use Support\Scheduler\Actions\DeleteFailedFilesAction;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Support\Scheduler\Actions\DeleteUnverifiedUsersAction;
use Support\Scheduler\Actions\DeleteExpiredShareLinksAction;
use App\Console\Commands\GenerateDemoSubscriptionContentCommand;
use Support\Scheduler\Actions\ExpireUnfilledUploadRequestAction;
class Kernel extends ConsoleKernel
{
@@ -26,10 +22,6 @@ class Kernel extends ConsoleKernel
// Basic demo content generator
SetupDevEnvironment::class,
SetupProdEnvironment::class,
SetupWebsocketEnvironment::class,
// Subscription demo generator
GenerateDemoSubscriptionContentCommand::class,
];
/**
@@ -53,10 +45,6 @@ class Kernel extends ConsoleKernel
fn () => resolve(DeleteExpiredShareLinksAction::class)()
)->everyTenMinutes();
$schedule->call(
fn () => resolve(ExpireUnfilledUploadRequestAction::class)()
)->hourly();
$schedule->call(
fn () => resolve(UpdateSystemAction::class)()
)->everyMinute();
@@ -65,10 +53,6 @@ class Kernel extends ConsoleKernel
fn () => resolve(DeleteUnverifiedUsersAction::class)()
)->daily()->at('00:05');
$schedule->call(
fn () => resolve(ReportUsageAction::class)()
)->daily()->at('00:10');
// Run queue jobs every minute
$schedule->command('queue:work --queue=high,default --max-time=300')
->everyFiveMinutes()

View File

@@ -15,7 +15,6 @@ use Illuminate\View\Middleware\ShareErrorsFromSession;
use Support\Middleware\PreventRequestsDuringMaintenance;
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Domain\UploadRequest\Middleware\ProtectUploadRequestRoutes;
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;
@@ -78,6 +77,5 @@ class Kernel extends HttpKernel
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'admin' => AdminCheck::class,
'setup-wizard' => ProtectSetupWizardRoutes::class,
'upload-request' => ProtectUploadRequestRoutes::class,
];
}

View File

@@ -45,9 +45,6 @@ class AuthServiceProvider extends ServiceProvider
if ($user?->id === $item->user_id) {
return true;
}
// Check team member ability to access into requested item
return $this->teamMemberGuard($item, $user, $ability);
});
});
@@ -85,17 +82,4 @@ class AuthServiceProvider extends ServiceProvider
return $share->user_id === $item->user_id;
}
private function teamMemberGuard(Folder | File $item, ?User $user, $ability): bool
{
$teamFolder = $item->getLatestParent();
$membership = DB::table('team_folder_members')
->where('parent_id', $teamFolder->id)
->where('user_id', $user->id)
->first();
// check existing members permission or check team folder owner privileges
return $membership?->permission === $ability || $teamFolder->user_id === Auth::id();
}
}

View File

@@ -2,7 +2,6 @@
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Support\Listeners\SubscriptionEventSubscriber;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
@@ -25,7 +24,7 @@ class EventServiceProvider extends ServiceProvider
* @var array
*/
protected $subscribe = [
SubscriptionEventSubscriber::class,
];
/**

View File

@@ -43,10 +43,6 @@ class RouteServiceProvider extends ServiceProvider
->middleware('api')
->group(base_path('routes/share.php'));
Route::prefix('api/upload-request')
->middleware('api')
->group(base_path('routes/upload-request.php'));
Route::prefix('api/admin')
->middleware(['api', 'auth:sanctum', 'admin'])
->group(base_path('routes/admin.php'));
@@ -64,10 +60,6 @@ class RouteServiceProvider extends ServiceProvider
Route::middleware('web')
->group(base_path('routes/file.php'));
Route::prefix('api/teams')
->middleware(['api'])
->group(base_path('routes/teams.php'));
Route::middleware('web')
->group(base_path('routes/web.php'));
});

View File

@@ -12,32 +12,14 @@ use VueFileManager\Subscription\Domain\Plans\Exceptions\MeteredBillingPlanDoesnt
class CreateNewUserAction extends Controller
{
public function __construct(
protected AutoSubscribeForMeteredBillingAction $autoSubscribeForMeteredBilling,
) {
}
/**
* Validate and create a new user.
*
* @throws MeteredBillingPlanDoesntExist
*/
public function __invoke(CreateUserData $data): User
{
// Check if subscription metered billing plan exist
$this->checkMeteredBillingPlan($data);
// Create user
$user = $this->createUser($data);
// Join to previously accepted team folder invitations
$this->applyExistingTeamInvitations($user);
// Subscribe user for metered billing
if (get_settings('subscription_type') === 'metered' && $data->role !== 'admin') {
($this->autoSubscribeForMeteredBilling)($user);
}
// Mark as verified if verification is disabled
if (! $data->password || ! intval(get_settings('user_verification'))) {
$user->markEmailAsVerified();
@@ -48,43 +30,10 @@ class CreateNewUserAction extends Controller
return $user;
}
/**
* @throws MeteredBillingPlanDoesntExist
*/
private function checkMeteredBillingPlan(CreateUserData $data): void
{
if (get_settings('subscription_type') === 'metered' && $data->role !== 'admin') {
// Get metered plan
$plan = Plan::where('status', 'active')
->where('type', 'metered');
if ($plan->doesntExist()) {
throw new MeteredBillingPlanDoesntExist();
}
}
}
private function applyExistingTeamInvitations(User $user): void
{
TeamFolderInvitation::where('email', $user->email)
->where('status', 'waiting-for-registration')
->cursor()
->each(function ($invitation) use ($user) {
TeamFolderMember::create([
'user_id' => $user->id,
'parent_id' => $invitation->parent_id,
'permission' => $invitation->permission,
]);
$invitation->accept();
});
}
private function createUser(CreateUserData $data): User
{
$user = User::create([
'password' => $data->password ? bcrypt($data->password) : null,
'oauth_provider' => $data->oauth_provider,
'email' => $data->email,
]);

View File

@@ -25,7 +25,7 @@ class CheckAccountController extends Controller
'name' => $user->settings->first_name,
'avatar' => $user->settings->avatar,
'verified' => $user->email_verified_at ? 1 : 0,
'oauth_provider' => $user->password ? null : $user->oauth_provider,
'oauth_provider' => null,
];
}
}

View File

@@ -1,53 +0,0 @@
<?php
namespace App\Users\Controllers\Authentication;
use App\Users\DTO\CreateUserData;
use App\Http\Controllers\Controller;
use App\Users\Actions\CreateNewUserAction;
use App\Users\Requests\RegisterUserRequest;
use Illuminate\Contracts\Auth\StatefulGuard;
use VueFileManager\Subscription\Domain\Plans\Exceptions\MeteredBillingPlanDoesntExist;
class RegisterUserController extends Controller
{
public function __construct(
protected CreateNewUserAction $createNewUser,
protected StatefulGuard $guard,
) {
}
public function __invoke(RegisterUserRequest $request)
{
// Check if account registration is enabled
if (! intval(get_settings('registration'))) {
return response([
'type' => 'error',
'message' => 'User registration is not allowed',
], 401);
}
// Map registration data
$data = CreateUserData::fromArray([
'name' => $request->input('name'),
'email' => $request->input('email'),
'password' => $request->input('password'),
]);
// Register user
try {
$user = ($this->createNewUser)($data);
} catch (MeteredBillingPlanDoesntExist $e) {
return response([
'type' => 'error',
'message' => 'User registrations are temporarily disabled',
], 409);
}
// Log in if verification is disabled
if (! $user->password || ! intval(get_settings('user_verification'))) {
$this->guard->login($user);
}
return response('User successfully registered.', 201);
}
}

View File

@@ -9,7 +9,6 @@ class CreateUserData extends DataTransferObject
public string $name;
public string $email;
public ?string $password;
public ?string $oauth_provider;
public ?string $avatar;
public static function fromRequest($request): self
@@ -20,7 +19,6 @@ class CreateUserData extends DataTransferObject
'email' => $request->input('email'),
'avatar' => $request->input('avatar') ?? null,
'password' => $request->input('password'),
'oauth_provider' => $request->input('oauth_provider') ?? null,
]);
}
@@ -32,7 +30,6 @@ class CreateUserData extends DataTransferObject
'email' => $array['email'],
'avatar' => $array['avatar'] ?? null,
'password' => $array['password'] ?? null,
'oauth_provider' => $array['oauth_provider'] ?? null,
]);
}
}

View File

@@ -15,7 +15,6 @@ use Illuminate\Support\Facades\Storage;
use Illuminate\Notifications\Notifiable;
use App\Users\Notifications\ResetPassword;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Domain\UploadRequest\Models\UploadRequest;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Users\Restrictions\RestrictionsManager;
use Illuminate\Database\Eloquent\Relations\HasOne;
@@ -23,7 +22,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use VueFileManager\Subscription\App\User\Traits\Billable;
/**
* @property string id
@@ -47,7 +45,6 @@ class User extends Authenticatable implements MustVerifyEmail
use Notifiable;
use HasFactory;
use Sortable;
use Billable;
protected $guarded = [
'id',
@@ -57,7 +54,6 @@ class User extends Authenticatable implements MustVerifyEmail
protected $fillable = [
'email',
'password',
'oauth_provider',
];
protected $hidden = [
@@ -138,8 +134,7 @@ class User extends Authenticatable implements MustVerifyEmail
*/
public function favouriteFolders(): BelongsToMany
{
return $this->belongsToMany(Folder::class, 'favourite_folder', 'user_id', 'parent_id', 'id', 'id')
->where('team_folder', false);
return $this->belongsToMany(Folder::class, 'favourite_folder', 'user_id', 'parent_id', 'id', 'id');
}
/**
@@ -182,11 +177,6 @@ class User extends Authenticatable implements MustVerifyEmail
return $this->hasMany(Traffic::class);
}
public function uploadRequest(): HasOne
{
return $this->hasOne(UploadRequest::class);
}
/**
* Send the password reset notification.
*/
@@ -216,7 +206,6 @@ class User extends Authenticatable implements MustVerifyEmail
// Create default limitations
$user->limitations()->create([
'max_storage_amount' => get_settings('default_max_storage_amount') ?? 1,
'max_team_members' => get_settings('default_max_team_member') ?? 10,
]);
// Create user directory for his files

View File

@@ -46,7 +46,6 @@ class UserLimitation extends Model
{
return [
'max_storage_amount' => $this->getMaxStorageAmount(),
'max_team_members' => $this->getMaxTeamMembers(),
];
}
@@ -63,44 +62,4 @@ class UserLimitation extends Model
'percentage' => get_storage_percentage($userCapacity, $this->max_storage_amount),
];
}
/**
* Get usage data of team members
*/
private function getMaxTeamMembers(): array
{
$userTeamFolderIds = DB::table('team_folder_members')
->where('user_id', $this->user_id)
->pluck('parent_id');
$memberIds = DB::table('team_folder_members')
->where('user_id', '!=', $this->user_id)
->whereIn('parent_id', $userTeamFolderIds)
->pluck('user_id')
->unique();
// Get member emails
$memberEmails = User::whereIn('id', $memberIds)
->pluck('email');
// Get active invitation emails
$InvitationEmails = DB::table('team_folder_invitations')
->where('status', 'pending')
->where('inviter_id', $this->user_id)
->pluck('email')
->unique();
// Get allowed emails in the limit
$totalUsedEmails = $memberEmails->merge($InvitationEmails)
->unique();
return [
'use' => $totalUsedEmails->count(),
'total' => (int) $this->max_team_members,
'percentage' => ($totalUsedEmails->count() / $this->max_team_members) * 100,
'meta' => [
'allowed_emails' => $totalUsedEmails,
],
];
}
}

View File

@@ -3,14 +3,6 @@ namespace App\Users\Resources;
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;
use VueFileManager\Subscription\Domain\Subscriptions\Resources\SubscriptionResource;
use VueFileManager\Subscription\Domain\Usage\Actions\SumUsageForCurrentPeriodAction;
use VueFileManager\Subscription\Domain\FailedPayments\Resources\FailedPaymentsCollection;
class UserResource extends JsonResource
{
@@ -22,11 +14,6 @@ class UserResource extends JsonResource
*/
public function toArray($request)
{
$subscriptionType = get_settings('subscription_type');
$isMeteredSubscription = $subscriptionType === 'metered';
$isFixedSubscription = $subscriptionType === 'fixed';
return [
'data' => [
'id' => $this->id,
@@ -44,63 +31,17 @@ class UserResource extends JsonResource
'updated_at' => format_date($this->updated_at, 'd. M. Y'),
],
'relationships' => [
'readNotifications' => new NotificationCollection($this->readNotifications),
'unreadNotifications' => new NotificationCollection($this->unreadNotifications),
'settings' => new SettingsResource($this->settings),
'favourites' => new FolderCollection($this->favouriteFolders),
'creditCards' => new CreditCardCollection($this->creditCards),
$this->mergeWhen($this->hasSubscription(), fn () => [
'subscription' => new SubscriptionResource($this->subscription),
]),
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
'balance' => new BalanceResource($this->balance),
]),
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
'alert' => new BillingAlertResource($this->billingAlert),
]),
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
'failedPayments' => new FailedPaymentsCollection($this->failedPayments),
]),
],
'meta' => [
'restrictions' => [
'canUpload' => $this->canUpload(),
'canDownload' => $this->canDownload(),
'canCreateFolder' => $this->canCreateFolder(),
'canCreateTeamFolder' => $this->canCreateTeamFolder(),
'canInviteTeamMembers' => $this->canInviteTeamMembers(),
],
$this->mergeWhen($isFixedSubscription, fn () => [
'limitations' => $this->limitations->summary(),
]),
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
'usages' => $this->getUsageEstimates(),
]),
$this->mergeWhen($isMeteredSubscription && $this->hasSubscription(), fn () => [
'totalDebt' => [
'formatted' => format_currency($this->failedPayments->sum('amount'), $this->subscription->plan->currency),
'amount' => $this->failedPayments->sum('amount'),
],
]),
],
],
];
}
private function getUsageEstimates()
{
// Get plan currency
$currency = $this->subscription->plan->currency;
// Get usage
$usage = resolve(SumUsageForCurrentPeriodAction::class)($this->subscription);
// Format usages
$estimates = resolve(FormatUsageEstimatesAction::class)($currency, $usage);
return [
'costEstimate' => format_currency($estimates->sum('amount'), $currency),
'featureEstimates' => $estimates->toArray(),
];
}
}

View File

@@ -18,11 +18,7 @@ class UserStorageResource extends JsonResource
list($images, $audios, $videos, $documents, $others) = $this->get_file_type_distribution();
list($downloadTotal, $uploadTotal, $upload, $download) = $this->get_traffic_distribution();
$totalCapacity = match (get_settings('subscription_type')) {
'metered' => $this->usedCapacity / 1000000000,
'fixed' => $this->limitations->max_storage_amount,
default => $this->limitations->max_storage_amount,
};
$totalCapacity = $this->limitations->max_storage_amount;
return [
'data' => [

View File

@@ -33,16 +33,6 @@ class DefaultRestrictionsEngine implements RestrictionsEngine
return true;
}
public function canCreateTeamFolder(User $user): bool
{
return true;
}
public function canInviteTeamMembers(User $user, array $newInvites = []): bool
{
return true;
}
public function canVisitShared(User $user): bool
{
return true;

View File

@@ -11,9 +11,5 @@ interface RestrictionsEngine
public function canCreateFolder(User $user): bool;
public function canCreateTeamFolder(User $user): bool;
public function canInviteTeamMembers(User $user, array $newInvites = []): bool;
public function canVisitShared(User $user): bool;
}

View File

@@ -3,8 +3,6 @@ namespace App\Users\Restrictions;
use Illuminate\Support\Manager;
use App\Users\Restrictions\Engines\DefaultRestrictionsEngine;
use App\Users\Restrictions\Engines\FixedBillingRestrictionsEngine;
use App\Users\Restrictions\Engines\MeteredBillingRestrictionsEngine;
class RestrictionsManager extends Manager
{

View File

@@ -21,11 +21,6 @@ class DeleteUserDataAction
// Delete all user files
Storage::deleteDirectory("files/$user->id");
// Delete user subscriptions
if ($user->subscription) {
$user->subscription->delete();
}
// Delete all user records in database
collect(['folders', 'files', 'user_settings', 'shares', 'favourite_folder', 'traffic'])
->each(function ($table) use ($user) {

View File

@@ -6,7 +6,6 @@ use App\Users\Models\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
class GetDashboardDataController extends Controller
{
@@ -15,16 +14,9 @@ class GetDashboardDataController extends Controller
// Get bandwidth data
list($upload, $download, $uploadTotal, $downloadTotal, $storageUsage) = $this->getDiskData();
// Get total earnings from transactions
$totalEarnings = DB::table('transactions')
->where('status', 'completed')
->where('type', 'charge')
->sum('amount');
return response()->json([
'users' => [
'total' => User::count(),
'usersPremiumTotal' => Subscription::count(),
],
'disk' => [
'used' => $storageUsage,
@@ -41,7 +33,6 @@ class GetDashboardDataController extends Controller
'isRunningCron' => isRunningCron(),
'license' => get_settings('license'),
'version' => config('vuefilemanager.version'),
'earnings' => format_currency($totalEarnings, 'USD'), // todo: refactor currency to global setup or plan currency
],
]);
}

View File

@@ -20,7 +20,6 @@ class BrowseFolderController
$folders = Folder::with(['parent:id,name', 'shared:token,id,item_id,permission,is_protected,expire_in'])
->where('parent_id', $root_id)
->where('team_folder', false)
->where('user_id', Auth::id())
->sortable()
->get();

View File

@@ -53,18 +53,12 @@ class SpotlightSearchController
{
$user_id = Auth::id();
// Get "shared with me" folders
$sharedWithMeFolderIds = DB::table('team_folder_members')
->where('user_id', $user_id)
->pluck('parent_id');
// Next get their folder tree for ids extraction
$folderWithinIds = Folder::with('folders:id,parent_id')
->whereIn('parent_id', $sharedWithMeFolderIds)
->get(['id']);
// Then get all accessible shared folders within
$accessible_parent_ids = Arr::flatten([filter_folders_ids($folderWithinIds), $sharedWithMeFolderIds]);
$accessible_parent_ids = Arr::flatten([filter_folders_ids($folderWithinIds)]);
// Prepare eloquent builder
$folder = new Folder();

View File

@@ -60,19 +60,10 @@ class GetFileParentId
private function createFolder($directoryName, $userId, $parentId): Folder
{
/*
* Check if exist parent team folder, if yes,
* then get the latest parent folder to detect whether it is team_folder
*/
if ($parentId) {
$isTeamFolder = Folder::find($parentId)->getLatestParent()->team_folder;
}
return Folder::create([
'name' => $directoryName,
'parent_id' => $parentId,
'user_id' => $userId,
'team_folder' => $isTeamFolder ?? false,
]);
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Domain\Files\Requests;
use Domain\Admin\Rules\DisabledMimetypes;
use Illuminate\Foundation\Http\FormRequest;
class UploadRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|string',
'parent_id' => 'nullable|uuid',
'path' => 'required|string',
'is_last' => 'sometimes|string',
'extension' => 'sometimes|string|nullable',
'file' => ['required', 'file', new DisabledMimetypes],
];
}
}

View File

@@ -39,9 +39,6 @@ class CreateFolderAction
'emoji' => $request->input('emoji') ?? null,
'author' => $shared ? 'visitor' : 'user',
'user_id' => $user->id,
'team_folder' => $isFilledParentId
? Folder::find($parentId)->getLatestParent()->team_folder
: false,
]);
}
}

View File

@@ -10,30 +10,10 @@ class NavigationTreeController
public function __invoke(): array
{
// Get signed user folders
$folders = Folder::with('folders:id,parent_id,name,team_folder')
$folders = Folder::with('folders:id,parent_id,name')
->where('parent_id')
->where('team_folder', false)
->where('user_id', Auth::id())
->sortable()
->get(['id', 'parent_id', 'name', 'team_folder']);
// Get signed user team folders
$teamFolders = Folder::with('folders:id,parent_id,name,team_folder')
->where('parent_id')
->where('team_folder', true)
->where('user_id', Auth::id())
->sortable()
->get(['id', 'parent_id', 'name']);
// Get signed user folder which are shared with him
$sharedFolderIds = DB::table('team_folder_members')
->where('user_id', Auth::id())
->whereIn('permission', ['can-edit', 'can-view'])
->pluck('parent_id');
$sharedWithMeFolders = Folder::with('folders:id,parent_id,name,team_folder')
->whereIn('id', $sharedFolderIds)
->sortable()
->get(['id', 'parent_id', 'name']);
return [
@@ -44,20 +24,6 @@ class NavigationTreeController
'isMovable' => true,
'isOpen' => true,
],
[
'location' => 'team-folders',
'name' => __t('team_folders'),
'folders' => $teamFolders,
'isMovable' => false,
'isOpen' => false,
],
[
'location' => 'shared-with-me',
'name' => __t('shared_with_me'),
'folders' => $sharedWithMeFolders,
'isMovable' => false,
'isOpen' => false,
],
];
}
}

View File

@@ -10,7 +10,6 @@ use Kyslik\ColumnSortable\Sortable;
use Database\Factories\FolderFactory;
use Illuminate\Database\Eloquent\Model;
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
use Domain\Teams\Models\TeamFolderInvitation;
use \Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -34,7 +33,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
* @property string created_at
* @property string updated_at
* @property string deleted_at
* @property bool team_folder
*/
class Folder extends Model
{
@@ -54,7 +52,6 @@ class Folder extends Model
protected $casts = [
'emoji' => 'array',
'team_folder' => 'boolean',
];
public $sortable = [
@@ -180,18 +177,6 @@ class Folder extends Model
return $this->hasOne(Share::class, 'item_id', 'id');
}
public function teamInvitations(): HasMany
{
return $this->hasMany(TeamFolderInvitation::class, 'parent_id', 'id')
->where('status', 'pending');
}
public function teamMembers(): BelongsToMany
{
return $this->belongsToMany(User::class, 'team_folder_members', 'parent_id', 'user_id')
->withPivot('permission');
}
public function user(): HasOne
{
return $this->hasOne(User::class, 'id', 'user_id');

View File

@@ -19,7 +19,7 @@ class FolderResource extends JsonResource
'color' => $this->color,
'emoji' => $this->emoji,
'filesize' => $this->filesize,
'isTeamFolder' => $this->team_folder,
'isTeamFolder' => false,
'items' => $this->items,
'trashed_items' => $this->trashed_items,
'created_at' => set_time_by_user_timezone($this->user, $this->created_at),
@@ -29,12 +29,6 @@ class FolderResource extends JsonResource
: null,
],
'relationships' => [
$this->mergeWhen($this->teamMembers, fn () => [
'members' => new TeamMembersCollection($this->teamMembers),
]),
$this->mergeWhen($this->teamInvitations, fn () => [
'invitations' => new TeamInvitationsCollection($this->teamInvitations),
]),
$this->mergeWhen($this->shared, fn () => [
'shared' => new ShareResource($this->shared),
]),
@@ -49,19 +43,6 @@ class FolderResource extends JsonResource
],
],
]),
$this->mergeWhen($this->user, fn () => [
'user' => [
'data' => [
'type' => 'user',
'id' => $this->user_id,
'attributes' => [
'name' => $this->user->settings->name,
'avatar' => $this->user->settings->avatar,
'color' => $this->user->settings->color,
],
],
],
]),
],
],
];

View File

@@ -30,9 +30,6 @@ class IndexController
// Get setup status
$setup_status = get_setup_status();
// Get app pages
$pages = Page::all();
// Get all settings
$settings = get_settings_in_json();
} catch (PDOException $e) {
@@ -45,7 +42,6 @@ class IndexController
return view('index')
->with('status_check', $status_check ?? [])
->with('settings', $settings ?? null)
->with('legal', $pages ?? null)
->with('installation', $setup_status);
}
}

View File

@@ -3,16 +3,9 @@ namespace Domain\Items\Actions;
use Gate;
use Domain\Sharing\Models\Share;
use Domain\Folders\Models\Folder;
use Domain\Teams\Actions\SetTeamFolderPropertyForAllChildrenAction;
class MoveFileOrFolderAction
{
public function __construct(
public SetTeamFolderPropertyForAllChildrenAction $setTeamFolderPropertyForAllChildren,
) {
}
/**
* Move folder or file to new location
*/
@@ -24,30 +17,10 @@ class MoveFileOrFolderAction
// Check permission
Gate::authorize('can-edit', [$entry, $share]);
// Process folder
if ($item['type'] === 'folder') {
// Determine, if we are moving folder into the team folder or not
$isTeamFolder = is_null($request->input('to_id'))
? false
: Folder::find($request->input('to_id'))->getLatestParent()->team_folder;
// Change team_folder mark for all children folders
($this->setTeamFolderPropertyForAllChildren)($entry, $isTeamFolder);
// Update folder
$entry->update([
'parent_id' => $request->input('to_id'),
'team_folder' => $isTeamFolder,
]);
}
// Process file
if ($item['type'] !== 'folder') {
// Update file
$entry->update([
'parent_id' => $request->input('to_id'),
]);
}
// Update item
$entry->update([
'parent_id' => $request->input('to_id'),
]);
}
}
}

View File

@@ -9,12 +9,10 @@ class SeedDefaultSettingsAction
/**
* Store default VueFileManager settings into database
*/
public function __invoke(
string $license
): void {
public function __invoke(): void {
// Set default settings
collect(
config('content.content.' . strtolower($license))
config('content.content.regular')
)->each(fn ($content) => Setting::updateOrCreate([
'name' => $content['name'],
], [
@@ -23,6 +21,6 @@ class SeedDefaultSettingsAction
// Set update records
collect(config('vuefilemanager.updates'))
->each(fn ($version) => AppUpdate::create(['version' => $version]));
->each(fn ($version) => AppUpdate::create(['version' => 'regular']));
}
}

View File

@@ -29,21 +29,6 @@ class UpdateSettingValueController extends Controller
return response('Done', 204);
}
// Set paypal live option
if ($request->input('name') === 'paypal_live') {
setEnvironmentValue([
'PAYPAL_IS_LIVE' => $request->input('value') ? 'true' : 'false',
]);
// Clear config cache
if (! is_dev()) {
Artisan::call('config:clear');
Artisan::call('config:cache');
}
return response('Done', 204);
}
// Find and update variable
Setting::updateOrCreate(
['name' => $request->input('name')],

View File

@@ -1,102 +0,0 @@
<?php
namespace Domain\Settings\Controllers;
use DB;
use Artisan;
use Illuminate\Http\Response;
use Domain\Settings\Models\Setting;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Http;
use Domain\Localization\Models\Language;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory;
use Domain\Settings\Requests\UpgradeLicenseRequest;
class UpgradeLicenseController extends Controller
{
public function __invoke(UpgradeLicenseRequest $request): Response|Application|ResponseFactory
{
// Verify purchase code
$response = Http::get("https://verify.vuefilemanager.com/api/verify-code/{$request->input('purchaseCode')}");
if ($response->successful() && $response->body() === 'b6896a44017217c36f4a6fdc56699728') {
// Store default settings for extended version
collect([
[
'name' => 'license',
'value' => 'extended',
],
[
'name' => 'purchase_code',
'value' => $request->input('purchaseCode'),
],
[
'name' => 'section_pricing_content',
'value' => 1,
],
[
'name' => 'paypal_payment_description',
'value' => 'Available PayPal Credit, Debit or Credit Card.',
],
[
'name' => 'paystack_payment_description',
'value' => 'Available Bank Account, USSD, Mobile Money, Apple Pay.',
],
[
'name' => 'stripe_payment_description',
'value' => 'Available credit card or Apple Pay.',
],
[
'name' => 'allowed_registration_bonus',
'value' => 0,
],
[
'name' => 'registration_bonus_amount',
'value' => 0,
],
[
'name' => 'pricing_title',
'value' => 'Pick the <span class="text-theme">Best Plan</span> For Your Needs',
],
[
'name' => 'pricing_description',
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
],
])->each(function ($col) {
Setting::updateOrCreate([
'name' => $col['name'],
], [
'value' => $col['value'],
]);
});
// Seed translations for extended version
Language::all()
->each(function ($lang) {
$translations = collect(
config('language-translations.extended')
)
->map(fn ($value, $key) => [
'lang' => $lang->locale,
'value' => $value,
'key' => $key,
])->toArray();
$chunks = array_chunk($translations, 100);
foreach ($chunks as $chunk) {
DB::table('language_translations')
->insert($chunk);
}
});
// Clear config and cache
Artisan::call('config:clear');
Artisan::call('cache:clear');
return response('Your license was successfully upgraded', 201);
}
return response('Purchase code is invalid or is not Extended License.', 400);
}
}

View File

@@ -7,7 +7,6 @@ use Illuminate\Http\Response;
use Domain\Settings\Models\Setting;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\StatefulGuard;
use Domain\Pages\Actions\SeedDefaultPagesAction;
use Domain\Settings\Actions\SeedDefaultSettingsAction;
use Domain\SetupWizard\Requests\StoreAdminAccountRequest;
use Domain\Localization\Actions\SeedDefaultLanguageAction;
@@ -20,7 +19,6 @@ class CreateAdminAccountController extends Controller
{
public function __construct(
protected StatefulGuard $guard,
public SeedDefaultPagesAction $seedDefaultPages,
public SeedDefaultLanguageAction $seedDefaultLanguage,
public CreateDiskDirectoriesAction $createDiskDirectories,
public SeedDefaultSettingsAction $seedDefaultSettingsAction,
@@ -58,7 +56,7 @@ class CreateAdminAccountController extends Controller
],
[
'name' => 'license',
'value' => strtolower($request->input('license')),
'value' => 'regular',
],
[
'name' => 'purchase_code',
@@ -79,8 +77,7 @@ class CreateAdminAccountController extends Controller
Artisan::call('config:clear');
// Set up application
($this->seedDefaultPages)();
($this->seedDefaultSettingsAction)($request->input('license'));
($this->seedDefaultSettingsAction)();
($this->seedDefaultLanguage)();
return response('Registration was successful', 204);

View File

@@ -16,10 +16,6 @@ class StoreAppSettingsController extends Controller
StoreAppSetupRequest $request
): Response {
collect([
[
'name' => 'subscription_type',
'value' => $request->input('subscriptionType') ?? 'none',
],
[
'name' => 'app_color',
'value' => $request->input('color'),
@@ -68,10 +64,6 @@ class StoreAppSettingsController extends Controller
'name' => 'contact_email',
'value' => $request->input('contactMail'),
],
[
'name' => 'registration',
'value' => $request->input('userRegistration'),
],
[
'name' => 'storage_limitation',
'value' => $request->input('storageLimitation'),
@@ -80,14 +72,6 @@ class StoreAppSettingsController extends Controller
'name' => 'default_max_storage_amount',
'value' => $request->input('defaultStorage') ?? 5,
],
[
'name' => 'default_max_team_member',
'value' => $request->input('teamsDefaultMembers') ?? 10,
],
[
'name' => 'user_verification',
'value' => 0,
],
])->each(function ($col) {
Setting::updateOrCreate([
'name' => $col['name'],

View File

@@ -83,31 +83,6 @@ class StoreEnvironmentSettingsController extends Controller
};
$setup = [
'broadcasting' => [
'pusher' => [
'BROADCAST_DRIVER' => 'pusher',
'PUSHER_APP_ID' => $request->input('broadcast.id'),
'PUSHER_APP_KEY' => $request->input('broadcast.key'),
'PUSHER_APP_SECRET' => $request->input('broadcast.secret'),
'PUSHER_APP_CLUSTER' => $request->input('broadcast.cluster'),
'PUSHER_APP_HOST' => '',
'PUSHER_APP_PORT' => '',
'PUSHER_APP_TLS' => true,
],
'native' => [
'BROADCAST_DRIVER' => 'pusher',
'PUSHER_APP_ID' => 'local',
'PUSHER_APP_KEY' => 'local',
'PUSHER_APP_SECRET' => 'local',
'PUSHER_APP_CLUSTER' => 'local',
'PUSHER_APP_HOST' => $request->input('broadcast.host'),
'PUSHER_APP_PORT' => '',
'PUSHER_APP_TLS' => $request->boolean('tls') ? 'true' : 'false',
],
'none' => [
'BROADCAST_DRIVER' => 'null',
],
],
'drivers' => [
'local' => [
'FILESYSTEM_DISK' => 'local',
@@ -184,7 +159,6 @@ class StoreEnvironmentSettingsController extends Controller
// Set other environment variables
setEnvironmentValue(array_merge(
$setup['broadcasting'][$request->input('broadcast.driver')],
$setup['environment'][$request->input('environment')],
$setup['mail'][$request->input('mailDriver')],
$setup['drivers'][$StorageDriver],

View File

@@ -27,7 +27,6 @@ class StoreAdminAccountRequest extends FormRequest
'password' => 'required|string|min:6|confirmed',
'name' => 'required|string',
'purchase_code' => 'required|string',
'license' => 'required|string',
'avatar' => 'sometimes|file',
];
}

View File

@@ -31,7 +31,6 @@ class StoreAppSetupRequest extends FormRequest
'contactMail' => 'required|email',
'googleAnalytics' => 'sometimes|string',
'defaultStorage' => 'sometimes|digits_between:1,9',
'userRegistration' => 'required|boolean',
'storageLimitation' => 'required|boolean',
];
}

View File

@@ -23,7 +23,6 @@ class StoreEnvironmentSetupRequest extends FormRequest
public function rules()
{
return [
'broadcast' => 'required|array',
'storage' => 'required|array',
'environment' => 'required|string',
'storage.driver' => 'required|string',

View File

@@ -17,14 +17,5 @@ class ClearHowdyDemoDataAction
DB::table('shares')
->where('user_id', $user->id)
->delete();
// Delete File request
UploadRequest::where('user_id', $user->id)
->cursor()
->each(function ($request) {
if ($request->created_at->diffInHours(now()) >= 6) {
$request->delete();
}
});
}
}

View File

@@ -19,119 +19,5 @@ class UpgradingVersionsController
public UpgradeDatabaseAction $upgradeDatabase,
public DeleteLanguageTranslationsAction $deleteLanguageStrings,
public UpdateLanguageTranslationsAction $updateLanguageStrings,
) {
}
public function upgrade_to_2_1_1(): void
{
($this->upgradeDatabase)();
}
public function upgrade_to_2_0_10(): void
{
($this->upgradeDatabase)();
// Upgrade team folder content ownership
Folder::where('parent_id', null)
->where('team_folder', true)
->cursor()
->each(function ($teamFolder) {
// Get all inherited folder from team folder
$childrenFolderIds = Folder::with('folders:id,parent_id')
->where('id', $teamFolder->id)
->get('id');
$teamFolderIds = Arr::flatten(filter_folders_ids($childrenFolderIds));
// Replace user content ownership for author of team folder
DB::table('files')
->whereIn('parent_id', $teamFolderIds)
->cursor()
->each(function ($file) use ($teamFolder) {
// Move image thumbnails
if ($file->type === 'image') {
// Get image thumbnail list
$thumbnailList = getThumbnailFileList($file->basename);
// move thumbnails to the new location
$thumbnailList->each(function ($basename) use ($file, $teamFolder) {
$oldPath = "files/$file->user_id/$basename";
$newPath = "files/$teamFolder->user_id/$basename";
if (Storage::exists($oldPath)) {
Storage::move($oldPath, $newPath);
}
});
}
// Get single file path
$filePath = "files/$file->user_id/$file->basename";
// Move single file
if (Storage::exists($filePath)) {
Storage::move($filePath, "files/$teamFolder->user_id/$file->basename");
}
// Update file permission
File::find($file->id)->update([
'user_id' => $teamFolder->user_id,
'creator_id' => $teamFolder->user_id !== $file->user_id ? $file->user_id : null,
]);
});
// Update folder ownership
DB::table('folders')
->whereIn('parent_id', $teamFolderIds)
->update(['user_id' => $teamFolder->user_id]);
});
// Upgrade dwg files
File::withTrashed()
->where('mimetype', 'vnd.dwg')
->cursor()
->each(fn ($file) => $file->update([
'mimetype' => 'dwg',
'type' => 'file',
]));
}
public function upgrade_to_2_0_13(): void
{
// Force plan synchronization
if (get_settings('license') === 'extended' && Plan::count() !== 0) {
Artisan::call('subscription:synchronize-plans');
}
}
public function upgrade_to_2_0_14(): void
{
($this->upgradeDatabase)();
User::whereNotNull('two_factor_secret')
->cursor()
->each(fn ($user) => $user->forceFill(['two_factor_confirmed_at' => now()])->save());
($this->deleteLanguageStrings)([
'popup_2fa.disappear_qr',
]);
($this->updateLanguageStrings)([
'require_email_verification' => 'Require Verify Email Address',
'require_email_verification_note' => 'Turn on, if you want to verify user email address after registration.',
]);
Artisan::call('cache:clear');
}
public function upgrade_to_2_0_16(): void
{
($this->updateLanguageStrings)([
'write_feedback' => 'Help Us Improve',
'change_password' => 'Security & API',
'shared.empty_shared' => 'Nothing Shared Yet',
'admin_settings.others.default_storage' => 'Default Storage Space for User Accounts (in GB)',
]);
Artisan::call('cache:clear');
}
) {}
}

View File

@@ -38,16 +38,6 @@ if (! function_exists('getListOfLatestLogs')) {
}
}
if (! function_exists('isBroadcasting')) {
/**
* Check if cron is running
*/
function isBroadcasting(): bool
{
return config('broadcasting.default') === 'pusher';
}
}
if (! function_exists('isRunningCron')) {
/**
* Check if cron is running
@@ -91,20 +81,6 @@ if (! function_exists('obfuscate_email')) {
}
}
if (! function_exists('get_restriction_driver')) {
/**
* Get driver for limitation API
*/
function get_restriction_driver(): string
{
return match (get_settings('subscription_type')) {
'fixed' => 'fixed',
'metered' => 'metered',
default => 'default',
};
}
}
if (! function_exists('get_email_provider')) {
/**
* Get single or multiple values from settings table
@@ -239,24 +215,6 @@ if (! function_exists('setEnvironmentValue')) {
}
}
if (! function_exists('get_invoice_number')) {
/**
* Get invoice number
*
* @return string
*/
function get_invoice_number()
{
$invoices = \App\Invoice::all();
if ($invoices->isEmpty()) {
return now()->year . '001';
}
return (int) $invoices->last()->order + 1;
}
}
if (! function_exists('cache_forget_many')) {
/**
* Forget many cache keys at once
@@ -270,18 +228,6 @@ if (! function_exists('cache_forget_many')) {
}
}
if (! function_exists('get_storage')) {
/**
* Get app version from config
*
* @return \Illuminate\Config\Repository|mixed
*/
function get_storage()
{
return config('filesystems.default');
}
}
if (! function_exists('isStorageDriver')) {
/**
* Check if is running AWS s3 as storage
@@ -1067,29 +1013,6 @@ if (! function_exists('replace_occurrence')) {
);
}
if (! function_exists('get_socialite_avatar')) {
/**
* Get socialite avatar create and store his thumbnails
*/
function store_socialite_avatar($avatar)
{
// Get image from external source
$image = Http::get($avatar)->body();
// Generate avatar name
$avatar_name = Str::uuid() . '.jpg';
// Create intervention image
$intervention = Image::make($image);
// Generate avatar sizes
generate_avatar_thumbnails($intervention, $avatar_name);
// Return name of image
return $avatar_name;
}
}
if (! function_exists('generate_avatar_thumbnails')) {
/**
* Create avatar thumbnails
@@ -1124,39 +1047,4 @@ if (! function_exists('replace_occurrence')) {
return "{$degrees}°$minutes'$seconds\"$ref";
}
}
if (! function_exists('extractExtensionFromUrl')) {
/**
* Extract extension from the url
*
* TODO: make unit test
*/
function extractExtensionFromUrl($url, $response): string|null
{
$extension = null;
if (array_key_exists('extension', pathinfo($url))) {
// Break attributes
$string = str_replace(['&'], '?', pathinfo($url)['extension']);
// Get extension from url path
$extension = explode('?', $string)[0];
}
// Return pure extension
if ($extension) {
return $extension;
}
// Prepare header for extracting content-type line
$header = array_change_key_case($response->headers(), CASE_LOWER);
// Get extension
if (array_key_exists('content-type', $header)) {
return explode('/', $header['content-type'][0])[1];
}
return null;
}
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -1,47 +0,0 @@
<?php
namespace Tests\App\Restrictions;
use Tests\TestCase;
use Domain\Settings\Models\Setting;
class RestrictionsTest extends TestCase
{
/**
* @test
*/
public function it_get_metered_driver()
{
Setting::updateOrCreate([
'name' => 'subscription_type',
], [
'value' => 'metered',
]);
$this->assertEquals('metered', get_restriction_driver());
}
/**
* @test
*/
public function it_get_fixed_driver()
{
Setting::updateOrCreate([
'name' => 'subscription_type',
], [
'value' => 'fixed',
]);
$this->assertEquals('fixed', get_restriction_driver());
}
/**
* @test
*/
public function it_get_default_driver()
{
$subscriptionType = Setting::where('name', 'subscription_type')
->first();
$subscriptionType?->delete();
$this->assertEquals('default', get_restriction_driver());
}
}

View File

@@ -15,239 +15,6 @@ use App\Users\Notifications\RegistrationBonusAddedNotification;
class SignFlowTest extends TestCase
{
/**
* @test
*/
public function it_create_user_from_register_form()
{
collect([
[
'name' => 'user_verification',
'value' => 1,
],
[
'name' => 'default_max_storage_amount',
'value' => 10,
],
])->each(function ($setting) {
Setting::updateOrCreate([
'name' => $setting['name'],
], [
'value' => $setting['value'],
]);
});
$this->postJson('api/register', [
'role' => 'admin',
'email' => 'john@doe.com',
'password' => 'SecretPassword',
'password_confirmation' => 'SecretPassword',
'name' => 'John Doe',
])->assertStatus(201);
$this
->assertDatabaseHas('users', [
'email' => 'john@doe.com',
'email_verified_at' => null,
'role' => 'user',
])
->assertDatabaseHas('user_settings', [
'first_name' => 'John',
'last_name' => 'Doe',
])
->assertDatabaseHas('user_limitations', [
'max_storage_amount' => 10,
]);
Storage::disk('local')
->assertExists('files/' . User::first()->id);
Notification::assertTimesSent(1, VerifyEmail::class);
}
/**
* @test
*/
public function it_register_user_when_metered_billing_is_active()
{
// Seed default settings
collect([
[
'name' => 'subscription_type',
'value' => 'metered',
],
[
'name' => 'allowed_registration_bonus',
'value' => 0,
],
[
'name' => 'registration_bonus_amount',
'value' => 15,
],
])->each(function ($setting) {
Setting::updateOrCreate([
'name' => $setting['name'],
], [
'value' => $setting['value'],
]);
});
// Create metered plan
$plan = Plan::factory()
->create([
'status' => 'active',
'type' => 'metered',
'currency' => 'USD',
]);
$this->postJson('api/register', [
'role' => 'admin',
'email' => 'john@doe.com',
'password' => 'SecretPassword',
'password_confirmation' => 'SecretPassword',
'name' => 'John Doe',
])->assertStatus(201);
$this
->assertDatabaseCount('transactions', 0)
->assertDatabaseHas('users', [
'role' => 'user',
'email' => 'john@doe.com',
])
->assertDatabaseHas('subscriptions', [
'status' => 'active',
'name' => $plan->name,
'ends_at' => null,
'renews_at' => now()->addDays(config('subscription.metered_billing.settlement_period')),
])
->assertDatabaseHas('balances', [
'currency' => 'USD',
'amount' => 0,
])
->assertDatabaseHas('user_settings', [
'first_name' => 'John',
'last_name' => 'Doe',
]);
}
/**
* @test
*/
public function it_register_user_when_metered_billing_is_active_with_registration_bonus()
{
// Seed default settings
collect([
[
'name' => 'subscription_type',
'value' => 'metered',
],
[
'name' => 'allowed_registration_bonus',
'value' => 1,
],
[
'name' => 'registration_bonus_amount',
'value' => 15,
],
])->each(function ($setting) {
Setting::updateOrCreate([
'name' => $setting['name'],
], [
'value' => $setting['value'],
]);
});
// Create metered plan
$plan = Plan::factory()
->create([
'status' => 'active',
'type' => 'metered',
'currency' => 'USD',
]);
$this->postJson('api/register', [
'role' => 'admin',
'email' => 'john@doe.com',
'password' => 'SecretPassword',
'password_confirmation' => 'SecretPassword',
'name' => 'John Doe',
])->assertStatus(201);
$user = User::first();
$this
->assertDatabaseHas('users', [
'role' => 'user',
'email' => 'john@doe.com',
])
->assertDatabaseHas('subscriptions', [
'status' => 'active',
'name' => $plan->name,
'ends_at' => null,
'renews_at' => now()->addDays(config('subscription.metered_billing.settlement_period')),
])
->assertDatabaseHas('balances', [
'currency' => 'USD',
'amount' => 15,
])
->assertDatabaseHas('transactions', [
'user_id' => $user->id,
'amount' => 15.00,
'currency' => 'USD',
'status' => 'completed',
'type' => 'credit',
'driver' => 'system',
])
->assertDatabaseHas('user_settings', [
'first_name' => 'John',
'last_name' => 'Doe',
]);
Notification::assertSentTo($user, RegistrationBonusAddedNotification::class);
}
/**
* @test
*/
public function it_try_register_when_registration_is_disabled()
{
Setting::updateOrCreate([
'name' => 'registration',
], [
'value' => 0,
]);
$this->postJson('api/register', [
'email' => 'john@doe.com',
'password' => 'SecretPassword',
'password_confirmation' => 'SecretPassword',
'name' => 'John Doe',
])->assertStatus(401);
$this->assertDatabaseMissing('users', [
'email' => 'john@doe.com',
'email_verified_at' => null,
]);
}
/**
* @test
*/
public function it_try_register_from_disabled_email_provider()
{
$this->postJson('api/register', [
'email' => 'john@maildrop.cc',
'password' => 'SecretPassword',
'password_confirmation' => 'SecretPassword',
'name' => 'John Doe',
])->assertStatus(422);
$this->assertDatabaseMissing('users', [
'email' => 'john@doe.com',
'email_verified_at' => null,
]);
}
/**
* @test
*/
@@ -339,33 +106,4 @@ class SignFlowTest extends TestCase
'email' => $user->email,
]);
}
/**
* @test
*/
public function it_create_user_from_register_form_with_reCaptcha()
{
Setting::updateOrCreate([
'name' => 'allowed_recaptcha',
], [
'value' => 1,
]);
$this->mock(ReCaptchaRules::class, function ($mock) {
$mock->shouldReceive('passes')->andReturn(true);
});
$this->postJson('api/register', [
'email' => 'john@doe.com',
'password' => 'SecretPassword',
'password_confirmation' => 'SecretPassword',
'name' => 'John Doe',
'reCaptcha' => 'fakeToken',
])->assertStatus(201);
$this
->assertDatabaseHas('users', [
'email' => 'john@doe.com',
]);
}
}

View File

@@ -170,16 +170,11 @@ class UserAccountTest extends TestCase
'meta' => [
'restrictions' => [
'canCreateFolder' => true,
'canCreateTeamFolder' => true,
'canDownload' => true,
'canInviteTeamMembers' => true,
'canUpload' => true,
],
],
'relationships' => [
'creditCards' => [
'data' => [],
],
'settings' => [
'data' => [
'id' => (string) $user->id,
@@ -202,12 +197,6 @@ class UserAccountTest extends TestCase
'favourites' => [
'data' => [],
],
'readNotifications' => [
'data' => [],
],
'unreadNotifications' => [
'data' => [],
],
],
],
]);

View File

@@ -77,24 +77,6 @@ class AdminTest extends TestCase
]);
}
/**
* todo: complete test
*/
public function it_get_non_existed_user_subscription()
{
$user = User::factory()
->hasSettings()
->create();
$admin = User::factory()
->create(['role' => 'admin']);
$this
->actingAs($admin)
->getJson("/api/admin/users/$user->id/subscription")
->assertStatus(404);
}
/**
* @test
*/

View File

@@ -25,14 +25,12 @@ class DashboardTest extends TestCase
->assertStatus(200)
->assertJsonFragment([
'app' => [
'earnings' => '$0.00',
'isRunningCron' => false,
'license' => 'extended',
'license' => 'regular',
'version' => config('vuefilemanager.version'),
],
'users' => [
'total' => 1,
'usersPremiumTotal' => 0,
],
'used' => '2.00MB',
]);

View File

@@ -69,7 +69,6 @@ class BrowseTest extends TestCase
'name' => 'level 1',
'items' => 2,
'trashed_items' => 2,
'team_folder' => false,
'folders' => [
[
'id' => $folder_level_2->id,
@@ -77,7 +76,6 @@ class BrowseTest extends TestCase
'name' => 'level 2',
'items' => 1,
'trashed_items' => 1,
'team_folder' => false,
'folders' => [
[
'id' => $folder_level_3->id,
@@ -92,7 +90,6 @@ class BrowseTest extends TestCase
'updated_at' => $folder_level_3->updated_at->toJson(),
'items' => 0,
'trashed_items' => 0,
'team_folder' => false,
'folders' => [],
],
],
@@ -103,7 +100,6 @@ class BrowseTest extends TestCase
'name' => 'level 2 Sibling',
'items' => 0,
'trashed_items' => 0,
'team_folder' => false,
'folders' => [],
],
],
@@ -112,20 +108,6 @@ class BrowseTest extends TestCase
'isMovable' => true,
'isOpen' => true,
],
[
'location' => 'team-folders',
'name' => 'Team Folders',
'folders' => [],
'isMovable' => false,
'isOpen' => false,
],
[
'location' => 'shared-with-me',
'name' => 'Shared with Me',
'folders' => [],
'isMovable' => false,
'isOpen' => false,
],
]);
}

View File

@@ -105,60 +105,6 @@ class FileTest extends TestCase
);
}
/**
* @test
*/
public function it_remotely_upload_new_file()
{
Event::fake([
RemoteFileCreatedEvent::class,
]);
$user = User::factory()
->hasSettings()
->create();
$folder = Folder::factory()
->create([
'user_id' => $user->id,
]);
$fakeFile = UploadedFile::fake()
->create('top-secret-document.pdf', 12000000, 'application/pdf');
Http::fake([
'https://fake.com/top-secret-document.pdf' => Http::response($fakeFile->getContent()),
'https://fake.com/another-secret-document.pdf' => Http::response($fakeFile->getContent()),
]);
$this
->actingAs($user)
->postJson('/api/upload/remote', [
'urls' => [
'https://fake.com/top-secret-document.pdf',
'https://fake.com/another-secret-document.pdf',
],
'parent_id' => $folder->id,
])->assertStatus(201);
$this
->assertDatabaseHas('files', [
'user_id' => $user->id,
'name' => 'top-secret-document',
'parent_id' => $folder->id,
])
->assertDatabaseHas('files', [
'name' => 'another-secret-document',
]);
File::all()
->each(function ($file) {
Event::assertDispatched(fn (RemoteFileCreatedEvent $event) => $event->payload['file']->id === $file->id);
Storage::assertExists("files/$file->user_id/$file->basename");
});
}
/**
* @test
*/

View File

@@ -1,15 +1,12 @@
<?php
namespace Tests\Domain\Homepage;
use Mail;
use Tests\TestCase;
use App\Users\Models\User;
use Domain\Files\Models\File;
use Domain\Sharing\Models\Share;
use Domain\Folders\Models\Folder;
use Domain\Settings\Models\Setting;
use Domain\Homepage\Mail\SendContactMessage;
use Domain\Pages\Actions\SeedDefaultPagesAction;
use Domain\Settings\Actions\SeedDefaultSettingsAction;
class HomepageTest extends TestCase
@@ -19,9 +16,7 @@ class HomepageTest extends TestCase
*/
public function it_get_index_page()
{
resolve(SeedDefaultPagesAction::class)();
resolve(SeedDefaultSettingsAction::class)('Extended');
resolve(SeedDefaultSettingsAction::class)();
Setting::create([
'name' => 'setup_wizard_success',
@@ -136,25 +131,4 @@ class HomepageTest extends TestCase
->assertStatus(200)
->assertSee('This link is protected by password');
}
/**
* @test
*/
public function it_send_contact_form()
{
Mail::fake();
Setting::create([
'name' => 'contact_email',
'value' => 'jane@doe.com',
]);
$this->postJson('/api/contact', [
'email' => 'john@doe.com',
'message' => 'Whaats is up!',
])
->assertStatus(201);
Mail::assertSent(SendContactMessage::class);
}
}

View File

@@ -6,9 +6,7 @@ use Tests\TestCase;
use App\Users\Models\User;
use Illuminate\Http\UploadedFile;
use Domain\Settings\Models\Setting;
use Illuminate\Support\Facades\Http;
use Domain\Settings\Actions\SeedDefaultSettingsAction;
use Domain\Localization\Actions\SeedDefaultLanguageAction;
class SettingsTest extends TestCase
{
@@ -40,7 +38,7 @@ class SettingsTest extends TestCase
*/
public function it_get_admin_settings()
{
resolve(SeedDefaultSettingsAction::class)('Extended');
resolve(SeedDefaultSettingsAction::class)();
$admin = User::factory()
->create(['role' => 'admin']);
@@ -74,7 +72,7 @@ class SettingsTest extends TestCase
*/
public function it_update_settings()
{
resolve(SeedDefaultSettingsAction::class)('Extended');
resolve(SeedDefaultSettingsAction::class)();
$admin = User::factory()
->create(['role' => 'admin']);
@@ -137,50 +135,6 @@ class SettingsTest extends TestCase
->assertStatus(204);
}
/**
* @test
*/
public function it_store_payment_service_credentials()
{
$admin = User::factory()
->create(['role' => 'admin']);
$this
->actingAs($admin)
->post('/api/admin/settings/payment-service', [
'service' => 'stripe',
'key' => '123456789',
'secret' => '123456789',
])->assertStatus(204);
$this->assertDatabaseHas('settings', [
'name' => 'allowed_stripe',
'value' => '1',
]);
}
/**
* @test
*/
public function it_store_social_service_credentials()
{
$admin = User::factory()
->create(['role' => 'admin']);
$this
->actingAs($admin)
->post('/api/admin/settings/social-service', [
'client_id' => '123456789',
'client_secret' => '123456789',
'service' => 'facebook',
])->assertStatus(204);
$this->assertDatabaseHas('settings', [
'name' => 'allowed_facebook',
'value' => 1,
]);
}
/**
* @test
*/
@@ -222,85 +176,4 @@ class SettingsTest extends TestCase
],
])->assertStatus(204);
}
/**
* @test
*/
public function it_set_broadcast()
{
$admin = User::factory()
->create(['role' => 'admin']);
$this
->actingAs($admin)
->postJson('/api/admin/settings/broadcast', [
'driver' => 'pusher',
'id' => '123',
'key' => '123456',
'secret' => 'mOoiofnssddf',
'cluster' => 'eu',
'port' => null,
'host' => null,
])->assertStatus(204);
}
/**
* @test
*/
public function it_upgrade_license()
{
Http::fake([
'https://verify.vuefilemanager.com/api/verify-code/*' => Http::response('b6896a44017217c36f4a6fdc56699728'),
]);
collect([
[
'name' => 'license',
'value' => 'regular',
],
[
'name' => 'purchase_code',
'value' => '22b28b36-6d84-41b2-a920-a884b2bf63b6',
],
])->each(function ($col) {
Setting::updateOrCreate([
'name' => $col['name'],
], [
'value' => $col['value'],
]);
});
resolve(SeedDefaultLanguageAction::class)();
$admin = User::factory()
->create(['role' => 'admin']);
$this
->actingAs($admin)
->postJson('/api/admin/upgrade-license', [
'purchaseCode' => '6ab28b36-6d84-41b2-a920-a884b2bf63b6',
])->assertStatus(201);
collect([
[
'name' => 'license',
'value' => 'extended',
],
[
'name' => 'purchase_code',
'value' => '6ab28b36-6d84-41b2-a920-a884b2bf63b6',
],
])->each(function ($col) {
$this->assertDatabaseHas('settings', [
'name' => $col['name'],
'value' => $col['value'],
]);
});
$this->assertDatabaseHas('language_translations', [
'key' => 'go_to_subscription',
'value' => 'Go to Subscription',
'lang' => 'en',
]);
}
}

View File

@@ -66,9 +66,6 @@ class SetupWizardTest extends TestCase
'description' => 'The best file manager on the internet',
'googleAnalytics' => 'UA-12345678-1',
'contactMail' => 'john@doe.com',
'subscriptionType' => 'metered',
'userVerification' => 1,
'userRegistration' => 1,
'storageLimitation' => 1,
'defaultStorage' => 10,
'logo' => UploadedFile::fake()->image('fake-logo.jpg'),
@@ -79,14 +76,6 @@ class SetupWizardTest extends TestCase
])->assertStatus(204);
$this
->assertDatabaseHas('settings', [
'name' => 'subscription_type',
'value' => 'metered',
])
->assertDatabaseHas('settings', [
'name' => 'user_verification',
'value' => 0,
])
->assertDatabaseHas('settings', [
'name' => 'app_color',
'value' => '#00BC72',
@@ -154,15 +143,6 @@ class SetupWizardTest extends TestCase
'avatar' => null,
]);
$this->assertDatabaseHas('pages', [
'title' => 'Terms of Service',
]);
$this->assertDatabaseHas('settings', [
'name' => 'feature_title_1',
'value' => 'Truly Freedom',
]);
$this->assertDatabaseHas('settings', [
'name' => 'setup_wizard_success',
'value' => '1',

View File

@@ -72,69 +72,4 @@ class SearchTest extends TestCase
'id' => $folder->id,
]);
}
/**
* @test
*/
public function it_get_searched_shared_with_me_file_and_folders()
{
$owner = User::factory()
->hasSettings()
->create();
$member = User::factory()
->hasSettings()
->create();
$folder = Folder::factory()
->create([
'name' => "Alice's files",
'user_id' => $owner->id,
]);
$folderWithin = Folder::factory()
->create([
'name' => 'Folder within Alice',
'parent_id' => $folder->id,
'user_id' => $owner->id,
]);
$document = File::factory()
->create([
'name' => 'Document',
'user_id' => $owner->id,
'parent_id' => $folderWithin->id,
]);
DB::table('team_folder_members')
->insert([
'parent_id' => $folder->id,
'user_id' => $member->id,
'permission' => 'can-edit',
]);
$this
->actingAs($member)
->getJson('/api/browse/search?query=ali')
->assertStatus(200)
->assertJsonFragment([
'id' => $folder->id,
]);
$this
->actingAs($member)
->getJson('/api/browse/search?query=Fol')
->assertStatus(200)
->assertJsonFragment([
'id' => $folder->id,
]);
$this
->actingAs($member)
->getJson('/api/browse/search?query=doc')
->assertStatus(200)
->assertJsonFragment([
'id' => $document->id,
]);
}
}

View File

@@ -109,157 +109,4 @@ class GateTest extends TestCase
]);
});
}
/**
* @test
*/
public function team_member_with_can_edit_privilege_rename_folder()
{
$owner = User::factory()
->hasSettings()
->create();
$member = User::factory()
->hasSettings()
->create();
$teamFolder = Folder::factory()
->create([
'user_id' => $owner->id,
'team_folder' => 1,
'name' => 'Team Folder',
]);
$parent = Folder::factory()
->create([
'user_id' => $owner->id,
'parent_id' => $teamFolder->id,
]);
$children = Folder::factory()
->create([
'user_id' => $owner->id,
'parent_id' => $parent->id,
]);
DB::table('team_folder_members')
->insert([
[
'parent_id' => $teamFolder->id,
'user_id' => $member->id,
'permission' => 'can-edit',
],
]);
$this
->actingAs($member)
->patchJson("/api/rename/{$children->id}", [
'name' => 'Renamed Folder',
'type' => 'folder',
])
->assertStatus(200)
->assertJsonFragment([
'name' => 'Renamed Folder',
]);
}
/**
* @test
*/
public function team_member_with_can_visit_privilege_try_rename_folder()
{
$owner = User::factory()
->create();
$member = User::factory()
->create();
$teamFolder = Folder::factory()
->create([
'user_id' => $owner->id,
'team_folder' => 1,
'name' => 'Team Folder',
]);
$parent = Folder::factory()
->create([
'user_id' => $owner->id,
'parent_id' => $teamFolder->id,
]);
$children = Folder::factory()
->create([
'user_id' => $owner->id,
'parent_id' => $parent->id,
'name' => 'Captivating',
]);
DB::table('team_folder_members')
->insert([
[
'parent_id' => $teamFolder->id,
'user_id' => $member->id,
'permission' => 'can-view',
],
]);
$this
->actingAs($member)
->patchJson("/api/rename/{$children->id}", [
'name' => 'Renamed Folder',
'type' => 'folder',
])
->assertStatus(403);
$this->assertDatabaseHas('folders', [
'name' => 'Captivating',
]);
}
/**
* @test
*/
public function team_member_rename_file()
{
$owner = User::factory()
->hasSettings()
->create();
$member = User::factory()
->hasSettings()
->create();
$teamFolder = Folder::factory()
->create([
'user_id' => $owner->id,
'team_folder' => 1,
'name' => 'Team Folder',
]);
$file = File::factory()
->create([
'user_id' => $owner->id,
'parent_id' => $teamFolder->id,
]);
DB::table('team_folder_members')
->insert([
[
'parent_id' => $teamFolder->id,
'user_id' => $member->id,
'permission' => 'can-edit',
],
]);
$this
->actingAs($member)
->patchJson("/api/rename/{$file->id}", [
'name' => 'Renamed File',
'type' => 'file',
])
->assertStatus(200)
->assertJsonFragment([
'name' => 'Renamed File',
]);
}
}

View File

@@ -4,83 +4,14 @@ namespace Tests\Support\Scheduler;
use Storage;
use Tests\TestCase;
use App\Users\Models\User;
use Domain\Files\Models\File;
use Domain\Sharing\Models\Share;
use Illuminate\Http\UploadedFile;
use Domain\Traffic\Models\Traffic;
use Support\Scheduler\Actions\ReportUsageAction;
use Support\Scheduler\Actions\DeleteFailedFilesAction;
use VueFileManager\Subscription\Domain\Plans\Models\Plan;
use Support\Scheduler\Actions\DeleteUnverifiedUsersAction;
use Support\Scheduler\Actions\DeleteExpiredShareLinksAction;
use VueFileManager\Subscription\Domain\Plans\Models\PlanMeteredFeature;
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
class SchedulerTest extends TestCase
{
/**
* @test
*/
public function it_report_usage_of_subscription()
{
$user = User::factory()
->hasSettings()
->create();
$plan = Plan::factory()
->create([
'type' => 'metered',
]);
PlanMeteredFeature::factory()
->count(4)
->sequence(
['key' => 'storage'],
['key' => 'bandwidth'],
['key' => 'flatFee'],
['key' => 'member'],
)
->create([
'plan_id' => $plan->id,
]);
$subscription = Subscription::factory()
->create([
'status' => 'active',
'type' => 'pre-paid',
'plan_id' => $plan->id,
'user_id' => $user->id,
]);
File::factory()
->create([
'user_id' => $user->id,
'filesize' => 125000000,
]);
Traffic::factory()
->create([
'user_id' => $user->id,
'download' => 155000000,
'upload' => 255000000,
'created_at' => now()->subDay(),
]);
resolve(ReportUsageAction::class)();
$this
->assertDatabaseHas('usages', [
'metered_feature_id' => $plan->meteredFeatures()->get()[0]->id,
'subscription_id' => $subscription->id,
'quantity' => 0.125,
])
->assertDatabaseHas('usages', [
'metered_feature_id' => $plan->meteredFeatures()->get()[1]->id,
'subscription_id' => $subscription->id,
'quantity' => 0.410,
]);
}
/**
* @test
*/