Skip to content

Commit 263a8cf

Browse files
committed
fix: allow notifications when Activity setting is not registered
When Activity app doesn't know about LibreSign's notification settings (common in test environments or fresh installations), we should allow notifications by default instead of blocking them. This fix checks if the Activity manager has the setting registered before enforcing the admin setting. If the setting is not found, notifications are allowed, respecting LibreSign's isDefaultEnabledMail() and isDefaultEnabledNotification() which return true. Fixes email and notification delivery in integration tests. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent d077a31 commit 263a8cf

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

lib/Controller/IdentifyAccountController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ private function isNotificationDisabledAtActivity(string $userId, string $type):
279279
}
280280
$activityUserSettings = \OCP\Server::get(\OCA\Activity\UserSettings::class);
281281
if ($activityUserSettings) {
282+
$manager = \OCP\Server::get(\OCP\Activity\IManager::class);
283+
try {
284+
$manager->getSettingById($type);
285+
} catch (\Exception $e) {
286+
return false;
287+
}
288+
282289
$adminSetting = $activityUserSettings->getAdminSetting('email', $type);
283290
if (!$adminSetting) {
284291
return true;

lib/Listener/MailNotifyListener.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ private function isNotificationDisabledAtActivity(string $userId, string $type):
174174
}
175175
$activityUserSettings = \OCP\Server::get(\OCA\Activity\UserSettings::class);
176176
if ($activityUserSettings) {
177+
$manager = \OCP\Server::get(\OCP\Activity\IManager::class);
178+
try {
179+
$manager->getSettingById($type);
180+
} catch (\Exception $e) {
181+
return false;
182+
}
183+
177184
$adminSetting = $activityUserSettings->getAdminSetting('email', $type);
178185
if (!$adminSetting) {
179186
return true;

lib/Listener/NotificationListener.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ private function isNotificationDisabledAtActivity(string $userId, string $type):
210210
}
211211
$activityUserSettings = \OCP\Server::get(\OCA\Activity\UserSettings::class);
212212
if ($activityUserSettings) {
213+
$manager = \OCP\Server::get(\OCP\Activity\IManager::class);
214+
try {
215+
$manager->getSettingById($type);
216+
} catch (\Exception $e) {
217+
return false;
218+
}
219+
213220
$adminSetting = $activityUserSettings->getAdminSetting('notification', $type);
214221
if (!$adminSetting) {
215222
return true;

0 commit comments

Comments
 (0)