resource provider and service improvements
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* Mail Service Identity Interface
|
||||
*
|
||||
* Base interface for authentication credentials used by mail services.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface IServiceIdentity extends JsonSerializable {
|
||||
|
||||
public const TYPE_BASIC = 'basic';
|
||||
public const TYPE_OAUTH = 'oauth';
|
||||
public const TYPE_APIKEY = 'apikey';
|
||||
|
||||
/**
|
||||
* Gets the identity/authentication type
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string One of: 'basic', 'oauth', 'apikey'
|
||||
*/
|
||||
public function getType(): string;
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
/**
|
||||
* Mail Service API Key Identity Interface
|
||||
*
|
||||
* API key authentication for transactional mail services (SendGrid, Mailgun, etc.)
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface IServiceIdentityApiKey extends IServiceIdentity {
|
||||
|
||||
/**
|
||||
* Gets the API key
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getApiKey(): string;
|
||||
|
||||
/**
|
||||
* Gets the optional API key identifier/name
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApiKeyId(): ?string;
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
/**
|
||||
* Mail Service Basic Authentication Identity Interface
|
||||
*
|
||||
* Username/password authentication for traditional mail services.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface IServiceIdentityBasic extends IServiceIdentity {
|
||||
|
||||
/**
|
||||
* Gets the username/login identifier
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername(): string;
|
||||
|
||||
/**
|
||||
* Gets the password/secret
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword(): string;
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use DateTimeImmutable;
|
||||
|
||||
/**
|
||||
* Mail Service OAuth Identity Interface
|
||||
*
|
||||
* OAuth2 token-based authentication for modern mail APIs.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface IServiceIdentityOAuth extends IServiceIdentity {
|
||||
|
||||
/**
|
||||
* Gets the OAuth access token
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessToken(): string;
|
||||
|
||||
/**
|
||||
* Gets the OAuth refresh token
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRefreshToken(): ?string;
|
||||
|
||||
/**
|
||||
* Gets the token expiration time
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return DateTimeImmutable|null
|
||||
*/
|
||||
public function getExpiresAt(): ?DateTimeImmutable;
|
||||
|
||||
/**
|
||||
* Gets the granted OAuth scopes
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getScopes(): array;
|
||||
|
||||
/**
|
||||
* Checks if the access token has expired
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isExpired(): bool;
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* Mail Service Location Interface
|
||||
*
|
||||
* Unified interface supporting both URI-based (API services) and socket-based
|
||||
* (traditional IMAP/SMTP) connection configurations.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface IServiceLocation extends JsonSerializable {
|
||||
|
||||
public const TYPE_URI = 'uri';
|
||||
public const TYPE_SOCKET_SINGLE = 'socket-single';
|
||||
public const TYPE_SOCKET_SPLIT = 'socket-split';
|
||||
|
||||
public const SECURITY_NONE = 'none';
|
||||
public const SECURITY_SSL = 'ssl';
|
||||
public const SECURITY_TLS = 'tls';
|
||||
public const SECURITY_STARTTLS = 'starttls';
|
||||
|
||||
/**
|
||||
* Gets the location type
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string One of: 'uri', 'socket-single', 'socket-split'
|
||||
*/
|
||||
public function getType(): string;
|
||||
|
||||
/**
|
||||
* Gets the URI for API-based services (JMAP, EWS, Graph API, HTTP relay)
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string|null URI or null if not URI-based
|
||||
*/
|
||||
public function getUri(): ?string;
|
||||
|
||||
/**
|
||||
* Gets the inbound/primary host for socket-based services
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string|null Hostname or null if URI-based
|
||||
*/
|
||||
public function getInboundHost(): ?string;
|
||||
|
||||
/**
|
||||
* Gets the inbound/primary port for socket-based services
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return int|null Port number or null if URI-based
|
||||
*/
|
||||
public function getInboundPort(): ?int;
|
||||
|
||||
/**
|
||||
* Gets the inbound/primary security mode
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string|null One of: 'none', 'ssl', 'tls', 'starttls'
|
||||
*/
|
||||
public function getInboundSecurity(): ?string;
|
||||
|
||||
/**
|
||||
* Gets the outbound host for split-socket services (e.g., SMTP separate from IMAP)
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string|null Hostname or null if not split-socket
|
||||
*/
|
||||
public function getOutboundHost(): ?string;
|
||||
|
||||
/**
|
||||
* Gets the outbound port for split-socket services
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return int|null Port number or null if not split-socket
|
||||
*/
|
||||
public function getOutboundPort(): ?int;
|
||||
|
||||
/**
|
||||
* Gets the outbound security mode for split-socket services
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string|null One of: 'none', 'ssl', 'tls', 'starttls'
|
||||
*/
|
||||
public function getOutboundSecurity(): ?string;
|
||||
|
||||
}
|
||||
@@ -9,11 +9,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use JsonSerializable;
|
||||
use KTXF\Mail\Collection\ICollectionBase;
|
||||
use KTXF\Mail\Entity\IAddress;
|
||||
use KTXF\Mail\Entity\IMessageBase;
|
||||
use KTXF\Resource\Filter\IFilter;
|
||||
use KTXF\Resource\Provider\ResourceServiceBaseInterface;
|
||||
use KTXF\Resource\Range\IRange;
|
||||
use KTXF\Resource\Range\RangeType;
|
||||
use KTXF\Resource\Sort\ISort;
|
||||
@@ -26,7 +26,7 @@ use KTXF\Resource\Sort\ISort;
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface IServiceBase extends JsonSerializable {
|
||||
interface ServiceBaseInterface extends ResourceServiceBaseInterface {
|
||||
|
||||
// Collection capabilities
|
||||
public const CAPABILITY_COLLECTION_LIST = 'CollectionList';
|
||||
@@ -43,7 +43,6 @@ interface IServiceBase extends JsonSerializable {
|
||||
public const CAPABILITY_MESSAGE_DELTA = 'MessageDelta';
|
||||
public const CAPABILITY_MESSAGE_EXTANT = 'MessageExtant';
|
||||
public const CAPABILITY_MESSAGE_FETCH = 'MessageFetch';
|
||||
public const CAPABILITY_MESSAGE_SEARCH = 'MessageSearch';
|
||||
|
||||
// Filter capabilities
|
||||
public const CAPABILITY_FILTER_ID = 'FilterId';
|
||||
@@ -62,91 +61,9 @@ interface IServiceBase extends JsonSerializable {
|
||||
public const CAPABILITY_SORT_SIZE = 'SortSize';
|
||||
|
||||
public const JSON_TYPE = 'mail.service';
|
||||
public const JSON_PROPERTY_TYPE = '@type';
|
||||
public const JSON_PROPERTY_PROVIDER = 'provider';
|
||||
public const JSON_PROPERTY_ID = 'id';
|
||||
public const JSON_PROPERTY_LABEL = 'label';
|
||||
public const JSON_PROPERTY_SCOPE = 'scope';
|
||||
public const JSON_PROPERTY_OWNER = 'owner';
|
||||
public const JSON_PROPERTY_ENABLED = 'enabled';
|
||||
public const JSON_PROPERTY_CAPABILITIES = 'capabilities';
|
||||
public const JSON_PROPERTY_PRIMARY_ADDRESS = 'primaryAddress';
|
||||
public const JSON_PROPERTY_SECONDARY_ADDRESSES = 'secondaryAddresses';
|
||||
|
||||
/**
|
||||
* Confirms if a specific capability is supported
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $value Required capability e.g. 'Send'
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function capable(string $value): bool;
|
||||
|
||||
/**
|
||||
* Lists all supported capabilities
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return array<string,bool>
|
||||
*/
|
||||
public function capabilities(): array;
|
||||
|
||||
/**
|
||||
* Gets the unique identifier of the provider this service belongs to
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function in(): string;
|
||||
|
||||
/**
|
||||
* Gets the unique identifier for this service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function id(): string|int;
|
||||
|
||||
/**
|
||||
* Gets the localized human-friendly name of this service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel(): string;
|
||||
|
||||
/**
|
||||
* Gets the scope of this service (System or User)
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return ServiceScope
|
||||
*/
|
||||
public function getScope(): ServiceScope;
|
||||
|
||||
/**
|
||||
* Gets the owner user ID for User-scoped services
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return string|null User ID or null for System scope
|
||||
*/
|
||||
public function getOwner(): ?string;
|
||||
|
||||
/**
|
||||
* Gets whether this service is enabled
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getEnabled(): bool;
|
||||
|
||||
/**
|
||||
* Gets the primary mailing address for this service
|
||||
*
|
||||
@@ -309,19 +226,4 @@ interface IServiceBase extends JsonSerializable {
|
||||
*/
|
||||
public function messageFetch(string|int $collection, string|int ...$identifiers): array;
|
||||
|
||||
/**
|
||||
* Searches messages across collections
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $query Search query (syntax depends on protocol)
|
||||
* @param array|null $collections Collection IDs to search (null = all)
|
||||
* @param IFilter|null $filter Additional filter criteria
|
||||
* @param ISort|null $sort Optional sort order
|
||||
* @param IRange|null $range Optional pagination
|
||||
*
|
||||
* @return array<string|int,IMessageBase> Matching messages
|
||||
*/
|
||||
public function messageSearch(string $query, ?array $collections = null, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null): array;
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ use KTXF\Mail\Collection\ICollectionMutable;
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface IServiceCollectionMutable extends IServiceBase {
|
||||
interface ServiceCollectionMutableInterface extends ServiceBaseInterface {
|
||||
|
||||
public const CAPABILITY_COLLECTION_CREATE = 'CollectionCreate';
|
||||
public const CAPABILITY_COLLECTION_MODIFY = 'CollectionModify';
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
/**
|
||||
* Mail Service API Key Identity Implementation
|
||||
*
|
||||
* API key authentication for transactional mail services.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
class ServiceIdentityApiKey implements IServiceIdentityApiKey {
|
||||
|
||||
/**
|
||||
* @param string $apiKey API key
|
||||
* @param string|null $apiKeyId Optional API key identifier
|
||||
*/
|
||||
public function __construct(
|
||||
private string $apiKey,
|
||||
private ?string $apiKeyId = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates from array data
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromArray(array $data): self {
|
||||
return new self(
|
||||
$data['apiKey'] ?? '',
|
||||
$data['apiKeyId'] ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType(): string {
|
||||
return self::TYPE_APIKEY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getApiKey(): string {
|
||||
return $this->apiKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getApiKeyId(): ?string {
|
||||
return $this->apiKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function jsonSerialize(): array {
|
||||
return array_filter([
|
||||
'type' => self::TYPE_APIKEY,
|
||||
'apiKeyId' => $this->apiKeyId,
|
||||
// API key intentionally omitted from serialization for security
|
||||
], fn($v) => $v !== null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
/**
|
||||
* Mail Service Basic Identity Implementation
|
||||
*
|
||||
* Username/password authentication credentials.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
class ServiceIdentityBasic implements IServiceIdentityBasic {
|
||||
|
||||
/**
|
||||
* @param string $username Login username
|
||||
* @param string $password Login password
|
||||
*/
|
||||
public function __construct(
|
||||
private string $username,
|
||||
private string $password,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates from array data
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromArray(array $data): self {
|
||||
return new self(
|
||||
$data['username'] ?? '',
|
||||
$data['password'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType(): string {
|
||||
return self::TYPE_BASIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUsername(): string {
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getPassword(): string {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'type' => self::TYPE_BASIC,
|
||||
'username' => $this->username,
|
||||
// Password intentionally omitted from serialization for security
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
/**
|
||||
* Mail Service Location Implementation
|
||||
*
|
||||
* Unified implementation supporting URI-based and socket-based connections.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
class ServiceLocation implements IServiceLocation {
|
||||
|
||||
/**
|
||||
* @param string $type Location type (uri, socket-single, socket-split)
|
||||
* @param string|null $uri URI for API-based services
|
||||
* @param string|null $inboundHost Inbound/primary host
|
||||
* @param int|null $inboundPort Inbound/primary port
|
||||
* @param string|null $inboundSecurity Inbound security (none, ssl, tls, starttls)
|
||||
* @param string|null $outboundHost Outbound host (for split-socket)
|
||||
* @param int|null $outboundPort Outbound port (for split-socket)
|
||||
* @param string|null $outboundSecurity Outbound security (for split-socket)
|
||||
*/
|
||||
public function __construct(
|
||||
private string $type,
|
||||
private ?string $uri = null,
|
||||
private ?string $inboundHost = null,
|
||||
private ?int $inboundPort = null,
|
||||
private ?string $inboundSecurity = null,
|
||||
private ?string $outboundHost = null,
|
||||
private ?int $outboundPort = null,
|
||||
private ?string $outboundSecurity = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates a URI-based location (for API services)
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $uri
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function uri(string $uri): self {
|
||||
return new self(self::TYPE_URI, $uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a single-socket location (e.g., SMTP only)
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $host
|
||||
* @param int $port
|
||||
* @param string $security
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function socket(string $host, int $port, string $security = self::SECURITY_TLS): self {
|
||||
return new self(
|
||||
self::TYPE_SOCKET_SINGLE,
|
||||
null,
|
||||
$host,
|
||||
$port,
|
||||
$security
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a split-socket location (IMAP + SMTP)
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $inboundHost IMAP host
|
||||
* @param int $inboundPort IMAP port
|
||||
* @param string $inboundSecurity IMAP security
|
||||
* @param string $outboundHost SMTP host
|
||||
* @param int $outboundPort SMTP port
|
||||
* @param string $outboundSecurity SMTP security
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function splitSocket(
|
||||
string $inboundHost,
|
||||
int $inboundPort,
|
||||
string $inboundSecurity,
|
||||
string $outboundHost,
|
||||
int $outboundPort,
|
||||
string $outboundSecurity
|
||||
): self {
|
||||
return new self(
|
||||
self::TYPE_SOCKET_SPLIT,
|
||||
null,
|
||||
$inboundHost,
|
||||
$inboundPort,
|
||||
$inboundSecurity,
|
||||
$outboundHost,
|
||||
$outboundPort,
|
||||
$outboundSecurity
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates from array data
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromArray(array $data): self {
|
||||
return new self(
|
||||
$data['type'] ?? self::TYPE_SOCKET_SINGLE,
|
||||
$data['uri'] ?? null,
|
||||
$data['inboundHost'] ?? $data['host'] ?? null,
|
||||
$data['inboundPort'] ?? $data['port'] ?? null,
|
||||
$data['inboundSecurity'] ?? $data['security'] ?? null,
|
||||
$data['outboundHost'] ?? null,
|
||||
$data['outboundPort'] ?? null,
|
||||
$data['outboundSecurity'] ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType(): string {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUri(): ?string {
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getInboundHost(): ?string {
|
||||
return $this->inboundHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getInboundPort(): ?int {
|
||||
return $this->inboundPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getInboundSecurity(): ?string {
|
||||
return $this->inboundSecurity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getOutboundHost(): ?string {
|
||||
return $this->outboundHost ?? $this->inboundHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getOutboundPort(): ?int {
|
||||
return $this->outboundPort ?? $this->inboundPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getOutboundSecurity(): ?string {
|
||||
return $this->outboundSecurity ?? $this->inboundSecurity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function jsonSerialize(): array {
|
||||
$data = ['type' => $this->type];
|
||||
|
||||
if ($this->type === self::TYPE_URI) {
|
||||
$data['uri'] = $this->uri;
|
||||
} else {
|
||||
$data['inboundHost'] = $this->inboundHost;
|
||||
$data['inboundPort'] = $this->inboundPort;
|
||||
$data['inboundSecurity'] = $this->inboundSecurity;
|
||||
|
||||
if ($this->type === self::TYPE_SOCKET_SPLIT) {
|
||||
$data['outboundHost'] = $this->outboundHost;
|
||||
$data['outboundPort'] = $this->outboundPort;
|
||||
$data['outboundSecurity'] = $this->outboundSecurity;
|
||||
}
|
||||
}
|
||||
|
||||
return array_filter($data, fn($v) => $v !== null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ use KTXF\Mail\Entity\IMessageMutable;
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface IServiceMessageMutable extends IServiceBase {
|
||||
interface ServiceMessageMutableInterface extends ServiceBaseInterface {
|
||||
|
||||
public const CAPABILITY_MESSAGE_CREATE = 'MessageCreate';
|
||||
public const CAPABILITY_MESSAGE_MODIFY = 'MessageModify';
|
||||
@@ -20,7 +20,7 @@ use KTXF\Mail\Exception\SendException;
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface IServiceSend extends IServiceBase {
|
||||
interface ServiceMessageSendInterface extends ServiceBaseInterface {
|
||||
|
||||
public const CAPABILITY_SEND = 'Send';
|
||||
|
||||
46
shared/lib/Mail/Service/ServiceMutableInterface.php
Normal file
46
shared/lib/Mail/Service/ServiceMutableInterface.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use KTXF\Mail\Entity\IAddress;
|
||||
|
||||
/**
|
||||
* Mail Service Mutable Interface
|
||||
*
|
||||
* Extends base service interface with setter methods for mutable properties.
|
||||
* Used for service configuration and updates.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface ServiceMutableInterface extends ServiceBaseInterface {
|
||||
|
||||
/**
|
||||
* Sets the primary mailing address for this service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param IAddress $value Primary email address
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPrimaryAddress(IAddress $value): self;
|
||||
|
||||
/**
|
||||
* Sets the secondary mailing addresses (aliases) for this service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param array<int, IAddress> $value Array of secondary addresses
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSecondaryAddresses(array $value): self;
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* Defines the scope/context of a mail service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
enum ServiceScope: string implements JsonSerializable {
|
||||
|
||||
/**
|
||||
* System-level service for tenant-wide communications
|
||||
* (e.g., notifications@, reports@, noreply@)
|
||||
*/
|
||||
case System = 'system';
|
||||
|
||||
/**
|
||||
* User-level service for personal mail accounts
|
||||
* (e.g., user's own IMAP/SMTP accounts)
|
||||
*/
|
||||
case User = 'user';
|
||||
|
||||
public function jsonSerialize(): string {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user