summary refs log tree commit diff
path: root/src/notifications/Manager.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2024-08-21 00:14:34 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2024-08-21 00:29:11 +0200
commitd1eb35197546a491ce3503c7c2582980e90b6c52 (patch)
treef563e0a6d99e423970d9bfd954f24123bb8608ed /src/notifications/Manager.cpp
parentWarn about room name and topic not being encrypted (diff)
downloadnheko-d1eb35197546a491ce3503c7c2582980e90b6c52.tar.xz
Allow loading image only after explicit interactions
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) {