summary refs log tree commit diff
path: root/src/notifications/ManagerMac.cpp
diff options
context:
space:
mode:
authorZhymabek Roman <61125068+ZhymabekRoman@users.noreply.github.com>2023-01-02 21:59:29 +0600
committerGitHub <noreply@github.com>2023-01-02 21:59:29 +0600
commit59410a99ac9b5a90356adc2192b8c6107456c78f (patch)
treef42e081641cee3d62057208f3af1de3afddd02e6 /src/notifications/ManagerMac.cpp
parentAppImage: reduce package size (diff)
parentA whole new year full of excitement and possibilities! (diff)
downloadnheko-59410a99ac9b5a90356adc2192b8c6107456c78f.tar.xz
Merge branch 'master' into master
Diffstat (limited to 'src/notifications/ManagerMac.cpp')
-rw-r--r--src/notifications/ManagerMac.cpp57
1 files changed, 51 insertions, 6 deletions
diff --git a/src/notifications/ManagerMac.cpp b/src/notifications/ManagerMac.cpp

index d5faaf59..cec87c66 100644 --- a/src/notifications/ManagerMac.cpp +++ b/src/notifications/ManagerMac.cpp
@@ -1,5 +1,6 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors // SPDX-FileCopyrightText: 2022 Nheko Contributors +// SPDX-FileCopyrightText: 2023 Nheko Contributors // // SPDX-License-Identifier: GPL-3.0-or-later @@ -40,12 +41,36 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif const auto isEncrypted = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>( &notification.event) != nullptr; const auto isReply = utils::isReply(notification.event); + + // Putting these here to pass along since I'm not sure how + // our translate step interacts with .mm files + const auto respondStr = QObject::tr("Respond"); + const auto sendStr = QObject::tr("Send"); + const auto placeholder = QObject::tr("Write a message..."); + + auto playSound = false; + + if (std::find(notification.actions.begin(), + notification.actions.end(), + mtx::pushrules::actions::Action{mtx::pushrules::actions::set_tweak_sound{ + .value = "default"}}) != notification.actions.end()) { + playSound = true; + } 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, "", ""); + objCxxPostNotification(room_name, + room_id, + event_id, + messageInfo, + "", + "", + respondStr, + sendStr, + placeholder, + playSound); } else { const QString messageInfo = (isReply ? tr("%1 replied to a message") : tr("%1 sent a message")).arg(sender); @@ -53,17 +78,37 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif 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) { + [this, + notification, + room_name, + room_id, + event_id, + messageInfo, + respondStr, + sendStr, + placeholder, + playSound](QString, QSize, QImage, QString imgPath) { objCxxPostNotification(room_name, room_id, event_id, messageInfo, formatNotification(notification), - imgPath); + imgPath, + respondStr, + sendStr, + placeholder, + playSound); }); else - objCxxPostNotification( - room_name, room_id, event_id, messageInfo, formatNotification(notification), ""); + objCxxPostNotification(room_name, + room_id, + event_id, + messageInfo, + formatNotification(notification), + "", + respondStr, + sendStr, + placeholder, + playSound); } }