mirror of
https://github.com/axeloz/filesharing.git
synced 2025-05-06 18:13:55 +02:00
Adding infinite expiration time
This commit is contained in:
parent
3504b0a6ca
commit
5d617d649c
7 changed files with 61 additions and 31 deletions
|
@ -136,7 +136,14 @@ class UploadController extends Controller
|
||||||
// Saving metadata
|
// Saving metadata
|
||||||
try {
|
try {
|
||||||
$bundle->completed = true;
|
$bundle->completed = true;
|
||||||
|
|
||||||
|
// Infinite expiry
|
||||||
|
if ($bundle->expiry == 'forever') {
|
||||||
|
$bundle->expires_at = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
$bundle->expires_at = time()+$bundle->expiry;
|
$bundle->expires_at = time()+$bundle->expiry;
|
||||||
|
}
|
||||||
$bundle->fullsize = $size;
|
$bundle->fullsize = $size;
|
||||||
$bundle->preview_link = route('bundle.preview', ['bundle' => $bundle, 'auth' => $bundle->preview_token]);
|
$bundle->preview_link = route('bundle.preview', ['bundle' => $bundle, 'auth' => $bundle->preview_token]);
|
||||||
$bundle->download_link = route('bundle.zip.download', ['bundle' => $bundle, 'auth' => $bundle->preview_token]);
|
$bundle->download_link = route('bundle.zip.download', ['bundle' => $bundle, 'auth' => $bundle->preview_token]);
|
||||||
|
@ -171,7 +178,12 @@ class UploadController extends Controller
|
||||||
$f->forceDelete();
|
$f->forceDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json(new BundleResource($bundle));
|
// Finally deleting bundle
|
||||||
|
$bundle->forceDelete();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|
|
@ -30,7 +30,9 @@ class GuestAccess
|
||||||
abort_if($bundle->preview_token !== $request->auth, 403);
|
abort_if($bundle->preview_token !== $request->auth, 403);
|
||||||
|
|
||||||
// Aborting if bundle expired
|
// Aborting if bundle expired
|
||||||
|
if (! empty($bundle->expires_at)) {
|
||||||
abort_if($bundle->expires_at->isBefore(Carbon::now()), 404);
|
abort_if($bundle->expires_at->isBefore(Carbon::now()), 404);
|
||||||
|
}
|
||||||
|
|
||||||
// Aborting if max download is reached
|
// Aborting if max download is reached
|
||||||
abort_if( ($bundle->max_downloads ?? 0) > 0 && $bundle->downloads >= $bundle->max_downloads, 404);
|
abort_if( ($bundle->max_downloads ?? 0) > 0 && $bundle->downloads >= $bundle->max_downloads, 404);
|
||||||
|
|
|
@ -15,7 +15,7 @@ return [
|
||||||
'2W' => 'two-weeks',
|
'2W' => 'two-weeks',
|
||||||
'1M' => 'one-month',
|
'1M' => 'one-month',
|
||||||
'3M' => 'three-months',
|
'3M' => 'three-months',
|
||||||
'6M' => 'six-months'
|
'6M' => 'six-months',
|
||||||
],
|
],
|
||||||
'default_expiry' => 86400, // 1 Day,
|
'default_expiry' => 86400, // 1 Day,
|
||||||
|
|
||||||
|
|
|
@ -86,5 +86,8 @@ return [
|
||||||
'unexpected-error' => 'An unexpected error has occurred',
|
'unexpected-error' => 'An unexpected error has occurred',
|
||||||
'login-to-get-bundles' => 'to get your bundles',
|
'login-to-get-bundles' => 'to get your bundles',
|
||||||
'you-are-logged-in' => 'You are logged in as ":username"',
|
'you-are-logged-in' => 'You are logged in as ":username"',
|
||||||
'logout' => 'Logout'
|
'logout' => 'Logout',
|
||||||
|
'forever' => 'Forever',
|
||||||
|
'yes' => 'Yes',
|
||||||
|
'no' => 'No',
|
||||||
];
|
];
|
||||||
|
|
|
@ -86,5 +86,8 @@ return [
|
||||||
'unexpected-error' => 'Une erreur inattendue est survenue',
|
'unexpected-error' => 'Une erreur inattendue est survenue',
|
||||||
'to-get-bundles' => 'pour accéder à vos archives',
|
'to-get-bundles' => 'pour accéder à vos archives',
|
||||||
'you-are-logged-in' => 'Vous êtes connecté(e) en tant que ":username"',
|
'you-are-logged-in' => 'Vous êtes connecté(e) en tant que ":username"',
|
||||||
'logout' => 'Déconnexion'
|
'logout' => 'Déconnexion',
|
||||||
|
'forever' => 'Infinie',
|
||||||
|
'yes' => 'Oui',
|
||||||
|
'no' => 'Non',
|
||||||
];
|
];
|
||||||
|
|
|
@ -14,21 +14,25 @@
|
||||||
created_at: null,
|
created_at: null,
|
||||||
expires_at: null,
|
expires_at: null,
|
||||||
expired: null,
|
expired: null,
|
||||||
|
interval: null,
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
this.updateTimes()
|
this.updateTimes()
|
||||||
|
|
||||||
window.setInterval( () => {
|
this.interval = window.setInterval( () => {
|
||||||
this.updateTimes()
|
this.updateTimes()
|
||||||
}, 5000)
|
}, 5000)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTimes: function() {
|
updateTimes: function() {
|
||||||
this.created_at = moment(this.metadata.created_at).fromNow()
|
this.created_at = moment(this.metadata.created_at).fromNow()
|
||||||
|
|
||||||
|
if (this.metadata.expiry) {
|
||||||
if (! this.isExpired()) {
|
if (! this.isExpired()) {
|
||||||
this.expires_at = moment(this.metadata.expires_at).fromNow()
|
this.expires_at = moment(this.metadata.expires_at).fromNow()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
isExpired: function() {
|
isExpired: function() {
|
||||||
|
@ -91,7 +95,18 @@
|
||||||
<span class="font-title text-xs text-primary uppercase mr-1">
|
<span class="font-title text-xs text-primary uppercase mr-1">
|
||||||
@lang('app.upload-expiry')
|
@lang('app.upload-expiry')
|
||||||
</span>
|
</span>
|
||||||
|
<template x-if="expires_at">
|
||||||
<span x-text="expires_at"></span>
|
<span x-text="expires_at"></span>
|
||||||
|
</template>
|
||||||
|
<template x-if="! expires_at">
|
||||||
|
<span>@lang('app.forever')</span>
|
||||||
|
</template>
|
||||||
|
</p>
|
||||||
|
<p class="w-1/2 px-1 mt-1">
|
||||||
|
<span class="font-title text-xs text-primary uppercase mr-1">
|
||||||
|
@lang('app.files')
|
||||||
|
</span>
|
||||||
|
<span x-text="Object.keys(metadata.files).length"></span>
|
||||||
</p>
|
</p>
|
||||||
<p class="w-1/2 px-1 mt-1">
|
<p class="w-1/2 px-1 mt-1">
|
||||||
<span class="font-title text-xs text-primary uppercase mr-1">
|
<span class="font-title text-xs text-primary uppercase mr-1">
|
||||||
|
@ -99,12 +114,6 @@
|
||||||
</span>
|
</span>
|
||||||
<span x-text="humanSize(metadata.fullsize)"></span>
|
<span x-text="humanSize(metadata.fullsize)"></span>
|
||||||
</p>
|
</p>
|
||||||
<p class="w-1/2 px-1 mt-1">
|
|
||||||
<span class="font-title text-xs text-primary uppercase mr-1">
|
|
||||||
@lang('app.max-downloads')
|
|
||||||
</span>
|
|
||||||
<span x-text="metadata.max_downloads > 0 ? metadata.max_download : '∞'"></span>
|
|
||||||
</p>
|
|
||||||
<p class="w-1/2 px-1 mt-1">
|
<p class="w-1/2 px-1 mt-1">
|
||||||
<span class="font-title text-xs text-primary uppercase mr-1">
|
<span class="font-title text-xs text-primary uppercase mr-1">
|
||||||
@lang('app.current-downloads')
|
@lang('app.current-downloads')
|
||||||
|
@ -113,9 +122,9 @@
|
||||||
</p>
|
</p>
|
||||||
<p class="w-1/2 px-1 mt-1">
|
<p class="w-1/2 px-1 mt-1">
|
||||||
<span class="font-title text-xs text-primary uppercase mr-1">
|
<span class="font-title text-xs text-primary uppercase mr-1">
|
||||||
@lang('app.password')
|
@lang('app.max-downloads')
|
||||||
</span>
|
</span>
|
||||||
<span x-text="metadata.password ? 'yes': 'no'"></span>
|
<span x-text="metadata.max_downloads > 0 ? metadata.max_downloads : '∞'"></span>
|
||||||
</p>
|
</p>
|
||||||
<p class="w-full px-1 mt-1" x-show="metadata.description">
|
<p class="w-full px-1 mt-1" x-show="metadata.description">
|
||||||
<span class="font-title text-xs text-primary uppercase mr-1">
|
<span class="font-title text-xs text-primary uppercase mr-1">
|
||||||
|
|
|
@ -259,7 +259,8 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then( (response) => {
|
.then( (response) => {
|
||||||
this.syncData(response.data)
|
//this.syncData(response.data)
|
||||||
|
window.location.href = '/'
|
||||||
})
|
})
|
||||||
.catch( (error) => {
|
.catch( (error) => {
|
||||||
|
|
||||||
|
@ -457,9 +458,9 @@
|
||||||
name="expiry"
|
name="expiry"
|
||||||
id="upload-expiry"
|
id="upload-expiry"
|
||||||
>
|
>
|
||||||
<option value="0"></option>
|
<option value="forever">@lang('app.forever')</option>
|
||||||
@foreach (config('sharing.expiry_values') as $k => $e)
|
@foreach (config('sharing.expiry_values') as $k => $e)
|
||||||
<option value="{{ Upload::getExpirySeconds($k) }}" {{ $e == config('sharing.default_expiry') ? 'selected' : '' }}>@lang('app.'.$e)</option>
|
<option value="{{ Upload::getExpirySeconds($k) }}">@lang('app.'.$e)</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue