Notify board members about moved cards according to their Deck setting
Replaces the yes/no notify_email flag with notify_mode:
- off: no mail
- owner: only the board owner, as before (migrated from notify_email=1)
- board: everyone with access to the board, filtered by their own Deck
"Notifications" setting for it (board:<id>:notify-due: off /
assigned / all), mirroring Deck's NotificationHelper rules
Recipients are resolved via PermissionService::findUsers() (owner, ACL,
groups and circles expanded), AssignmentMapper::isUserAssigned() and
IConfig, none of which reads Deck's frozen $userId. If they cannot be
resolved, no mail is sent rather than one to the wrong people.
Moved cards are collected over the whole run and each recipient gets a
single digest mail afterwards, in their own language.
Bumps to 35.2.0 so the migrations run.
This commit is contained in:
1 parent
27717205cd
commit
578b235f08
14 files changed
+579
-100
No files matched your search
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\WorkflowDeckAutomation\Tests\Unit\Service;
|
||||
|
||||
use OCA\WorkflowDeckAutomation\Service\NotificationPolicy;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NotificationPolicyTest extends TestCase {
|
||||
public function testOffNeverNotifies(): void {
|
||||
$this->assertFalse(NotificationPolicy::shouldNotify('off', false, true));
|
||||
// Not even the owner of an unshared board — "off" is "off" in Deck too.
|
||||
$this->assertFalse(NotificationPolicy::shouldNotify('off', true, true));
|
||||
}
|
||||
|
||||
public function testAllAlwaysNotifies(): void {
|
||||
$this->assertTrue(NotificationPolicy::shouldNotify('all', false, false));
|
||||
$this->assertTrue(NotificationPolicy::shouldNotify('all', true, false));
|
||||
}
|
||||
|
||||
public function testAssignedNotifiesOnlyAssignedUsers(): void {
|
||||
$this->assertTrue(NotificationPolicy::shouldNotify('assigned', false, true));
|
||||
$this->assertFalse(NotificationPolicy::shouldNotify('assigned', false, false));
|
||||
}
|
||||
|
||||
public function testOwnerOfUnsharedBoardIsNotifiedWithAssigned(): void {
|
||||
$this->assertTrue(NotificationPolicy::shouldNotify('assigned', true, false));
|
||||
}
|
||||
|
||||
public function testUnknownSettingFallsBackToDeckDefault(): void {
|
||||
$this->assertTrue(NotificationPolicy::shouldNotify('', false, true));
|
||||
$this->assertFalse(NotificationPolicy::shouldNotify('bogus', false, false));
|
||||
$this->assertTrue(NotificationPolicy::shouldNotify('bogus', true, false));
|
||||
}
|
||||
|
||||
public function testAssignmentIsOnlyLookedUpWhenItMatters(): void {
|
||||
$lookup = function (): bool {
|
||||
$this->fail('assignment lookup must not run');
|
||||
};
|
||||
$this->assertFalse(NotificationPolicy::shouldNotify('off', false, $lookup));
|
||||
$this->assertTrue(NotificationPolicy::shouldNotify('all', false, $lookup));
|
||||
$this->assertTrue(NotificationPolicy::shouldNotify('assigned', true, $lookup));
|
||||
|
||||
$this->assertTrue(NotificationPolicy::shouldNotify('assigned', false, static fn (): bool => true));
|
||||
$this->assertFalse(NotificationPolicy::shouldNotify('assigned', false, static fn (): bool => false));
|
||||
}
|
||||
|
||||
public function testModes(): void {
|
||||
foreach (['off', 'owner', 'board'] as $mode) {
|
||||
$this->assertTrue(NotificationPolicy::isValidMode($mode));
|
||||
}
|
||||
$this->assertFalse(NotificationPolicy::isValidMode(''));
|
||||
$this->assertFalse(NotificationPolicy::isValidMode('all'));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user