summary refs log tree commit diff
path: root/src/notifications/ManagerMac.cpp
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2021-11-03 21:43:11 -0400
committerJoseph Donofry <joedonofry@gmail.com>2021-11-03 21:43:11 -0400
commit743a83c8e6f0b64b21e8042a9eb04ce35c713008 (patch)
treef980bdb8c45e607547f87e48f42144227166aa6c /src/notifications/ManagerMac.cpp
parentMerge remote-tracking branch 'nheko-im/master' into video_player_enhancements (diff)
parentUpdate translations (diff)
downloadnheko-743a83c8e6f0b64b21e8042a9eb04ce35c713008.tar.xz
Update video_player_enhancements with changes from master
Diffstat (limited to 'src/notifications/ManagerMac.cpp')
-rw-r--r--src/notifications/ManagerMac.cpp74
1 files changed, 38 insertions, 36 deletions
diff --git a/src/notifications/ManagerMac.cpp b/src/notifications/ManagerMac.cpp

index 8e36985c..30948dae 100644 --- a/src/notifications/ManagerMac.cpp +++ b/src/notifications/ManagerMac.cpp
@@ -19,48 +19,50 @@ static QString formatNotification(const mtx::responses::Notification &notification) { - return utils::stripReplyFallbacks(notification.event, {}, {}).quoted_body; + return utils::stripReplyFallbacks(notification.event, {}, {}).quoted_body; } void NotificationsManager::postNotification(const mtx::responses::Notification &notification, const QImage &icon) { - Q_UNUSED(icon) + Q_UNUSED(icon) - 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 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>>( - &notification.event) != nullptr; - const auto isReply = utils::isReply(notification.event); - if (isEncrypted) { - // TODO: decrypt this message if the decryption setting is on in the UserSettings - const QString messageInfo = (isReply ? tr("%1 replied with an encrypted message") - : tr("%1 sent an encrypted message")) - .arg(sender); - objCxxPostNotification(room_name, messageInfo, "", QImage()); - } else { - const QString messageInfo = - (isReply ? tr("%1 replied to a message") : tr("%1 sent a message")).arg(sender); - if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image) - MxcImageProvider::download( - QString::fromStdString(mtx::accessors::url(notification.event)) - .remove("mxc://"), - QSize(200, 80), - [this, notification, room_name, messageInfo]( - QString, QSize, QImage image, QString) { - objCxxPostNotification(room_name, - messageInfo, - formatNotification(notification), - image); - }); - else - objCxxPostNotification( - room_name, messageInfo, formatNotification(notification), QImage()); - } + const auto room_id = QString::fromStdString(notification.room_id); + const auto event_id = QString::fromStdString(mtx::accessors::event_id(notification.event)); + + const auto isEncrypted = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>( + &notification.event) != nullptr; + const auto isReply = utils::isReply(notification.event); + if (isEncrypted) { + // TODO: decrypt this message if the decryption setting is on in the UserSettings + const QString messageInfo = (isReply ? tr("%1 replied with an encrypted message") + : tr("%1 sent an encrypted message")) + .arg(sender); + objCxxPostNotification(room_name, room_id, event_id, messageInfo, "", ""); + } else { + const QString messageInfo = + (isReply ? tr("%1 replied to a message") : tr("%1 sent a message")).arg(sender); + if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image) + MxcImageProvider::download( + QString::fromStdString(mtx::accessors::url(notification.event)).remove("mxc://"), + QSize(200, 80), + [this, notification, room_name, room_id, event_id, messageInfo]( + QString, QSize, QImage, QString imgPath) { + objCxxPostNotification(room_name, + room_id, + event_id, + messageInfo, + formatNotification(notification), + imgPath); + }); + else + objCxxPostNotification( + room_name, room_id, event_id, messageInfo, formatNotification(notification), ""); + } }