From 750be99aaf967c6f8978c3419642999bc313632d Mon Sep 17 00:00:00 2001 From: "martin f. krafft" <madduck@madduck.net> Date: Sun, 12 Nov 2023 11:00:35 +0100 Subject: [PATCH] Add logic to set due date from addons, based on #2362 Signed-off-by: martin f. krafft <madduck@madduck.net> --- .../src/main/scala/docspell/backend/BackendCommands.scala | 6 ++++++ .../src/main/scala/docspell/common/bc/ItemAction.scala | 6 ++++++ .../main/scala/docspell/website/AddonOutputExample.scala | 1 + 3 files changed, 13 insertions(+) diff --git a/modules/backend/src/main/scala/docspell/backend/BackendCommands.scala b/modules/backend/src/main/scala/docspell/backend/BackendCommands.scala index 4417adb0..f54bf5e1 100644 --- a/modules/backend/src/main/scala/docspell/backend/BackendCommands.scala +++ b/modules/backend/src/main/scala/docspell/backend/BackendCommands.scala @@ -127,6 +127,12 @@ private[backend] class BackendCommands[F[_]: Sync]( itemOps .setItemDate(Nel.of(item), date.some, collective) .void + + case ItemAction.SetDueDate(duedate) => + logger.debug(s"Set due date $duedate on item ${item.id} for $collective") *> + itemOps + .setItemDueDate(Nel.of(item), duedate, collective) + .void } def runAttachAction( diff --git a/modules/common/src/main/scala/docspell/common/bc/ItemAction.scala b/modules/common/src/main/scala/docspell/common/bc/ItemAction.scala index f84e5dc5..4e41fa3d 100644 --- a/modules/common/src/main/scala/docspell/common/bc/ItemAction.scala +++ b/modules/common/src/main/scala/docspell/common/bc/ItemAction.scala @@ -105,4 +105,10 @@ object ItemAction { implicit val jsonDecoder: Decoder[SetDate] = deriveDecoder implicit val jsonEncoder: Encoder[SetDate] = deriveEncoder } + + case class SetDueDate(duedate: Option[Timestamp]) extends ItemAction + object SetDueDate { + implicit val jsonDecoder: Decoder[SetDueDate] = deriveDecoder + implicit val jsonEncoder: Encoder[SetDueDate] = deriveEncoder + } } diff --git a/website/src/main/scala/docspell/website/AddonOutputExample.scala b/website/src/main/scala/docspell/website/AddonOutputExample.scala index 7cdf6e67..65b77c74 100644 --- a/website/src/main/scala/docspell/website/AddonOutputExample.scala +++ b/website/src/main/scala/docspell/website/AddonOutputExample.scala @@ -21,6 +21,7 @@ object AddonOutputExample extends Helper { ItemAction.ReplaceTags(Set("tagX", "tagY")), ItemAction.RemoveTags(Set("tag0", "tag9")), ItemAction.RemoveTagsCategory(Set("doc-type")), + ItemAction.SetDueDate(Some(Timestamp.ofMillis(1707908400000L))), ItemAction.SetFolder("folder-name".some), ItemAction.SetCorrOrg(id("OaIy-org-ID").some), ItemAction.SetCorrPerson(id("OaIy-person-ID").some),