Adopt restserver to new collective-id

This commit is contained in:
eikek
2022-08-04 12:44:09 +02:00
parent 53d92c4a26
commit eabcffe71a
48 changed files with 539 additions and 293 deletions

View File

@ -16,7 +16,11 @@ import docspell.notification.api._
import docspell.store.queries.QLogin
import docspell.store.records._
import db.migration.data._
import db.migration.data.{
PeriodicDueItemsArgs => PeriodicDueItemsArgsLegacy,
PeriodicQueryArgs => PeriodicQueryArgsLegacy,
_
}
import doobie._
import doobie.implicits._
import doobie.util.transactor.Strategy
@ -75,8 +79,8 @@ trait MigrationTasks {
ref.flatMap(channelRef =>
RPeriodicTask.updateTask(
old.id,
PeriodicQueryArgs.taskName,
PeriodicQueryArgs(
PeriodicQueryArgsLegacy.taskName,
PeriodicQueryArgsLegacy(
oldArgs.account,
NonEmptyList.of(channelRef),
oldArgs.query,
@ -105,8 +109,8 @@ trait MigrationTasks {
ref.flatMap(channelRef =>
RPeriodicTask.updateTask(
old.id,
PeriodicDueItemsArgs.taskName,
PeriodicDueItemsArgs(
PeriodicDueItemsArgsLegacy.taskName,
PeriodicDueItemsArgsLegacy(
oldArgs.account,
NonEmptyList.of(channelRef),
oldArgs.remindDays,
@ -147,7 +151,7 @@ trait MigrationTasks {
RPeriodicTask
.updateTask(
old.id,
PeriodicDueItemsArgs.taskName,
PeriodicDueItemsArgsLegacy.taskName,
a.asJson.noSpaces
)
)
@ -163,7 +167,7 @@ trait MigrationTasks {
private def convertArgs(
old: NotifyDueItemsArgs
): OptionT[ConnectionIO, PeriodicDueItemsArgs] = {
): OptionT[ConnectionIO, PeriodicDueItemsArgsLegacy] = {
val recs = old.recipients
.map(MailAddress.parse)
.flatMap {
@ -188,7 +192,7 @@ trait MigrationTasks {
now
)
_ <- OptionT.liftF(RNotificationChannelMail.insert(ch))
args = PeriodicDueItemsArgs(
args = PeriodicDueItemsArgsLegacy(
old.account,
NonEmptyList.of(ChannelRef(ch.id, ChannelType.Mail, chName)),
old.remindDays,

View File

@ -0,0 +1,43 @@
/*
* Copyright 2020 Eike K. & Contributors
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
package db.migration.data
import cats.data.NonEmptyList
import docspell.common._
import docspell.notification.api.ChannelRef
import io.circe.generic.semiauto
import io.circe.{Decoder, Encoder}
/** 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.
*
* @deprecated
* replaced with a version using `AccountInfo`
*/
final case class PeriodicDueItemsArgs(
account: AccountId,
channels: NonEmptyList[ChannelRef],
remindDays: Int,
daysBack: Option[Int],
tagsInclude: List[Ident],
tagsExclude: List[Ident],
baseUrl: Option[LenientUri]
)
object PeriodicDueItemsArgs {
val taskName = Ident.unsafe("periodic-due-items-notify2")
implicit val jsonDecoder: Decoder[PeriodicDueItemsArgs] =
semiauto.deriveDecoder
implicit val jsonEncoder: Encoder[PeriodicDueItemsArgs] =
semiauto.deriveEncoder
}

View File

@ -0,0 +1,33 @@
/*
* Copyright 2020 Eike K. & Contributors
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
package db.migration.data
import cats.data.NonEmptyList
import docspell.common._
import docspell.notification.api.ChannelRef
import io.circe.generic.semiauto
import io.circe.{Decoder, Encoder}
/** @deprecated replaced with a version using `AccountInfo` */
final case class PeriodicQueryArgs(
account: AccountId,
channels: NonEmptyList[ChannelRef],
query: Option[ItemQueryString],
bookmark: Option[String],
baseUrl: Option[LenientUri],
contentStart: Option[String]
)
object PeriodicQueryArgs {
val taskName = Ident.unsafe("periodic-query-notify2")
implicit val jsonDecoder: Decoder[PeriodicQueryArgs] =
semiauto.deriveDecoder
implicit def jsonEncoder: Encoder[PeriodicQueryArgs] =
semiauto.deriveEncoder
}

View File

@ -0,0 +1,69 @@
/*
* Copyright 2020 Eike K. & Contributors
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
package db.migration.data
import docspell.common._
import docspell.common.syntax.all._
import io.circe._
import io.circe.generic.semiauto._
/** 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.
*
* @deprecated
* replaced with a version using `AccountInfo`
*/
case class ScanMailboxArgs(
// the docspell user account
account: AccountId,
// the configured imap connection
imapConnection: Ident,
// scan folders recursively
scanRecursively: Option[Boolean],
// 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],
// set a folder for items
itemFolder: Option[Ident],
// set a filter for files when importing archives
fileFilter: Option[Glob],
// set a list of tags to apply to new item
tags: Option[List[String]],
// a glob filter for the mail subject
subjectFilter: Option[Glob],
// the language for extraction and analysis
language: Option[Language],
// apply additional filter to all mails or only imported
postHandleAll: Option[Boolean],
// Exclude the mail body when importing
attachmentsOnly: Option[Boolean]
)
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]
}

View File

@ -30,12 +30,12 @@ object RFolder {
def newFolder[F[_]: Sync](
name: String,
collective: CollectiveId,
user: Ident
ownerUserId: Ident
): F[RFolder] =
for {
nId <- Ident.randomId[F]
now <- Timestamp.current[F]
} yield RFolder(nId, name, collective, user, now)
} yield RFolder(nId, name, collective, ownerUserId, now)
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "folder"