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>
This commit is contained in:
Vitor Mattos 2025-12-16 19:12:48 -03:00
parent d077a3174a
commit 263a8cf562
No known key found for this signature in database
GPG key ID: 6FECE2AD4809003A
3 changed files with 21 additions and 0 deletions

View file

@ -279,6 +279,13 @@ class IdentifyAccountController extends AEnvironmentAwareController {
}
$activityUserSettings = \OCP\Server::get(\OCA\Activity\UserSettings::class);
if ($activityUserSettings) {
$manager = \OCP\Server::get(\OCP\Activity\IManager::class);
try {
$manager->getSettingById($type);
} catch (\Exception $e) {
return false;
}
$adminSetting = $activityUserSettings->getAdminSetting('email', $type);
if (!$adminSetting) {
return true;

View file

@ -174,6 +174,13 @@ class MailNotifyListener implements IEventListener {
}
$activityUserSettings = \OCP\Server::get(\OCA\Activity\UserSettings::class);
if ($activityUserSettings) {
$manager = \OCP\Server::get(\OCP\Activity\IManager::class);
try {
$manager->getSettingById($type);
} catch (\Exception $e) {
return false;
}
$adminSetting = $activityUserSettings->getAdminSetting('email', $type);
if (!$adminSetting) {
return true;

View file

@ -210,6 +210,13 @@ class NotificationListener implements IEventListener {
}
$activityUserSettings = \OCP\Server::get(\OCA\Activity\UserSettings::class);
if ($activityUserSettings) {
$manager = \OCP\Server::get(\OCP\Activity\IManager::class);
try {
$manager->getSettingById($type);
} catch (\Exception $e) {
return false;
}
$adminSetting = $activityUserSettings->getAdminSetting('notification', $type);
if (!$adminSetting) {
return true;