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, ...@@ -168,17 +168,14 @@ void MessageHandler::sendMessage(const QString& toJid,
msg.setMediaType(MessageType::MessageText); // text message without media msg.setMediaType(MessageType::MessageText); // text message without media
msg.setDeliveryState(Enums::DeliveryState::Pending); msg.setDeliveryState(Enums::DeliveryState::Pending);
msg.setStamp(QDateTime::currentDateTimeUtc()); msg.setStamp(QDateTime::currentDateTimeUtc());
if (isSpoiler) { msg.setIsSpoiler(isSpoiler);
msg.setIsSpoiler(isSpoiler); msg.setSpoilerHint(spoilerHint);
} else if (MediaUtils::isGeoLocation(msg.body())) { // process links from the body
const QUrl url(msg.body()); const QStringList words = body.split(u' ');
const QMimeType mimeType = MediaUtils::mimeType(url); for (const auto &word : words) {
const MessageType messageType = MediaUtils::messageType(mimeType); if (parseMediaUri(msg, word, true))
msg.setMediaType(messageType); break;
} }
emit model->addMessageRequested(msg); 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