Adjust watermark permissions and transparency
This commit is contained in:
@@ -20,6 +20,7 @@ use App\Models\User;
|
||||
use App\Services\EventJoinTokenService;
|
||||
use App\Support\ApiError;
|
||||
use App\Support\TenantMemberPermissions;
|
||||
use App\Support\WatermarkConfigResolver;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
@@ -414,6 +415,7 @@ class EventController extends Controller
|
||||
$package = $event->eventPackage?->package;
|
||||
$brandingAllowed = optional($package)->branding_allowed !== false;
|
||||
$watermarkAllowed = optional($package)->watermark_allowed !== false;
|
||||
$watermarkRemovalAllowed = WatermarkConfigResolver::determineRemovalAllowed($event);
|
||||
|
||||
if (isset($validated['settings']) && is_array($validated['settings'])) {
|
||||
$validated['settings'] = array_merge($event->settings ?? [], $validated['settings']);
|
||||
@@ -423,6 +425,7 @@ class EventController extends Controller
|
||||
|
||||
$validated['settings']['branding_allowed'] = $brandingAllowed;
|
||||
$validated['settings']['watermark_allowed'] = $watermarkAllowed;
|
||||
$validated['settings']['watermark_removal_allowed'] = $watermarkRemovalAllowed;
|
||||
|
||||
$settings = $validated['settings'];
|
||||
$branding = Arr::get($settings, 'branding', []);
|
||||
@@ -435,20 +438,19 @@ class EventController extends Controller
|
||||
|
||||
if (is_array($watermark)) {
|
||||
$mode = $watermark['mode'] ?? 'base';
|
||||
$policy = $watermarkAllowed ? 'basic' : 'none';
|
||||
|
||||
if (! $watermarkAllowed) {
|
||||
$mode = 'off';
|
||||
$mode = 'base';
|
||||
} elseif (! $brandingAllowed) {
|
||||
$mode = 'base';
|
||||
} elseif ($mode === 'off' && $policy === 'basic') {
|
||||
} elseif ($mode === 'off' && ! $watermarkRemovalAllowed) {
|
||||
$mode = 'base';
|
||||
}
|
||||
|
||||
$assetPath = $watermark['asset'] ?? null;
|
||||
$assetDataUrl = $watermark['asset_data_url'] ?? null;
|
||||
|
||||
if (! $watermarkAllowed) {
|
||||
if (! $watermarkAllowed || $mode === 'off') {
|
||||
$assetPath = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Http\Resources\Tenant;
|
||||
|
||||
use App\Models\WatermarkSetting;
|
||||
use App\Services\Packages\PackageLimitEvaluator;
|
||||
use App\Support\TenantMemberPermissions;
|
||||
use App\Support\WatermarkConfigResolver;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Http\Resources\MissingValue;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
use function app;
|
||||
@@ -47,6 +50,8 @@ class EventResource extends JsonResource
|
||||
$limitEvaluator = app()->make(PackageLimitEvaluator::class);
|
||||
}
|
||||
|
||||
$settings['watermark_removal_allowed'] = WatermarkConfigResolver::determineRemovalAllowed($this->resource);
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
@@ -108,6 +113,27 @@ class EventResource extends JsonResource
|
||||
$watermark = Arr::get($settings, 'watermark');
|
||||
$base = config('watermark.base', []);
|
||||
$base = is_array($base) ? $base : [];
|
||||
$baseSetting = null;
|
||||
|
||||
if (class_exists(WatermarkSetting::class) && Schema::hasTable('watermark_settings')) {
|
||||
try {
|
||||
$baseSetting = WatermarkSetting::query()->first();
|
||||
} catch (\Throwable) {
|
||||
$baseSetting = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($baseSetting) {
|
||||
$base = array_merge($base, array_filter([
|
||||
'asset' => $baseSetting->asset,
|
||||
'position' => $baseSetting->position,
|
||||
'opacity' => $baseSetting->opacity,
|
||||
'scale' => $baseSetting->scale,
|
||||
'padding' => $baseSetting->padding,
|
||||
'offset_x' => $baseSetting->offset_x,
|
||||
'offset_y' => $baseSetting->offset_y,
|
||||
], static fn ($value) => $value !== null));
|
||||
}
|
||||
|
||||
if (! is_array($watermark)) {
|
||||
$watermark = [];
|
||||
|
||||
Reference in New Issue
Block a user