aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Notification/Notification.php67
-rw-r--r--lib/public/Notification/INotification.php21
2 files changed, 76 insertions, 12 deletions
diff --git a/lib/private/Notification/Notification.php b/lib/private/Notification/Notification.php
index 7346f35f966..ffcb36af6e5 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 = [];
@@ -231,12 +239,10 @@ class Notification implements INotification {
if (!is_string($subject) || $subject === '' || isset($subject[64])) {
throw new \InvalidArgumentException('The given subject is invalid');
}
- $this->subject = $subject;
- if (!is_array($parameters)) {
- throw new \InvalidArgumentException('The given subject parameters are invalid');
- }
+ $this->subject = $subject;
$this->subjectParameters = $parameters;
+
return $this;
}
@@ -289,11 +295,8 @@ class Notification implements INotification {
if (!is_string($subject) || $subject === '') {
throw new \InvalidArgumentException('The given parsed subject is invalid');
}
- $this->subjectRich = $subject;
- if (!is_array($parameters)) {
- throw new \InvalidArgumentException('The given subject parameters are invalid');
- }
+ $this->subjectRich = $subject;
$this->subjectRichParameters = $parameters;
return $this;
@@ -326,12 +329,10 @@ class Notification implements INotification {
if (!is_string($message) || $message === '' || isset($message[64])) {
throw new \InvalidArgumentException('The given message is invalid');
}
- $this->message = $message;
- if (!is_array($parameters)) {
- throw new \InvalidArgumentException('The given message parameters are invalid');
- }
+ $this->message = $message;
$this->messageParameters = $parameters;
+
return $this;
}
@@ -374,6 +375,40 @@ 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;
+ $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 +551,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()
&&
diff --git a/lib/public/Notification/INotification.php b/lib/public/Notification/INotification.php
index 3a8bde0a375..55109a5ee2e 100644
--- a/lib/public/Notification/INotification.php
+++ b/lib/public/Notification/INotification.php
@@ -184,6 +184,27 @@ interface INotification {
public function getParsedMessage();
/**
+ * @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 = []);
+
+ /**
+ * @return string
+ * @since 9.2.0
+ */
+ public function getRichMessage();
+
+ /**
+ * @return array[]
+ * @since 9.2.0
+ */
+ public function getRichMessageParameters();
+
+ /**
* @param string $link
* @return $this
* @throws \InvalidArgumentException if the link is invalid