Clean up notification code a bit

This commit is contained in:
Nicolas Werner 2021-03-17 19:08:17 +01:00
parent 95026dcc62
commit e5d75c814b
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
16 changed files with 204 additions and 474 deletions

View file

@ -870,30 +870,7 @@ TimelineModel::relatedInfo(QString id)
if (!event)
return {};
RelatedInfo related = {};
related.quoted_user = QString::fromStdString(mtx::accessors::sender(*event));
related.related_event = id.toStdString();
related.type = mtx::accessors::msg_type(*event);
// get body, strip reply fallback, then transform the event to text, if it is a media event
// etc
related.quoted_body = QString::fromStdString(mtx::accessors::body(*event));
QRegularExpression plainQuote("^>.*?$\n?", QRegularExpression::MultilineOption);
while (related.quoted_body.startsWith(">"))
related.quoted_body.remove(plainQuote);
if (related.quoted_body.startsWith("\n"))
related.quoted_body.remove(0, 1);
related.quoted_body = utils::getQuoteBody(related);
related.quoted_body.replace("@room", QString::fromUtf8("@\u2060room"));
// get quoted body and strip reply fallback
related.quoted_formatted_body = mtx::accessors::formattedBodyWithFallback(*event);
related.quoted_formatted_body.remove(QRegularExpression(
"<mx-reply>.*</mx-reply>", QRegularExpression::DotMatchesEverythingOption));
related.quoted_formatted_body.replace("@room", "@\u2060aroom");
related.room = room_id_;
return related;
return utils::stripReplyFallbacks(*event, id.toStdString(), room_id_);
}
void