refactor(core): centralize reserved system user identity
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -14,6 +14,7 @@ use KTXC\Resource\ProviderManager;
|
|||||||
use KTXF\Mail\Provider\ProviderBaseInterface;
|
use KTXF\Mail\Provider\ProviderBaseInterface;
|
||||||
use KTXF\Mail\Provider\ProviderServiceMutateInterface;
|
use KTXF\Mail\Provider\ProviderServiceMutateInterface;
|
||||||
use KTXF\Resource\Provider\ResourceServiceMutateInterface;
|
use KTXF\Resource\Provider\ResourceServiceMutateInterface;
|
||||||
|
use KTXF\Resource\SystemIdentity;
|
||||||
use KTXM\ProviderMailSystem\Stores\ServiceStore;
|
use KTXM\ProviderMailSystem\Stores\ServiceStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,7 +109,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface
|
|||||||
{
|
{
|
||||||
// routes are tenant scoped and only visible in the system user context,
|
// routes are tenant scoped and only visible in the system user context,
|
||||||
// keeping them out of regular user account listings
|
// keeping them out of regular user account listings
|
||||||
if ($userId !== self::USER_SYSTEM) {
|
if ($userId !== SystemIdentity::USER) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface
|
|||||||
|
|
||||||
public function serviceFetch(string $tenantId, string $userId, string|int $identifier): ?Service
|
public function serviceFetch(string $tenantId, string $userId, string|int $identifier): ?Service
|
||||||
{
|
{
|
||||||
if ($userId !== self::USER_SYSTEM) {
|
if ($userId !== SystemIdentity::USER) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface
|
|||||||
if (!str_ends_with($address, self::ADDRESS_DOMAIN_SUFFIX)) {
|
if (!str_ends_with($address, self::ADDRESS_DOMAIN_SUFFIX)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ($userId !== self::USER_SYSTEM) {
|
if ($userId !== SystemIdentity::USER) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +171,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface
|
|||||||
|
|
||||||
public function serviceExtant(string $tenantId, string $userId, string|int ...$identifiers): array
|
public function serviceExtant(string $tenantId, string $userId, string|int ...$identifiers): array
|
||||||
{
|
{
|
||||||
if ($userId !== self::USER_SYSTEM) {
|
if ($userId !== SystemIdentity::USER) {
|
||||||
return array_fill_keys(array_map('strval', $identifiers), false);
|
return array_fill_keys(array_map('strval', $identifiers), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +224,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface
|
|||||||
*/
|
*/
|
||||||
protected function assertSystemContext(string $userId): void
|
protected function assertSystemContext(string $userId): void
|
||||||
{
|
{
|
||||||
if ($userId !== self::USER_SYSTEM) {
|
if ($userId !== SystemIdentity::USER) {
|
||||||
throw new InvalidArgumentException('System mail routes can only be managed in the system user context');
|
throw new InvalidArgumentException('System mail routes can only be managed in the system user context');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use KTXF\Resource\Identifier\EntityIdentifierInterface;
|
|||||||
use KTXF\Resource\Provider\ProviderInterface;
|
use KTXF\Resource\Provider\ProviderInterface;
|
||||||
use KTXF\Resource\Provider\ResourceServiceIdentityInterface;
|
use KTXF\Resource\Provider\ResourceServiceIdentityInterface;
|
||||||
use KTXF\Resource\Provider\ResourceServiceLocationInterface;
|
use KTXF\Resource\Provider\ResourceServiceLocationInterface;
|
||||||
|
use KTXF\Resource\SystemIdentity;
|
||||||
use KTXF\Resource\Range\IRange;
|
use KTXF\Resource\Range\IRange;
|
||||||
use KTXF\Resource\Range\RangeType;
|
use KTXF\Resource\Range\RangeType;
|
||||||
use KTXF\Resource\Sort\ISort;
|
use KTXF\Resource\Sort\ISort;
|
||||||
@@ -422,7 +423,7 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceE
|
|||||||
throw new RuntimeException("Target mail provider '$providerId' is not available");
|
throw new RuntimeException("Target mail provider '$providerId' is not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
$service = $provider->serviceFetch($this->serviceTenantId, ProviderBaseInterface::USER_SYSTEM, $serviceId);
|
$service = $provider->serviceFetch($this->serviceTenantId, SystemIdentity::USER, $serviceId);
|
||||||
if ($service === null) {
|
if ($service === null) {
|
||||||
throw new RuntimeException("Target mail service '$providerId/$serviceId' was not found");
|
throw new RuntimeException("Target mail service '$providerId/$serviceId' was not found");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user