mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-10-31 17:50:11 +00:00 
			
		
		
		
	Merge pull request #1842 from eikek/fix/1840-share-with-no-name
Fix querying shares without a name
This commit is contained in:
		| @@ -17,6 +17,11 @@ trait StringSyntax { | |||||||
|     def parseJsonAs[A](implicit d: Decoder[A]): Either[Throwable, A] = |     def parseJsonAs[A](implicit d: Decoder[A]): Either[Throwable, A] = | ||||||
|       parser.decode[A](s) |       parser.decode[A](s) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   implicit class OptionStringOpts(s: Option[String]) { | ||||||
|  |     def asNonBlank: Option[String] = | ||||||
|  |       s.filter(_.trim.nonEmpty) | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| object StringSyntax extends StringSyntax | object StringSyntax extends StringSyntax | ||||||
|   | |||||||
| @@ -14,6 +14,7 @@ import docspell.backend.BackendApp | |||||||
| import docspell.backend.auth.AuthToken | import docspell.backend.auth.AuthToken | ||||||
| import docspell.backend.ops.OShare | import docspell.backend.ops.OShare | ||||||
| import docspell.backend.ops.OShare.{SendResult, ShareMail, VerifyResult} | import docspell.backend.ops.OShare.{SendResult, ShareMail, VerifyResult} | ||||||
|  | import docspell.common.syntax.string._ | ||||||
| import docspell.common.{Ident, Timestamp} | import docspell.common.{Ident, Timestamp} | ||||||
| import docspell.restapi.model._ | import docspell.restapi.model._ | ||||||
| import docspell.restserver.Config | import docspell.restserver.Config | ||||||
| @@ -37,7 +38,7 @@ object ShareRoutes { | |||||||
|       case GET -> Root :? QP.Query(q) :? QP.OwningFlag(owning) => |       case GET -> Root :? QP.Query(q) :? QP.OwningFlag(owning) => | ||||||
|         val login = if (owning) Some(user.account.login) else None |         val login = if (owning) Some(user.account.login) else None | ||||||
|         for { |         for { | ||||||
|           all <- backend.share.findAll(user.account.collectiveId, login, q) |           all <- backend.share.findAll(user.account.collectiveId, login, q.asNonBlank) | ||||||
|           now <- Timestamp.current[F] |           now <- Timestamp.current[F] | ||||||
|           res <- Ok(ShareList(all.map(mkShareDetail(now)))) |           res <- Ok(ShareList(all.map(mkShareDetail(now)))) | ||||||
|         } yield res |         } yield res | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user