Also interpret URLs from the body when sending messages

Receiving a message with a URL in the body resulted in having possible
media displayed (with a download button), but the same did not happen
when you sent a message with a link. This commit fixes this and also
processes links from the sent body.
parent 109dc5d6
Pipeline #32148 passed with stage
in 3 minutes and 59 seconds
......@@ -168,17 +168,14 @@ void MessageHandler::sendMessage(const QString& toJid,
msg.setMediaType(MessageType::MessageText); // text message without media
msg.setDeliveryState(Enums::DeliveryState::Pending);
msg.setStamp(QDateTime::currentDateTimeUtc());
if (isSpoiler) {
msg.setIsSpoiler(isSpoiler);
msg.setSpoilerHint(spoilerHint);
} else if (MediaUtils::isGeoLocation(msg.body())) {
const QUrl url(msg.body());
const QMimeType mimeType = MediaUtils::mimeType(url);
const MessageType messageType = MediaUtils::messageType(mimeType);
msg.setMediaType(messageType);
msg.setMediaLocation(msg.body());
msg.setMediaContentType(mimeType.name());
msg.setOutOfBandUrl(msg.body());
// process links from the body
const QStringList words = body.split(u' ');
for (const auto &word : words) {
if (parseMediaUri(msg, word, true))
break;
}
emit model->addMessageRequested(msg);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment