diff --git a/src/notifications/Manager.cpp b/src/notifications/Manager.cpp
index d15eea51..f67e01ff 100644
--- a/src/notifications/Manager.cpp
+++ b/src/notifications/Manager.cpp
@@ -5,9 +5,33 @@
#include "notifications/Manager.h"
#include "Cache.h"
+#include "Cache_p.h"
#include "EventAccessors.h"
+#include "UserSettingsPage.h"
#include "Utils.h"
+bool
+NotificationsManager::allowShowingImages(const mtx::responses::Notification ¬ification)
+{
+ auto show = UserSettings::instance()->showImage();
+
+ switch (show) {
+ case UserSettings::ShowImage::Always:
+ return true;
+ case UserSettings::ShowImage::OnlyPrivate: {
+ auto accessRules = cache::client()
+ ->getStateEvent<mtx::events::state::JoinRules>(notification.room_id)
+ .value_or(mtx::events::StateEvent<mtx::events::state::JoinRules>{})
+ .content;
+
+ return accessRules.join_rule != mtx::events::state::JoinRule::Public;
+ }
+ case UserSettings::ShowImage::Never:
+ default:
+ return false;
+ }
+}
+
QString
NotificationsManager::getMessageTemplate(const mtx::responses::Notification ¬ification)
{
diff --git a/src/notifications/Manager.h b/src/notifications/Manager.h
index 707a4fb3..b748b510 100644
--- a/src/notifications/Manager.h
+++ b/src/notifications/Manager.h
@@ -66,7 +66,6 @@ private:
const QString &text,
const QImage &icon);
void closeNotification(uint id);
-
const bool hasMarkup_;
const bool hasImages_;
#endif
@@ -111,6 +110,7 @@ private slots:
private:
QString getMessageTemplate(const mtx::responses::Notification ¬ification);
+ bool allowShowingImages(const mtx::responses::Notification ¬ification);
// notification ID to (room ID, event ID)
// Only populated on Linux atm
diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp
index 75ba1886..1704d3a3 100644
--- a/src/notifications/ManagerLinux.cpp
+++ b/src/notifications/ManagerLinux.cpp
@@ -114,7 +114,7 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
}
if (hasMarkup_) {
- if (hasImages_ &&
+ if (hasImages_ && allowShowingImages(notification) &&
(mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image ||
mtx::accessors::event_type(notification.event) == mtx::events::EventType::Sticker)) {
MxcImageProvider::download(
diff --git a/src/notifications/ManagerMac.cpp b/src/notifications/ManagerMac.cpp
index ee5639e4..03b2480d 100644
--- a/src/notifications/ManagerMac.cpp
+++ b/src/notifications/ManagerMac.cpp
@@ -93,7 +93,9 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
} 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)
+ if (allowShowingImages(notification) &&
+ (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image ||
+ mtx::accessors::event_type(notification.event) == mtx::events::EventType::Sticker))
MxcImageProvider::download(
QString::fromStdString(mtx::accessors::url(notification.event)).remove("mxc://"),
QSize(200, 80),
diff --git a/src/notifications/ManagerWin.cpp b/src/notifications/ManagerWin.cpp
index a69afa4e..03fd4782 100644
--- a/src/notifications/ManagerWin.cpp
+++ b/src/notifications/ManagerWin.cpp
@@ -83,8 +83,9 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
if (!icon.save(iconPath))
iconPath.clear();
- if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image ||
- mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image) {
+ if (allowShowingImages(notification) &&
+ (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image ||
+ mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image)) {
MxcImageProvider::download(
QString::fromStdString(mtx::accessors::url(notification.event))
.remove(QStringLiteral("mxc://")),
|