From 4d5390e6d36230af808e7e23db892fd84864571e Mon Sep 17 00:00:00 2001 From: Simon Dumas Date: Thu, 5 Oct 2023 11:54:55 +0200 Subject: [PATCH] Use Transactors read/write with Cats Effect --- .../bluebrain/nexus/delta/plugins/jira/TokenStore.scala | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/delta/plugins/jira/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/jira/TokenStore.scala b/delta/plugins/jira/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/jira/TokenStore.scala index 6b91f52d77..cef29e1c0d 100644 --- a/delta/plugins/jira/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/jira/TokenStore.scala +++ b/delta/plugins/jira/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/jira/TokenStore.scala @@ -1,7 +1,6 @@ package ch.epfl.bluebrain.nexus.delta.plugins.jira import cats.effect.{Clock, IO} -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.kernel.utils.IOInstant import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors import ch.epfl.bluebrain.nexus.delta.sourcing.implicits._ @@ -43,12 +42,10 @@ object TokenStore { def apply(xas: Transactors)(implicit clock: Clock[IO]): TokenStore = { new TokenStore { override def get(user: Identity.User): IO[Option[OAuthToken]] = - toCatsIO( sql"SELECT token_value FROM jira_tokens WHERE realm = ${user.realm.value} and subject = ${user.subject}" .query[Json] .option - .transact(xas.read) - ) + .transact(xas.readCE) .flatMap { case Some(token) => IO.fromEither(token.as[OAuthToken]).map(Some(_)) @@ -60,7 +57,7 @@ object TokenStore { sql""" INSERT INTO jira_tokens(realm, subject, instant, token_value) | VALUES(${user.realm.value}, ${user.subject}, $now, ${oauthToken.asJson}) | ON CONFLICT (realm, subject) DO UPDATE SET instant = EXCLUDED.instant, token_value = EXCLUDED.token_value - """.stripMargin.update.run.transact(xas.write).void + """.stripMargin.update.run.transact(xas.writeCE).void } } }