aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Notification
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-10-27 15:43:34 +0200
committerJoas Schilling <coding@schilljs.com>2016-10-31 10:37:37 +0100
commit2c0b5dee19f1276a40a6dfdf5e13e7d5bafb20f3 (patch)
tree0b6342bd0b567911d26e5deab3a769fb8c85be0c /lib/private/Notification
parent6d2d069c172f1af72f134e32f4e8fc1fffbed80b (diff)
downloadnextcloud-server-2c0b5dee19f1276a40a6dfdf5e13e7d5bafb20f3.tar.gz
nextcloud-server-2c0b5dee19f1276a40a6dfdf5e13e7d5bafb20f3.zip
Allow rich object strings in messages as well
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Notification')
-rw-r--r--lib/private/Notification/Notification.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/private/Notification/Notification.php b/lib/private/Notification/Notification.php
index 7346f35f966..39fc6ab9465 100644
--- a/lib/private/Notification/Notification.php
+++ b/lib/private/Notification/Notification.php
@@ -74,6 +74,12 @@ class Notification implements INotification {
protected $messageParsed;
/** @var string */
+ protected $messageRich;
+
+ /** @var array */
+ protected $messageRichParameters;
+
+ /** @var string */
protected $link;
/** @var string */
@@ -112,6 +118,8 @@ class Notification implements INotification {
$this->message = '';
$this->messageParameters = [];
$this->messageParsed = '';
+ $this->messageRich = '';
+ $this->messageRichParameters = [];
$this->link = '';
$this->icon = '';
$this->actions = [];
@@ -374,6 +382,43 @@ class Notification implements INotification {
}
/**
+ * @param string $message
+ * @param array $parameters
+ * @return $this
+ * @throws \InvalidArgumentException if the message or parameters are invalid
+ * @since 9.2.0
+ */
+ public function setRichMessage($message, array $parameters = []) {
+ if (!is_string($message) || $message === '') {
+ throw new \InvalidArgumentException('The given parsed message is invalid');
+ }
+ $this->messageRich = $message;
+
+ if (!is_array($parameters)) {
+ throw new \InvalidArgumentException('The given message parameters are invalid');
+ }
+ $this->messageRichParameters = $parameters;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ * @since 9.2.0
+ */
+ public function getRichMessage() {
+ return $this->messageRich;
+ }
+
+ /**
+ * @return array[]
+ * @since 9.2.0
+ */
+ public function getRichMessageParameters() {
+ return $this->messageRichParameters;
+ }
+
+ /**
* @param string $link
* @return $this
* @throws \InvalidArgumentException if the link is invalid
@@ -516,6 +561,14 @@ class Notification implements INotification {
}
}
+ if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
+ try {
+ $this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
+ } catch (InvalidObjectExeption $e) {
+ return false;
+ }
+ }
+
return
$this->isValidCommon()
&&