Server-side stub impl for notify-due-items

This commit is contained in:
Eike Kettner
2020-04-19 20:31:28 +02:00
parent e97e0db45c
commit ad772c0c25
16 changed files with 562 additions and 37 deletions

View File

@ -1,5 +1,7 @@
package docspell.common
import io.circe._
case class AccountId(collective: Ident, user: Ident) {
def asString =
@ -32,4 +34,9 @@ object AccountId {
separated.orElse(Ident.fromString(str).map(id => AccountId(id, id)))
}
implicit val jsonDecoder: Decoder[AccountId] =
Decoder.decodeString.emap(parse)
implicit val jsonEncoder: Encoder[AccountId] =
Encoder.encodeString.contramap(_.asString)
}

View File

@ -0,0 +1,35 @@
package docspell.common
import io.circe._, io.circe.generic.semiauto._
import docspell.common.syntax.all._
/** Arguments to the notification task.
*
* This tasks queries items with a due date and informs the user via
* mail.
*
* If the structure changes, there must be some database migration to
* update or remove the json data of the corresponding task.
*/
case class NotifyDueItemsArgs(
account: AccountId,
smtpConnection: Ident,
recipients: List[String],
remindDays: Int,
tagsInclude: List[Ident],
tagsExclude: List[Ident]
) {}
object NotifyDueItemsArgs {
val taskName = Ident.unsafe("notify-due-items")
implicit val jsonEncoder: Encoder[NotifyDueItemsArgs] =
deriveEncoder[NotifyDueItemsArgs]
implicit val jsonDecoder: Decoder[NotifyDueItemsArgs] =
deriveDecoder[NotifyDueItemsArgs]
def parse(str: String): Either[Throwable, NotifyDueItemsArgs] =
str.parseJsonAs[NotifyDueItemsArgs]
}