Add a route to update the name of an attachment

This commit is contained in:
Eike Kettner
2020-06-14 12:34:07 +02:00
parent e15e2c9313
commit 84a26461ed
4 changed files with 76 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import org.http4s.dsl.Http4sDsl
import org.http4s.headers._
import org.http4s.headers.ETag.EntityTag
import org.http4s.circe.CirceEntityEncoder._
import org.http4s.circe.CirceEntityDecoder._
import docspell.backend.BackendApp
import docspell.backend.auth.AuthToken
import docspell.backend.ops.OItem
@ -126,6 +127,13 @@ object AttachmentRoutes {
resp <- md.map(Ok(_)).getOrElse(NotFound(BasicResult(false, "Not found.")))
} yield resp
case req @ POST -> Root / Ident(id) / "name" =>
for {
nn <- req.as[OptionalText]
res <- backend.item.setAttachmentName(id, nn.text, user.account.collective)
resp <- Ok(Conversions.basicResult(res, "Name updated."))
} yield resp
case DELETE -> Root / Ident(id) =>
for {
n <- backend.item.deleteAttachment(id, user.account.collective)