summary refs log tree commit diff
path: root/src/notifications/Manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/notifications/Manager.cpp')
-rw-r--r--src/notifications/Manager.cpp24
1 files changed, 24 insertions, 0 deletions
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 &notification) +{ + 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 &notification) {