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.
65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\WorkflowDeckAutomation\Migration;
|
|
|
|
use Closure;
|
|
use OCP\DB\ISchemaWrapper;
|
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
|
use OCP\DB\Types;
|
|
use OCP\IDBConnection;
|
|
use OCP\Migration\IOutput;
|
|
use OCP\Migration\SimpleMigrationStep;
|
|
|
|
/**
|
|
* Replaces the yes/no `notify_email` flag with `notify_mode`
|
|
* (off / owner / board, see NotificationPolicy::MODES).
|
|
*
|
|
* Existing workflows keep behaving exactly as before: a set flag becomes
|
|
* `owner` — the only recipient the flag ever had — everything else `off`.
|
|
* The old column is dropped by the next step, once the values are copied.
|
|
*/
|
|
class Version1002Date20261001120000 extends SimpleMigrationStep {
|
|
public function __construct(
|
|
private IDBConnection $db,
|
|
) {
|
|
}
|
|
|
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
|
/** @var ISchemaWrapper $schema */
|
|
$schema = $schemaClosure();
|
|
|
|
if (!$schema->hasTable('wfda_workflows')) {
|
|
return null;
|
|
}
|
|
|
|
$table = $schema->getTable('wfda_workflows');
|
|
if ($table->hasColumn('notify_mode')) {
|
|
return null;
|
|
}
|
|
|
|
$table->addColumn('notify_mode', Types::STRING, [
|
|
'notnull' => true,
|
|
'length' => 16,
|
|
'default' => 'off',
|
|
]);
|
|
|
|
return $schema;
|
|
}
|
|
|
|
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
|
/** @var ISchemaWrapper $schema */
|
|
$schema = $schemaClosure();
|
|
if (!$schema->hasTable('wfda_workflows') || !$schema->getTable('wfda_workflows')->hasColumn('notify_email')) {
|
|
return;
|
|
}
|
|
|
|
$qb = $this->db->getQueryBuilder();
|
|
$qb->update('wfda_workflows')
|
|
->set('notify_mode', $qb->createNamedParameter('owner'))
|
|
->where($qb->expr()->eq('notify_email', $qb->createNamedParameter(true, IQueryBuilder::PARAM_BOOL)));
|
|
$qb->executeStatement();
|
|
}
|
|
}
|