diff --git a/files/lib/data/message/MessageAction.class.php b/files/lib/data/message/MessageAction.class.php
index d5e9b93..795240a 100644
--- a/files/lib/data/message/MessageAction.class.php
+++ b/files/lib/data/message/MessageAction.class.php
@@ -337,19 +337,34 @@ public function pushAttachment() {
foreach ($attachments as $attachment) {
$attachmentIDs[] = $attachment->attachmentID;
}
+
+ $processor = new \wcf\system\html\input\HtmlInputProcessor();
+ $processor->process(implode(' ', array_map(function ($attachmentID) {
+ return '[attach='.$attachmentID.',none,true][/attach]';
+ }, $attachmentIDs)), 'be.bastelstu.chat.message', 0);
+ WCF::getDB()->beginTransaction();
/** @var Message $message */
$message = (new MessageAction([ ], 'create', [ 'data' => [ 'roomID' => $room->roomID
, 'userID' => WCF::getUser()->userID
, 'username' => WCF::getUser()->username
, 'time' => TIME_NOW
, 'objectTypeID' => $objectTypeID
- , 'payload' => serialize([ 'attachmentIDs' => $attachmentIDs ])
+ , 'payload' => serialize([ 'attachmentIDs' => $attachmentIDs
+ , 'message' => $processor->getHtml()
+ ])
]
]
)
)->executeAction()['returnValues'];
$attachmentHandler->updateObjectID($message->messageID);
+ $processor->setObjectID($message->messageID);
+ if (\wcf\system\message\embedded\object\MessageEmbeddedObjectManager::getInstance()->registerObjects($processor)) {
+ (new MessageEditor($message))->update([
+ 'hasEmbeddedObjects' => 1
+ ]);
+ }
+ WCF::getDB()->commitTransaction();
}
}
diff --git a/files/lib/system/message/type/AttachmentMessageType.class.php b/files/lib/system/message/type/AttachmentMessageType.class.php
index eb7176d..38b5b42 100644
--- a/files/lib/system/message/type/AttachmentMessageType.class.php
+++ b/files/lib/system/message/type/AttachmentMessageType.class.php
@@ -53,6 +53,8 @@ public function getPayload(\chat\data\message\Message $message, \wcf\data\user\U
if ($user === null) $user = new \wcf\data\user\UserProfile(\wcf\system\WCF::getUser());
$payload = $message->payload;
+ $payload['formattedMessage'] = null;
+ $payload['plaintextMessage'] = null;
$parameters = [ 'message' => $message
, 'user' => $user
@@ -60,7 +62,16 @@ public function getPayload(\chat\data\message\Message $message, \wcf\data\user\U
];
\wcf\system\event\EventHandler::getInstance()->fireAction($this, 'getPayload', $parameters);
- // TODO
+ if ($parameters['payload']['formattedMessage'] === null) {
+ $this->processor->setOutputType('text/html');
+ $this->processor->process($parameters['payload']['message'], 'be.bastelstu.chat.message', $message->messageID);
+ $parameters['payload']['formattedMessage'] = $this->processor->getHtml();
+ }
+ if ($parameters['payload']['plaintextMessage'] === null) {
+ $this->processor->setOutputType('text/plain');
+ $this->processor->process($parameters['payload']['message'], 'be.bastelstu.chat.message', $message->messageID);
+ $parameters['payload']['plaintextMessage'] = $this->processor->getHtml();
+ }
return $parameters['payload'];
}
diff --git a/templates/messageTypes.tpl b/templates/messageTypes.tpl
index 12f0ab2..6641b43 100644
--- a/templates/messageTypes.tpl
+++ b/templates/messageTypes.tpl
@@ -433,6 +433,37 @@
+
+