mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-31 05:15:08 +00:00
Add ScanMailboxArgs
This commit is contained in:
parent
c9de74fd91
commit
5d5311913c
@ -4,7 +4,7 @@ import cats.implicits._
|
||||
import scala.concurrent.duration.{FiniteDuration, Duration => SDur}
|
||||
import java.time.{Duration => JDur}
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
import io.circe._
|
||||
import cats.effect.Sync
|
||||
|
||||
case class Duration(nanos: Long) {
|
||||
@ -54,4 +54,11 @@ object Duration {
|
||||
now <- Timestamp.current[F]
|
||||
end = Timestamp.current[F]
|
||||
} yield end.map(e => Duration.millis(e.toMillis - now.toMillis))
|
||||
|
||||
|
||||
implicit val jsonEncoder: Encoder[Duration] =
|
||||
Encoder.encodeLong.contramap(_.millis)
|
||||
|
||||
implicit val jsonDecoder: Decoder[Duration] =
|
||||
Decoder.decodeLong.map(Duration.millis)
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package docspell.common
|
||||
|
||||
import io.circe._, io.circe.generic.semiauto._
|
||||
import docspell.common.syntax.all._
|
||||
|
||||
/** Arguments to the poll-mailbox task.
|
||||
*
|
||||
* This tasks queries user mailboxes and pushes found mails into
|
||||
* docspell for processing.
|
||||
*
|
||||
* If the structure changes, there must be some database migration to
|
||||
* update or remove the json data of the corresponding task.
|
||||
*/
|
||||
case class ScanMailboxArgs(
|
||||
// the docspell user account
|
||||
account: AccountId,
|
||||
// the configured imap connection
|
||||
imapConnection: Ident,
|
||||
// what folders to search
|
||||
folders: List[String],
|
||||
// only select mails received since then
|
||||
receivedSince: Option[Duration],
|
||||
// move submitted mails to another folder
|
||||
targetFolder: Option[String],
|
||||
// delete the after submitting (only if targetFolder is None)
|
||||
deleteMail: Boolean,
|
||||
// set the direction when submitting
|
||||
direction: Option[Direction]
|
||||
)
|
||||
|
||||
object ScanMailboxArgs {
|
||||
|
||||
val taskName = Ident.unsafe("scan-mailbox")
|
||||
|
||||
implicit val jsonEncoder: Encoder[ScanMailboxArgs] =
|
||||
deriveEncoder[ScanMailboxArgs]
|
||||
implicit val jsonDecoder: Decoder[ScanMailboxArgs] =
|
||||
deriveDecoder[ScanMailboxArgs]
|
||||
|
||||
def parse(str: String): Either[Throwable, ScanMailboxArgs] =
|
||||
str.parseJsonAs[ScanMailboxArgs]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user