From 1f9464cf639546abbb8ef66e70f80b2a8d6d2fcb Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 11 Apr 2024 11:23:00 +0200 Subject: [PATCH] remove swiss dep to chat --- build.sbt | 2 +- modules/chat/src/main/ChatApi.scala | 3 --- modules/swiss/src/main/Env.scala | 2 +- modules/swiss/src/main/SwissApi.scala | 6 ++++-- modules/swiss/src/main/SwissSocket.scala | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 215efed913d84..2ae252afa2da6 100644 --- a/build.sbt +++ b/build.sbt @@ -300,7 +300,7 @@ lazy val tournament = module("tournament", ) lazy val swiss = module("swiss", - Seq(gathering, user, game, chat, room), + Seq(gathering, user, game, room), Seq(scalatags, lettuce) ++ reactivemongo.bundle ++ tests.bundle ) diff --git a/modules/chat/src/main/ChatApi.scala b/modules/chat/src/main/ChatApi.scala index ec7978f2ca37d..d80fc71b66fe5 100644 --- a/modules/chat/src/main/ChatApi.scala +++ b/modules/chat/src/main/ChatApi.scala @@ -123,9 +123,6 @@ final class ChatApi( val line = UserLine(UserName.lichess, None, false, flair = true, text, troll = false, deleted = false) publishLine(chatId, line, busChan) - def service(chatId: ChatId, text: String, busChan: BusChan.Select, isVolatile: Boolean): Unit = - (if isVolatile then volatile else system) (chatId, text, busChan) - def timeout( chatId: ChatId, userId: UserId, diff --git a/modules/swiss/src/main/Env.scala b/modules/swiss/src/main/Env.scala index 32be3e6600f78..2d3da3e00de0f 100644 --- a/modules/swiss/src/main/Env.scala +++ b/modules/swiss/src/main/Env.scala @@ -18,7 +18,7 @@ final class Env( userApi: lila.user.UserApi, onStart: lila.core.game.OnStart, socketKit: lila.core.socket.SocketKit, - chatApi: lila.chat.ChatApi, + chat: lila.core.chat.ChatApi, cacheApi: lila.memo.CacheApi, lightUserApi: lila.user.LightUserApi, historyApi: lila.core.history.HistoryApi, diff --git a/modules/swiss/src/main/SwissApi.scala b/modules/swiss/src/main/SwissApi.scala index 005a26ce91461..1f8006f68a988 100644 --- a/modules/swiss/src/main/SwissApi.scala +++ b/modules/swiss/src/main/SwissApi.scala @@ -36,7 +36,7 @@ final class SwissApi( banApi: SwissBanApi, boardApi: SwissBoardApi, verify: SwissCondition.Verify, - chatApi: lila.chat.ChatApi, + chatApi: lila.core.chat.ChatApi, lightUserApi: lila.user.LightUserApi, roundApi: lila.game.core.RoundApi )(using scheduler: Scheduler)(using Executor, akka.stream.Materializer) @@ -613,7 +613,9 @@ final class SwissApi( } private def systemChat(id: SwissId, text: String, volatile: Boolean = false): Unit = - chatApi.userChat.service(id.into(ChatId), text, _.swiss, isVolatile = volatile) + if volatile + then chatApi.volatile(id.into(ChatId), text, _.swiss) + else chatApi.system(id.into(ChatId), text, _.swiss) def withdrawAll(user: User, teamIds: List[TeamId]): Funit = mongo.swiss diff --git a/modules/swiss/src/main/SwissSocket.scala b/modules/swiss/src/main/SwissSocket.scala index d1077459bbef4..68f8438e1feb3 100644 --- a/modules/swiss/src/main/SwissSocket.scala +++ b/modules/swiss/src/main/SwissSocket.scala @@ -7,7 +7,7 @@ import lila.core.socket.{ protocol as P, * } final private class SwissSocket( socketKit: SocketKit, - chat: lila.chat.ChatApi, + chat: lila.core.chat.ChatApi, teamOf: SwissId => Fu[Option[TeamId]] )(using Executor, akka.actor.ActorSystem, Scheduler, lila.core.user.FlairGet):