Limit-Status im Upload-Flow anzeigen (Warnbanner + Sperrzustände).
Upload-Fehlercodes auswerten und freundliche Dialoge zeigen.
This commit is contained in:
@@ -3,10 +3,14 @@
|
||||
namespace App\Http\Controllers\Api\Tenant;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Tenant\NotificationPreferencesRequest;
|
||||
use App\Http\Requests\Tenant\SettingsStoreRequest;
|
||||
use App\Models\Tenant;
|
||||
use App\Services\Packages\TenantNotificationPreferences;
|
||||
use App\Support\ApiError;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
@@ -27,6 +31,62 @@ class SettingsController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function notificationPreferences(
|
||||
Request $request,
|
||||
TenantNotificationPreferences $preferencesService
|
||||
): JsonResponse {
|
||||
$tenant = $request->tenant;
|
||||
$defaults = TenantNotificationPreferences::defaults();
|
||||
$resolved = [];
|
||||
|
||||
foreach (array_keys($defaults) as $key) {
|
||||
$resolved[$key] = $preferencesService->shouldNotify($tenant, $key);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'data' => [
|
||||
'defaults' => $defaults,
|
||||
'preferences' => $resolved,
|
||||
'overrides' => $tenant->notification_preferences ?? null,
|
||||
'meta' => [
|
||||
'credit_warning_sent_at' => $tenant->credit_warning_sent_at?->toIso8601String(),
|
||||
'credit_warning_threshold' => $tenant->credit_warning_threshold,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateNotificationPreferences(
|
||||
NotificationPreferencesRequest $request,
|
||||
TenantNotificationPreferences $preferencesService
|
||||
): JsonResponse {
|
||||
$tenant = $request->tenant;
|
||||
$payload = $request->validated()['preferences'];
|
||||
|
||||
$tenant->update([
|
||||
'notification_preferences' => $payload,
|
||||
]);
|
||||
|
||||
$tenant->refresh();
|
||||
|
||||
$resolved = [];
|
||||
foreach (array_keys(TenantNotificationPreferences::defaults()) as $key) {
|
||||
$resolved[$key] = $preferencesService->shouldNotify($tenant->fresh(), $key);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Benachrichtigungseinstellungen aktualisiert.',
|
||||
'data' => [
|
||||
'preferences' => $resolved,
|
||||
'overrides' => $tenant->notification_preferences,
|
||||
'meta' => [
|
||||
'credit_warning_sent_at' => $tenant->credit_warning_sent_at?->toIso8601String(),
|
||||
'credit_warning_threshold' => $tenant->credit_warning_threshold,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the tenant's settings.
|
||||
*/
|
||||
@@ -98,7 +158,12 @@ class SettingsController extends Controller
|
||||
$domain = $request->input('domain');
|
||||
|
||||
if (! $domain) {
|
||||
return response()->json(['error' => 'Domain ist erforderlich.'], 400);
|
||||
return ApiError::response(
|
||||
'domain_missing',
|
||||
'Domain erforderlich',
|
||||
'Bitte gib eine Domain an.',
|
||||
Response::HTTP_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
if (! $this->isValidDomain($domain)) {
|
||||
|
||||
Reference in New Issue
Block a user