|  | 
|  | 1 | +<?php | 
|  | 2 | + | 
|  | 3 | +declare(strict_types=1); | 
|  | 4 | + | 
|  | 5 | +/** | 
|  | 6 | + * @copyright 2022 Anna Larch <anna@nextcloud.com> | 
|  | 7 | + * | 
|  | 8 | + * @author 2022 Anna Larch <anna@nextcloud.com> | 
|  | 9 | + * | 
|  | 10 | + * @license GNU AGPL version 3 or any later version | 
|  | 11 | + * | 
|  | 12 | + * This program is free software: you can redistribute it and/or modify | 
|  | 13 | + * it under the terms of the GNU Affero General Public License as | 
|  | 14 | + * published by the Free Software Foundation, either version 3 of the | 
|  | 15 | + * License, or (at your option) any later version. | 
|  | 16 | + * | 
|  | 17 | + * This program is distributed in the hope that it will be useful, | 
|  | 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 20 | + * GNU Affero General Public License for more details. | 
|  | 21 | + * | 
|  | 22 | + * You should have received a copy of the GNU Affero General Public License | 
|  | 23 | + * along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
|  | 24 | + */ | 
|  | 25 | + | 
|  | 26 | +namespace OCA\Mail\Db; | 
|  | 27 | + | 
|  | 28 | +use JsonSerializable; | 
|  | 29 | +use OCP\AppFramework\Db\Entity; | 
|  | 30 | + | 
|  | 31 | +/** | 
|  | 32 | + * @method int getType() | 
|  | 33 | + * @method void setType(int $type) | 
|  | 34 | + * @method int getAccountId() | 
|  | 35 | + * @method void setAccountId(int $accountId) | 
|  | 36 | + * @method int|null getAliasId() | 
|  | 37 | + * @method void setAliasId(?int $aliasId) | 
|  | 38 | + * @method int getSendAt() | 
|  | 39 | + * @method void setSendAt(int $sendAt) | 
|  | 40 | + * @method string getSubject() | 
|  | 41 | + * @method void setSubject(string $subject) | 
|  | 42 | + * @method string getBody() | 
|  | 43 | + * @method void setBody(string $body) | 
|  | 44 | + * @method bool isHtml() | 
|  | 45 | + * @method void setHtml(bool $html) | 
|  | 46 | + * @method string|null getInReplyToMessageId() | 
|  | 47 | + * @method void setInReplyToMessageId(?string $inReplyToId) | 
|  | 48 | + */ | 
|  | 49 | +class LocalMessage extends Entity implements JsonSerializable { | 
|  | 50 | +	public const TYPE_OUTGOING = 0; | 
|  | 51 | +	public const TYPE_DRAFT = 1; | 
|  | 52 | + | 
|  | 53 | +	/** | 
|  | 54 | +	 * @var int | 
|  | 55 | +	 * @psalm-var self::TYPE_* | 
|  | 56 | +	 */ | 
|  | 57 | +	protected $type; | 
|  | 58 | + | 
|  | 59 | +	/** @var int */ | 
|  | 60 | +	protected $accountId; | 
|  | 61 | + | 
|  | 62 | +	/** @var int|null */ | 
|  | 63 | +	protected $aliasId; | 
|  | 64 | + | 
|  | 65 | +	/** @var int */ | 
|  | 66 | +	protected $sendAt; | 
|  | 67 | + | 
|  | 68 | +	/** @var string */ | 
|  | 69 | +	protected $subject; | 
|  | 70 | + | 
|  | 71 | +	/** @var string */ | 
|  | 72 | +	protected $body; | 
|  | 73 | + | 
|  | 74 | +	/** @var bool */ | 
|  | 75 | +	protected $html; | 
|  | 76 | + | 
|  | 77 | +	/** @var string|null */ | 
|  | 78 | +	protected $inReplyToMessageId; | 
|  | 79 | + | 
|  | 80 | +	/** @var array|null */ | 
|  | 81 | +	protected $attachments; | 
|  | 82 | + | 
|  | 83 | +	/** @var array|null */ | 
|  | 84 | +	protected $recipients; | 
|  | 85 | + | 
|  | 86 | +	public function __construct() { | 
|  | 87 | +		$this->addType('type', 'integer'); | 
|  | 88 | +		$this->addType('accountId', 'integer'); | 
|  | 89 | +		$this->addType('aliasId', 'integer'); | 
|  | 90 | +		$this->addType('sendAt', 'integer'); | 
|  | 91 | +		$this->addType('html', 'boolean'); | 
|  | 92 | +	} | 
|  | 93 | + | 
|  | 94 | +	/** | 
|  | 95 | +	 * @return array | 
|  | 96 | +	 */ | 
|  | 97 | +	public function jsonSerialize() { | 
|  | 98 | +		return [ | 
|  | 99 | +			'id' => $this->getId(), | 
|  | 100 | +			'type' => $this->getType(), | 
|  | 101 | +			'accountId' => $this->getAccountId(), | 
|  | 102 | +			'aliasId' => $this->getAccountId(), | 
|  | 103 | +			'sendAt' => $this->getSendAt(), | 
|  | 104 | +			'subject' => $this->getSubject(), | 
|  | 105 | +			'text' => $this->getBody(), | 
|  | 106 | +			'html' => $this->isHtml(), | 
|  | 107 | +			'inReplyToMessageId' => $this->getInReplyToMessageId(), | 
|  | 108 | +			'attachments' => $this->getAttachments(), | 
|  | 109 | +			'recipients' => $this->getRecipients() | 
|  | 110 | +		]; | 
|  | 111 | +	} | 
|  | 112 | + | 
|  | 113 | +	/** | 
|  | 114 | +	 * @param LocalAttachment[] $attachments | 
|  | 115 | +	 * @return void | 
|  | 116 | +	 */ | 
|  | 117 | +	public function setAttachments(array $attachments): void { | 
|  | 118 | +		$this->attachments = $attachments; | 
|  | 119 | +	} | 
|  | 120 | + | 
|  | 121 | +	/** | 
|  | 122 | +	 * @return LocalAttachment[]|null | 
|  | 123 | +	 */ | 
|  | 124 | +	public function getAttachments(): ?array { | 
|  | 125 | +		return $this->attachments; | 
|  | 126 | +	} | 
|  | 127 | + | 
|  | 128 | +	/** | 
|  | 129 | +	 * @param Recipient[] $recipients | 
|  | 130 | +	 * @return void | 
|  | 131 | +	 */ | 
|  | 132 | +	public function setRecipients(array $recipients): void { | 
|  | 133 | +		$this->recipients = $recipients; | 
|  | 134 | +	} | 
|  | 135 | + | 
|  | 136 | +	/** | 
|  | 137 | +	 * @return Recipient[]|null | 
|  | 138 | +	 */ | 
|  | 139 | +	public function getRecipients(): ?array { | 
|  | 140 | +		return $this->recipients; | 
|  | 141 | +	} | 
|  | 142 | +} | 
0 commit comments