зеркало из https://github.com/nextcloud/spreed.git
Make sure we don't change the comments object as that will update the database
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
1005aaab49
Коммит
25aae9f512
|
@ -235,8 +235,7 @@ class SystemMessage {
|
|||
throw new \OutOfBoundsException('Unknown subject');
|
||||
}
|
||||
|
||||
$comment->setMessage($message, ChatManager::MAX_CHAT_LENGTH);
|
||||
$chatMessage->setMessage($parsedMessage, $parsedParameters);
|
||||
$chatMessage->setMessage($parsedMessage, $parsedParameters, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -348,7 +348,7 @@ class ChatController extends AEnvironmentAwareController {
|
|||
'timestamp' => $message->getComment()->getCreationDateTime()->getTimestamp(),
|
||||
'message' => $message->getMessage(),
|
||||
'messageParameters' => $message->getMessageParameters(),
|
||||
'systemMessage' => $message->getMessageType() === 'system' ? $message->getComment()->getMessage() : '',
|
||||
'systemMessage' => $message->getMessageType() === 'system' ? $message->getMessageRaw() : '',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -327,7 +327,7 @@ class RoomController extends AEnvironmentAwareController {
|
|||
'timestamp' => $lastMessage->getCreationDateTime()->getTimestamp(),
|
||||
'message' => $message->getMessage(),
|
||||
'messageParameters' => $message->getMessageParameters(),
|
||||
'systemMessage' => $message->getMessageType() === 'system' ? $lastMessage->getMessage() : '',
|
||||
'systemMessage' => $message->getMessageType() === 'system' ? $message->getMessageRaw() : '',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,9 @@ class Message {
|
|||
/** @var string */
|
||||
protected $message = '';
|
||||
|
||||
/** @var string */
|
||||
protected $rawMessage = '';
|
||||
|
||||
/** @var array */
|
||||
protected $parameters = [];
|
||||
|
||||
|
@ -106,9 +109,10 @@ class Message {
|
|||
return $this->visible;
|
||||
}
|
||||
|
||||
public function setMessage(string $message, array $parameters): void {
|
||||
public function setMessage(string $message, array $parameters, string $rawMessage = ''): void {
|
||||
$this->message = $message;
|
||||
$this->parameters = $parameters;
|
||||
$this->rawMessage = $rawMessage;
|
||||
}
|
||||
|
||||
public function getMessage(): string {
|
||||
|
@ -119,6 +123,10 @@ class Message {
|
|||
return $this->parameters;
|
||||
}
|
||||
|
||||
public function getMessageRaw(): string {
|
||||
return $this->rawMessage;
|
||||
}
|
||||
|
||||
public function setMessageType(string $type): void {
|
||||
$this->type = $type;
|
||||
}
|
||||
|
|
|
@ -368,17 +368,13 @@ class SystemMessageTest extends TestCase {
|
|||
->method('getFileFromShare');
|
||||
}
|
||||
|
||||
$comment->expects($this->once())
|
||||
->method('setMessage')
|
||||
->with($message);
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
$chatMessage = new Message($room, $participant, $comment, $this->l);
|
||||
$chatMessage->setMessage(json_encode([
|
||||
'message' => $message,
|
||||
'parameters' => $parameters,
|
||||
]), []);
|
||||
]), [], $message);
|
||||
|
||||
$parser->parseMessage($chatMessage);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче