mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Fix users with @room in the name pinging the whole room when replied to
This commit is contained in:
parent
f099ec63d1
commit
42b53817e0
1 changed files with 29 additions and 23 deletions
|
@ -375,32 +375,38 @@ InputBar::message(const QString &msg, MarkdownOverride useMarkdown, bool rainbow
|
||||||
} else if (!room->reply().isEmpty()) {
|
} else if (!room->reply().isEmpty()) {
|
||||||
auto related = room->relatedInfo(room->reply());
|
auto related = room->relatedInfo(room->reply());
|
||||||
|
|
||||||
QString body;
|
// Skip reply fallbacks to users who would cause a room ping with the fallback.
|
||||||
bool firstLine = true;
|
// This should be fine, since in some cases the reply fallback can be omitted now and the
|
||||||
auto lines = related.quoted_body.splitRef(u'\n');
|
// alternative is worse! On Element Android this applies to any substring, but that is their
|
||||||
for (auto line : qAsConst(lines)) {
|
// bug to fix.
|
||||||
if (firstLine) {
|
if (!related.quoted_user.startsWith("@room:")) {
|
||||||
firstLine = false;
|
QString body;
|
||||||
body = QStringLiteral("> <%1> %2\n").arg(related.quoted_user, line);
|
bool firstLine = true;
|
||||||
} else {
|
auto lines = related.quoted_body.splitRef(u'\n');
|
||||||
body += QStringLiteral("> %1\n").arg(line);
|
for (auto line : qAsConst(lines)) {
|
||||||
|
if (firstLine) {
|
||||||
|
firstLine = false;
|
||||||
|
body = QStringLiteral("> <%1> %2\n").arg(related.quoted_user, line);
|
||||||
|
} else {
|
||||||
|
body += QStringLiteral("> %1\n").arg(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text.body = QStringLiteral("%1\n%2").arg(body, msg).toStdString();
|
||||||
|
|
||||||
|
// NOTE(Nico): rich replies always need a formatted_body!
|
||||||
|
text.format = "org.matrix.custom.html";
|
||||||
|
if ((ChatPage::instance()->userSettings()->markdown() &&
|
||||||
|
useMarkdown == MarkdownOverride::NOT_SPECIFIED) ||
|
||||||
|
useMarkdown == MarkdownOverride::ON)
|
||||||
|
text.formatted_body =
|
||||||
|
utils::getFormattedQuoteBody(related, utils::markdownToHtml(msg, rainbowify))
|
||||||
|
.toStdString();
|
||||||
|
else
|
||||||
|
text.formatted_body =
|
||||||
|
utils::getFormattedQuoteBody(related, msg.toHtmlEscaped()).toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
text.body = QStringLiteral("%1\n%2").arg(body, msg).toStdString();
|
|
||||||
|
|
||||||
// NOTE(Nico): rich replies always need a formatted_body!
|
|
||||||
text.format = "org.matrix.custom.html";
|
|
||||||
if ((ChatPage::instance()->userSettings()->markdown() &&
|
|
||||||
useMarkdown == MarkdownOverride::NOT_SPECIFIED) ||
|
|
||||||
useMarkdown == MarkdownOverride::ON)
|
|
||||||
text.formatted_body =
|
|
||||||
utils::getFormattedQuoteBody(related, utils::markdownToHtml(msg, rainbowify))
|
|
||||||
.toStdString();
|
|
||||||
else
|
|
||||||
text.formatted_body =
|
|
||||||
utils::getFormattedQuoteBody(related, msg.toHtmlEscaped()).toStdString();
|
|
||||||
|
|
||||||
text.relations.relations.push_back(
|
text.relations.relations.push_back(
|
||||||
{mtx::common::RelationType::InReplyTo, related.related_event});
|
{mtx::common::RelationType::InReplyTo, related.related_event});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue