зеркало из https://github.com/nextcloud/spreed.git
Allow longer chat messages
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
af5173b242
Коммит
0fb7a8cb19
|
@ -45,6 +45,8 @@ use Symfony\Component\EventDispatcher\GenericEvent;
|
|||
*/
|
||||
class ChatManager {
|
||||
|
||||
public const MAX_CHAT_LENGTH = 32000;
|
||||
|
||||
/** @var CommentsManager|ICommentsManager */
|
||||
private $commentsManager;
|
||||
/** @var EventDispatcherInterface */
|
||||
|
@ -77,7 +79,7 @@ class ChatManager {
|
|||
*/
|
||||
public function addSystemMessage(Room $chat, string $actorType, string $actorId, string $message, \DateTime $creationDateTime, bool $sendNotifications): IComment {
|
||||
$comment = $this->commentsManager->create($actorType, $actorId, 'chat', (string) $chat->getId());
|
||||
$comment->setMessage($message);
|
||||
$comment->setMessage($message, self::MAX_CHAT_LENGTH);
|
||||
$comment->setCreationDateTime($creationDateTime);
|
||||
$comment->setVerb('system');
|
||||
try {
|
||||
|
@ -108,7 +110,8 @@ class ChatManager {
|
|||
*/
|
||||
public function addChangelogMessage(Room $chat, string $message): IComment {
|
||||
$comment = $this->commentsManager->create('guests', 'changelog', 'chat', (string) $chat->getId());
|
||||
$comment->setMessage($message);
|
||||
|
||||
$comment->setMessage($message, self::MAX_CHAT_LENGTH);
|
||||
$comment->setCreationDateTime($this->timeFactory->getDateTime());
|
||||
$comment->setVerb('comment'); // Has to be comment, so it counts as unread message
|
||||
|
||||
|
@ -140,7 +143,7 @@ class ChatManager {
|
|||
*/
|
||||
public function sendMessage(Room $chat, Participant $participant, string $actorType, string $actorId, string $message, \DateTime $creationDateTime): IComment {
|
||||
$comment = $this->commentsManager->create($actorType, $actorId, 'chat', (string) $chat->getId());
|
||||
$comment->setMessage($message);
|
||||
$comment->setMessage($message, self::MAX_CHAT_LENGTH);
|
||||
$comment->setCreationDateTime($creationDateTime);
|
||||
// A verb ('comment', 'like'...) must be provided to be able to save a
|
||||
// comment
|
||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
namespace OCA\Spreed\Chat\Command;
|
||||
|
||||
|
||||
use OCA\Spreed\Chat\ChatManager;
|
||||
use OCA\Spreed\Model\Command;
|
||||
use OCA\Spreed\Room;
|
||||
use OCA\Spreed\Service\CommandService;
|
||||
|
@ -76,7 +77,7 @@ class Executor {
|
|||
'user' => $user,
|
||||
'visibility' => $command->getResponse(),
|
||||
'output' => $e->getMessage(),
|
||||
]));
|
||||
]), ChatManager::MAX_CHAT_LENGTH);
|
||||
$message->setActor('bots', $command->getName());
|
||||
$message->setVerb('command');
|
||||
return;
|
||||
|
@ -95,7 +96,7 @@ class Executor {
|
|||
'user' => $user,
|
||||
'visibility' => $command->getResponse(),
|
||||
'output' => $output,
|
||||
]));
|
||||
]), ChatManager::MAX_CHAT_LENGTH);
|
||||
$message->setActor('bots', $command->getName());
|
||||
$message->setVerb('command');
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
namespace OCA\Spreed\Chat\Parser;
|
||||
|
||||
|
||||
use OCA\Spreed\Chat\ChatManager;
|
||||
use OCA\Spreed\Exceptions\ParticipantNotFoundException;
|
||||
use OCA\Spreed\GuestManager;
|
||||
use OCA\Spreed\Model\Message;
|
||||
|
@ -234,7 +235,7 @@ class SystemMessage {
|
|||
throw new \OutOfBoundsException('Unknown subject');
|
||||
}
|
||||
|
||||
$comment->setMessage($message);
|
||||
$comment->setMessage($message, ChatManager::MAX_CHAT_LENGTH);
|
||||
$chatMessage->setMessage($parsedMessage, $parsedParameters);
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ class Notifier implements INotifier {
|
|||
}
|
||||
return $this->parseCall($notification, $room, $l);
|
||||
}
|
||||
if ($subject === 'mention' || $subject === 'chat') {
|
||||
if ($subject === 'mention' || $subject === 'chat') {
|
||||
return $this->parseChatMessage($notification, $room, $participant, $l);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче