diff --git a/modules/account/src/main/scala/de/nowchess/account/resource/OfficialChallengeResource.scala b/modules/account/src/main/scala/de/nowchess/account/resource/OfficialChallengeResource.scala index 863f596..dba3473 100644 --- a/modules/account/src/main/scala/de/nowchess/account/resource/OfficialChallengeResource.scala +++ b/modules/account/src/main/scala/de/nowchess/account/resource/OfficialChallengeResource.scala @@ -2,7 +2,7 @@ package de.nowchess.account.resource import de.nowchess.account.client.{CoreCreateGameRequest, CoreGameClient, CorePlayerInfo} import de.nowchess.account.dto.{ErrorDto, OfficialChallengeResponse} -import de.nowchess.account.service.{AccountService, BotEventPublisher} +import de.nowchess.account.service.{AccountService, EventPublisher} import jakarta.annotation.security.RolesAllowed import jakarta.enterprise.context.ApplicationScoped import jakarta.inject.Inject @@ -25,7 +25,7 @@ class OfficialChallengeResource: // scalafix:off DisableSyntax.var @Inject var accountService: AccountService = uninitialized @Inject var jwt: JsonWebToken = uninitialized - @Inject var botEventPublisher: BotEventPublisher = uninitialized + @Inject var botEventPublisher: EventPublisher = uninitialized @Inject @RestClient diff --git a/modules/account/src/main/scala/de/nowchess/account/service/ChallengeService.scala b/modules/account/src/main/scala/de/nowchess/account/service/ChallengeService.scala index f7b825c..b95eb15 100644 --- a/modules/account/src/main/scala/de/nowchess/account/service/ChallengeService.scala +++ b/modules/account/src/main/scala/de/nowchess/account/service/ChallengeService.scala @@ -47,7 +47,7 @@ class ChallengeService: var coreGameClient: CoreGameClient = uninitialized @Inject - var botEventPublisher: BotEventPublisher = uninitialized + var eventPublisher: EventPublisher = uninitialized // scalafix:on @Transactional @@ -74,7 +74,7 @@ class ChallengeService: challenge.createdAt = Instant.now() challenge.expiresAt = Instant.now().plus(24, ChronoUnit.HOURS) challengeRepository.persist(challenge) - try botEventPublisher.publishChallengeCreated(destUser.id.toString, challenge.id.toString, challenger.username) + try eventPublisher.publishChallengeCreated(destUser.id.toString, challenge.id.toString, challenger.username) catch case ex: Exception => log.warnf(ex, "Failed to notify dest user for challenge %s", challenge.id) challenge @@ -90,7 +90,7 @@ class ChallengeService: challenge.gameId = gameId challengeRepository.merge(challenge) notifyBotIfNeeded(challenge, gameId) - try botEventPublisher.publishChallengeAccepted(challenge.challenger.id.toString, challenge.id.toString, gameId) + try eventPublisher.publishChallengeAccepted(challenge.challenger.id.toString, challenge.id.toString, gameId) catch case ex: Exception => log.warnf(ex, "Failed to notify challenger for game %s", gameId) challenge @@ -138,7 +138,7 @@ class ChallengeService: List(challenge.challenger, challenge.destUser).foreach { user => user.getBotAccounts.headOption.foreach { bot => val playingAs = if white.id == user.id.toString then "white" else "black" - try botEventPublisher.publishGameStart(bot.id.toString, gameId, playingAs, 1400, bot.id.toString) + try eventPublisher.publishGameStart(bot.id.toString, gameId, playingAs, 1400, bot.id.toString) catch case ex: Exception => log.warnf(ex, "Failed to notify bot for game %s", gameId) } } diff --git a/modules/account/src/main/scala/de/nowchess/account/service/BotEventPublisher.scala b/modules/account/src/main/scala/de/nowchess/account/service/EventPublisher.scala similarity index 98% rename from modules/account/src/main/scala/de/nowchess/account/service/BotEventPublisher.scala rename to modules/account/src/main/scala/de/nowchess/account/service/EventPublisher.scala index 6e299b8..42e58a6 100644 --- a/modules/account/src/main/scala/de/nowchess/account/service/BotEventPublisher.scala +++ b/modules/account/src/main/scala/de/nowchess/account/service/EventPublisher.scala @@ -7,7 +7,7 @@ import org.redisson.api.RedissonClient import scala.compiletime.uninitialized @ApplicationScoped -class BotEventPublisher: +class EventPublisher: // scalafix:off DisableSyntax.var @Inject var redisson: RedissonClient = uninitialized