Files
nextcloud-workflow-deck-aut…/lib/Db/Workflow.php
T
gnilebein 28b4edc811
Build package / php-lint (8.4) (push) Successful in 43s
Build package / php-lint (8.5) (push) Successful in 40s
Build package / xml-lint (push) Successful in 12s
Build package / unit-tests (push) Successful in 38s
Build package / package (push) Successful in 52s
revert 0e66319a06
revert Let each workflow watch the due date or the start date

Deck 1.18 added a start date to cards (Card::$startdate), so a workflow
no longer has to mean "overdue". Each rule now carries a date_field
('due' | 'start'), chosen in the settings form next to board and stacks.

Existing rules keep the due date: the new column's default supplies it
for every stored row, so there is no backfill step, and
Workflow::getDateFieldOrDue() covers entities that were never near the
database as well as hand-edited values. The controller is the one place
that rejects an unknown value instead of normalising it - a client
asking for a rule it would not get should hear about it.

The probe for the field is property_exists(), not method_exists():
Deck's entities declare no getter as real code - getStartdate(),
getDuedate(), even getId() all go through Entity::__call(), which
method_exists() ignores by definition. A method_exists() guard would
have been false on every Deck version and would have turned every
start-date rule into a silent no-op.

assertDeckAvailable() now also refuses Deck older than 1.18.0. That
floor cannot live in appinfo/info.xml - neither the server's nor the app
store's schema has an app-to-app dependency element - but
<nextcloud min-version="34"> already implies it, since 1.18.x is the
only Deck release line published for Nextcloud 34.

isOverdue() becomes hasPassed(): one function for both dates, since the
comparison and the argument against Deck's day-truncating
getDaysUntilDue() are identical for either.

Also carries a pending NcSelect icon-alignment fix that was already in
the working tree.

Bump to 34.1.0.
2026-08-26 07:10:55 +02:00

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),
];
}
}