aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Activity/Event.php25
-rw-r--r--lib/public/Activity/IEvent.php12
2 files changed, 26 insertions, 11 deletions
diff --git a/lib/private/Activity/Event.php b/lib/private/Activity/Event.php
index fd0c0afd9d8..b600a2c2249 100644
--- a/lib/private/Activity/Event.php
+++ b/lib/private/Activity/Event.php
@@ -33,7 +33,6 @@ use OCP\RichObjectStrings\InvalidObjectExeption;
use OCP\RichObjectStrings\IValidator;
class Event implements IEvent {
-
/** @var string */
protected $app = '';
/** @var string */
@@ -269,9 +268,29 @@ class Event implements IEvent {
$this->subjectRich = $subject;
$this->subjectRichParameters = $parameters;
+ if ($this->subjectParsed === '') {
+ $this->subjectParsed = $this->richToParsed($subject, $parameters);
+ }
+
return $this;
}
+ private function richToParsed(string $message, array $parameters): string {
+ $placeholders = [];
+ $replacements = [];
+ foreach ($parameters as $placeholder => $parameter) {
+ $placeholders[] = '{' . $placeholder . '}';
+ if (($parameter['type'] ?? '') === 'user') {
+ $replacements[] = '@' . $parameter['name'] ?? 'invalid-user';
+ } elseif (($parameter['type'] ?? '') === 'file') {
+ $replacements[] = $parameter['path'] ?? $parameter['name'] ?? 'invalid-file';
+ } else {
+ $replacements[] = $parameter['name'] ?? 'invalid-object';
+ }
+ }
+ return str_replace($placeholders, $replacements, $message);
+ }
+
/**
* @return string
* @since 11.0.0
@@ -350,6 +369,10 @@ class Event implements IEvent {
$this->messageRich = $message;
$this->messageRichParameters = $parameters;
+ if ($this->messageParsed === '') {
+ $this->messageParsed = $this->richToParsed($message, $parameters);
+ }
+
return $this;
}
diff --git a/lib/public/Activity/IEvent.php b/lib/public/Activity/IEvent.php
index 1e3c1deef26..4c47cc47a3f 100644
--- a/lib/public/Activity/IEvent.php
+++ b/lib/public/Activity/IEvent.php
@@ -103,9 +103,7 @@ interface IEvent {
* HTML is not allowed in the parsed subject and will be escaped
* automatically by the clients. You can use the RichObjectString system
* provided by the Nextcloud server to highlight important parameters via
- * the setRichSubject method, but make sure, that a plain text message is
- * always set via setParsedSubject, to support clients which can not handle
- * rich strings.
+ * the setRichSubject method.
*
* See https://github.com/nextcloud/server/issues/1706 for more information.
*
@@ -128,8 +126,6 @@ interface IEvent {
* HTML is not allowed in the rich subject and will be escaped automatically
* by the clients, but you can use the RichObjectString system provided by
* the Nextcloud server to highlight important parameters.
- * Also make sure, that a plain text subject is always set via
- * setParsedSubject, to support clients which can not handle rich strings.
*
* See https://github.com/nextcloud/server/issues/1706 for more information.
*
@@ -170,9 +166,7 @@ interface IEvent {
* HTML is not allowed in the parsed message and will be escaped
* automatically by the clients. You can use the RichObjectString system
* provided by the Nextcloud server to highlight important parameters via
- * the setRichMessage method, but make sure, that a plain text message is
- * always set via setParsedMessage, to support clients which can not handle
- * rich strings.
+ * the setRichMessage method.
*
* See https://github.com/nextcloud/server/issues/1706 for more information.
*
@@ -195,8 +189,6 @@ interface IEvent {
* HTML is not allowed in the rich message and will be escaped automatically
* by the clients, but you can use the RichObjectString system provided by
* the Nextcloud server to highlight important parameters.
- * Also make sure, that a plain text message is always set via
- * setParsedMessage, to support clients which can not handle rich strings.
*
* See https://github.com/nextcloud/server/issues/1706 for more information.
*