Ports the standalone due-date cron script into a proper Nextcloud 34 app with a personal-settings UI, per-user workflow configuration (source/target stack, assigned-user and label filters, email notification), a TimedJob background runner, and Gitea CI pipelines. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
99 lines
2.8 KiB
PHP
99 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\WorkflowDeckAutomation\Db;
|
|
|
|
use OCP\AppFramework\Db\Entity;
|
|
use OCP\DB\Types;
|
|
|
|
/**
|
|
* @method string getUserId()
|
|
* @method void setUserId(string $userId)
|
|
* @method string getTitle()
|
|
* @method void setTitle(string $title)
|
|
* @method int getBoardId()
|
|
* @method void setBoardId(int $boardId)
|
|
* @method int getSourceStackId()
|
|
* @method void setSourceStackId(int $sourceStackId)
|
|
* @method int getTargetStackId()
|
|
* @method void setTargetStackId(int $targetStackId)
|
|
* @method string|null getFilterUserIds()
|
|
* @method void setFilterUserIds(?string $filterUserIds)
|
|
* @method string|null getFilterLabelIds()
|
|
* @method void setFilterLabelIds(?string $filterLabelIds)
|
|
* @method bool getNotifyEmail()
|
|
* @method void setNotifyEmail(bool $notifyEmail)
|
|
* @method bool getEnabled()
|
|
* @method void setEnabled(bool $enabled)
|
|
* @method \DateTime|null getLastRun()
|
|
* @method void setLastRun(?\DateTime $lastRun)
|
|
*/
|
|
class Workflow extends Entity implements \JsonSerializable {
|
|
protected $userId;
|
|
protected $title;
|
|
protected $boardId;
|
|
protected $sourceStackId;
|
|
protected $targetStackId;
|
|
protected $filterUserIds;
|
|
protected $filterLabelIds;
|
|
protected $notifyEmail;
|
|
protected $enabled;
|
|
protected $lastRun;
|
|
|
|
public function __construct() {
|
|
$this->addType('id', Types::INTEGER);
|
|
$this->addType('userId', Types::STRING);
|
|
$this->addType('title', Types::STRING);
|
|
$this->addType('boardId', Types::INTEGER);
|
|
$this->addType('sourceStackId', Types::INTEGER);
|
|
$this->addType('targetStackId', Types::INTEGER);
|
|
$this->addType('filterUserIds', Types::STRING);
|
|
$this->addType('filterLabelIds', Types::STRING);
|
|
$this->addType('notifyEmail', Types::BOOLEAN);
|
|
$this->addType('enabled', Types::BOOLEAN);
|
|
$this->addType('lastRun', Types::DATETIME);
|
|
}
|
|
|
|
/**
|
|
* @return string[]
|
|
*/
|
|
public function getFilterUserIdsArray(): array {
|
|
return $this->decodeIds($this->getFilterUserIds());
|
|
}
|
|
|
|
/**
|
|
* @return int[]
|
|
*/
|
|
public function getFilterLabelIdsArray(): array {
|
|
return array_map('intval', $this->decodeIds($this->getFilterLabelIds()));
|
|
}
|
|
|
|
/**
|
|
* @return string[]
|
|
*/
|
|
private function decodeIds(?string $json): array {
|
|
if ($json === null || $json === '') {
|
|
return [];
|
|
}
|
|
$decoded = json_decode($json, true);
|
|
return is_array($decoded) ? array_values($decoded) : [];
|
|
}
|
|
|
|
public function jsonSerialize(): array {
|
|
return [
|
|
'id' => $this->getId(),
|
|
'userId' => $this->getUserId(),
|
|
'title' => $this->getTitle(),
|
|
'boardId' => $this->getBoardId(),
|
|
'sourceStackId' => $this->getSourceStackId(),
|
|
'targetStackId' => $this->getTargetStackId(),
|
|
'filterUserIds' => $this->getFilterUserIdsArray(),
|
|
'filterLabelIds' => $this->getFilterLabelIdsArray(),
|
|
'notifyEmail' => (bool)$this->getNotifyEmail(),
|
|
'enabled' => (bool)$this->getEnabled(),
|
|
'lastRun' => $this->getLastRun()?->format(\DateTimeInterface::ATOM),
|
|
];
|
|
}
|
|
}
|