* SPDX-License-Identifier: AGPL-3.0-or-later */ namespace KTXF\Mail\Service; use KTXF\Mail\Entity\IMessageBase; use KTXF\Mail\Entity\IMessageMutable; /** * Mail Service Message Mutable Interface * * Optional interface for services that support message CRUD operations. * Provides message creation, modification, deletion, copying, moving, and flag management. * * @since 2025.05.01 */ interface ServiceMessageMutableInterface extends ServiceBaseInterface { public const CAPABILITY_ENTITY_CREATE = 'EntityCreate'; public const CAPABILITY_ENTITY_MODIFY = 'EntityModify'; public const CAPABILITY_ENTITY_DESTROY = 'EntityDestroy'; public const CAPABILITY_ENTITY_COPY = 'EntityCopy'; public const CAPABILITY_ENTITY_MOVE = 'EntityMove'; public const CAPABILITY_ENTITY_FLAG = 'EntityFlag'; /** * Creates a fresh message instance for composition * * @since 2025.05.01 * * @return IMessageMutable Fresh message object */ public function messageFresh(): IMessageMutable; /** * Creates/imports a message into a collection * * @since 2025.05.01 * * @param string|int $collection Target collection ID * @param IMessageMutable $message Message to create * @param array $options Protocol-specific options (e.g., flags, keywords) * * @return IMessageBase Created message with assigned ID */ public function messageCreate(string|int $collection, IMessageMutable $message, array $options = []): IMessageBase; /** * Modifies an existing message * * @since 2025.05.01 * * @param string|int $collection Collection ID * @param string|int $identifier Message ID * @param IMessageMutable $message Updated message data * * @return IMessageBase Modified message */ public function messageModify(string|int $collection, string|int $identifier, IMessageMutable $message): IMessageBase; /** * Destroys one or more messages * * @since 2025.05.01 * * @param string|int $collection Collection ID * @param string|int ...$identifiers Message IDs to destroy * * @return array Map of ID => destroyed */ public function messageDestroy(string|int $collection, string|int ...$identifiers): array; /** * Copies messages to another collection * * @since 2025.05.01 * * @param string|int $sourceCollection Source collection ID * @param string|int $targetCollection Target collection ID * @param string|int ...$identifiers Message IDs to copy * * @return array Map of source ID => new ID */ public function messageCopy(string|int $sourceCollection, string|int $targetCollection, string|int ...$identifiers): array; /** * Moves messages to another collection * * @since 2025.05.01 * * @param string|int $sourceCollection Source collection ID * @param string|int $targetCollection Target collection ID * @param string|int ...$identifiers Message IDs to move * * @return array Map of ID => moved */ public function messageMove(string|int $sourceCollection, string|int $targetCollection, string|int ...$identifiers): array; /** * Sets flags on messages * * @since 2025.05.01 * * @param string|int $collection Collection ID * @param array $flags Flags to set (e.g., ['\Seen', '\Flagged']) * @param bool $value True to add flags, false to remove * @param string|int ...$identifiers Message IDs * * @return array Map of ID => success */ public function messageFlag(string|int $collection, array $flags, bool $value, string|int ...$identifiers): array; }