diff options
author | Joas Schilling <coding@schilljs.com> | 2019-02-20 14:16:01 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-02-20 14:17:37 +0300 |
commit | 2f60aab4abcae62db6dddc594c86b28d199a74e0 (patch) | |
tree | 91dc79b5ebf8613eef77674cbc945a22c11fec8b /lib/Model | |
parent | f828ab9c9e96e59ddcf7c34d4c39eaf1f85753a5 (diff) |
Introduce a Message model for parsing which also allows to hide messages
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Model')
-rw-r--r-- | lib/Model/Message.php | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/lib/Model/Message.php b/lib/Model/Message.php new file mode 100644 index 000000000..acb3848d9 --- /dev/null +++ b/lib/Model/Message.php @@ -0,0 +1,147 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Spreed\Model; + + +use OCA\Spreed\Participant; +use OCA\Spreed\Room; +use OCP\Comments\IComment; +use OCP\IL10N; +use OCP\IUser; + +class Message { + + /** @var Room */ + protected $room; + + /** @var IComment */ + protected $comment; + + /** @var IL10N */ + protected $l; + + /** @var Participant */ + protected $participant; + + /** @var bool */ + protected $visible = true; + + /** @var string */ + protected $type = ''; + + /** @var string */ + protected $message = ''; + + /** @var array */ + protected $parameters = []; + + /** @var string */ + protected $actorType = ''; + + /** @var string */ + protected $actorId = ''; + + /** @var string */ + protected $actorDisplayName = ''; + + public function __construct(Room $room, + Participant $participant, + IComment $comment, + IL10N $l) { + $this->room = $room; + $this->participant = $participant; + $this->comment = $comment; + $this->l = $l; + } + + /* + * Meta information + */ + + public function getRoom(): Room { + return $this->room; + } + + public function getComment(): IComment { + return $this->comment; + } + + public function getL10n(): IL10N { + return $this->l; + } + + public function getParticipant(): Participant { + return $this->participant; + } + + /* + * Parsed message information + */ + + public function setVisibility(bool $visible): void { + $this->visible = $visible; + } + + public function getVisibility(): bool { + return $this->visible; + } + + public function setMessage(string $message, array $parameters): void { + $this->message = $message; + $this->parameters = $parameters; + } + + public function getMessage(): string { + return $this->message; + } + + public function getMessageParameters(): array { + return $this->parameters; + } + + public function setMessageType(string $type): void { + $this->type = $type; + } + + public function getMessageType(): string { + return $this->type; + } + + public function setActor(string $type, string $id, string $displayName): void { + $this->actorType = $type; + $this->actorId = $id; + $this->actorDisplayName = $displayName; + } + + public function getActorType(): string { + return $this->actorType; + } + + public function getActorId(): string { + return $this->actorId; + } + + public function getActorDisplayName(): string { + return $this->actorDisplayName; + } +} |