Skip to content

Commit

Permalink
fix: Manually copy new method from Nextcloud 31
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Nov 15, 2024
1 parent 7c8a1db commit f19e3a5
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
use OCP\IRequest;
use OCP\IUserManager;
use OCP\RichObjectStrings\InvalidObjectExeption;
use OCP\RichObjectStrings\IRichTextFormatter;
use OCP\RichObjectStrings\IValidator;
use OCP\Security\ITrustedDomainHelper;
use OCP\Security\RateLimiting\IRateLimitExceededException;
Expand Down Expand Up @@ -123,7 +122,6 @@ public function __construct(
protected Authenticator $federationAuthenticator,
protected ProxyCacheMessageService $pcmService,
protected Notifier $notifier,
protected IRichTextFormatter $richTextFormatter,
protected ITaskProcessingManager $taskProcessingManager,
protected IAppConfig $appConfig,
protected LoggerInterface $logger,
Expand Down Expand Up @@ -570,7 +568,7 @@ public function summarizeChat(
continue;
}

$parsedMessage = $this->richTextFormatter->richToParsed(
$parsedMessage = $this->richToParsed(
$message->getMessage(),
$message->getMessageParameters(),
);
Expand Down Expand Up @@ -634,6 +632,24 @@ public function summarizeChat(
return new DataResponse($data, Http::STATUS_CREATED);
}

/**
* Function is copied from Nextcloud 31 \OCP\RichObjectStrings\IRichTextFormatter::richToParsed
* @deprecated
*/
protected function richToParsed(string $message, array $parameters): string {
$placeholders = [];
$replacements = [];
foreach ($parameters as $placeholder => $parameter) {
$placeholders[] = '{' . $placeholder . '}';
$replacements[] = match($parameter['type']) {
'user' => '@' . $parameter['name'],
'file' => $parameter['path'] ?? $parameter['name'],
default => $parameter['name'],
};
}
return str_replace($placeholders, $replacements, $message);
}

/**
* @return DataResponse<Http::STATUS_OK|Http::STATUS_NOT_MODIFIED, TalkChatMessageWithParent[], array{X-Chat-Last-Common-Read?: numeric-string, X-Chat-Last-Given?: numeric-string}>
*/
Expand Down

0 comments on commit f19e3a5

Please sign in to comment.