summary refs log tree commit diff
path: root/src/timeline2/TimelineViewManager.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2019-09-11 00:00:04 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2019-11-23 20:06:14 +0100
commita7595eab5a6fdcde80b9989f65de1801afad3d3d (patch)
tree02afbe0e598d8fa4e6c81a593a39e64b95414cd4 /src/timeline2/TimelineViewManager.cpp
parentShow redactions in qml timeline (diff)
downloadnheko-a7595eab5a6fdcde80b9989f65de1801afad3d3d.tar.xz
Reimplement sending basic text messages
Diffstat (limited to 'src/timeline2/TimelineViewManager.cpp')
-rw-r--r--src/timeline2/TimelineViewManager.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/timeline2/TimelineViewManager.cpp b/src/timeline2/TimelineViewManager.cpp

index eb9bea54..6aa2ff43 100644 --- a/src/timeline2/TimelineViewManager.cpp +++ b/src/timeline2/TimelineViewManager.cpp
@@ -62,3 +62,41 @@ TimelineViewManager::initWithMessages(const std::map<QString, mtx::responses::Ti models.value(e.first)->addEvents(e.second); } } + +void +TimelineViewManager::queueTextMessage(const QString &msg) +{ + mtx::events::msg::Text text = {}; + text.body = msg.trimmed().toStdString(); + text.format = "org.matrix.custom.html"; + text.formatted_body = utils::markdownToHtml(msg).toStdString(); + + if (timeline_) + timeline_->sendMessage(text); +} + +void +TimelineViewManager::queueReplyMessage(const QString &reply, const RelatedInfo &related) +{ + mtx::events::msg::Text text = {}; + + QString body; + bool firstLine = true; + for (const auto &line : related.quoted_body.splitRef("\n")) { + if (firstLine) { + firstLine = false; + body = QString("> <%1> %2\n").arg(related.quoted_user).arg(line); + } else { + body = QString("%1\n> %2\n").arg(body).arg(line); + } + } + + text.body = QString("%1\n%2").arg(body).arg(reply).toStdString(); + text.format = "org.matrix.custom.html"; + text.formatted_body = + utils::getFormattedQuoteBody(related, utils::markdownToHtml(reply)).toStdString(); + text.relates_to.in_reply_to.event_id = related.related_event; + + if (timeline_) + timeline_->sendMessage(text); +}