[Web] Retention: last run for single rules, mode only when editing, check domain access first

This commit is contained in:
FreddleSpl0it committed 2026-11-09 12:09:57 +01:00
1 parent 1238e6fb58
commit 6796db6b8f
5 files changed
+44 -6

No files matched your search

@@ -71,7 +71,7 @@ class RetentionApiController
{
$id = $this->toId($id);
$rule = ($id === null) ? null : $this->rules->get($id);
return ($rule === null) ? [] : $this->rules->toArray($rule);
return ($rule === null) ? [] : $this->rules->toArray($rule, $this->rules->lastRuns([$id])[$id] ?? null);
}
/**
@@ -196,13 +196,14 @@ class RuleService
/** @throws UserError */
private function domainFor(mixed $value): string
{
$domain = strtolower((string)Input::text($value));
$domain = Input::text($value);
$domain = ($domain === null || $domain === '') ? '' : (string)idn_to_ascii(strtolower($domain), 0, INTL_IDNA_VARIANT_UTS46);
if ($domain !== '' && !$this->context->hasAdminRights() && !$this->context->canAccessDomain($domain)) {
throw new AccessDenied();
}
if ($domain === '' || !$this->repo->isDomain($domain)) {
throw new UserError('domain_not_found', [htmlspecialchars((string)Input::text($value))]);
}
if (!$this->context->hasAdminRights() && !$this->context->canAccessDomain($domain)) {
throw new AccessDenied();
}
return $domain;
}