mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
parent
3517b6506c
commit
a1968110d5
1 changed files with 2 additions and 15 deletions
|
@ -51,15 +51,8 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
|
||||||
const QImage &icon)
|
const QImage &icon)
|
||||||
{
|
{
|
||||||
const auto room_name = QString::fromStdString(cache::singleRoomInfo(notification.room_id).name);
|
const auto room_name = QString::fromStdString(cache::singleRoomInfo(notification.room_id).name);
|
||||||
const auto sender =
|
|
||||||
cache::displayName(QString::fromStdString(notification.room_id),
|
|
||||||
QString::fromStdString(mtx::accessors::sender(notification.event)));
|
|
||||||
|
|
||||||
const auto isEncrypted = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
auto formatNotification = [this, notification] {
|
||||||
¬ification.event) != nullptr;
|
|
||||||
const auto isReply = utils::isReply(notification.event);
|
|
||||||
|
|
||||||
auto formatNotification = [this, notification, sender] {
|
|
||||||
const auto template_ = getMessageTemplate(notification);
|
const auto template_ = getMessageTemplate(notification);
|
||||||
if (std::holds_alternative<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
if (std::holds_alternative<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
||||||
notification.event)) {
|
notification.event)) {
|
||||||
|
@ -69,18 +62,12 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
|
||||||
return template_.arg(utils::stripReplyFallbacks(notification.event, {}, {}).quoted_body);
|
return template_.arg(utils::stripReplyFallbacks(notification.event, {}, {}).quoted_body);
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto line1 =
|
|
||||||
(room_name == sender) ? sender : QString("%1 - %2").arg(sender).arg(room_name);
|
|
||||||
const auto line2 = (isEncrypted ? (isReply ? tr("%1 replied with an encrypted message")
|
|
||||||
: tr("%1 sent an encrypted message"))
|
|
||||||
: formatNotification());
|
|
||||||
|
|
||||||
auto iconPath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + room_name +
|
auto iconPath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + room_name +
|
||||||
"-room-avatar.png";
|
"-room-avatar.png";
|
||||||
if (!icon.save(iconPath))
|
if (!icon.save(iconPath))
|
||||||
iconPath.clear();
|
iconPath.clear();
|
||||||
|
|
||||||
systemPostNotification(line1, line2, iconPath);
|
systemPostNotification(room_name, formatNotification(), iconPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue