Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonValue
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import java.time.OffsetDateTime

/**
* API to manage connection to the Lobby server
Expand Down Expand Up @@ -49,9 +50,15 @@ internal class InvalidResponse : ServerMessage
* A general message from the server (automated or broadcast from admin) to display to the user.
* FIXME: Should maybe offer event codes for translations in case of automated responses.
*/
data class NoticeInfo(
data class NoticeInfo @JvmOverloads constructor(
val style: String?,
val text: String?,
@JsonProperty("i18n_key")
val i18nKey: String? = null,
@JsonProperty("i18n_args")
val i18nArgs: List<String> = emptyList(),
@JsonProperty("expires_at")
val expiresAt: OffsetDateTime? = null,
) : ServerMessage

/**
Expand Down Expand Up @@ -210,4 +217,3 @@ internal class ClientPingMessage : ClientMessage
* Holds no data, just checks if the connection is still alive
*/
internal class ClientPongMessage : ClientMessage

Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,33 @@ class ServerMessageTest {
assertEquals(NoticeInfo("kill", "boo"), result)
}

@Test
fun deserializeLocalizableNoticeInfo() {
val result = objectMapper.readValue<ServerMessage>(
"""
{
"command": "notice",
"style": "error",
"text": "You are banned from FAF until 2026-05-10T22:00:00+00:00. Reason: test",
"i18n_key": "login.error.banned",
"i18n_args": ["2026-05-10T22:00:00+00:00", "test"],
"expires_at": "2026-05-10T22:00:00+00:00"
}
""".trimIndent()
)

assertEquals(
NoticeInfo(
"error",
"You are banned from FAF until 2026-05-10T22:00:00+00:00. Reason: test",
"login.error.banned",
listOf("2026-05-10T22:00:00+00:00", "test"),
OffsetDateTime.parse("2026-05-10T22:00:00+00:00")
),
result
)
}

@Test
fun deserializeGameJoinFailed() {
val result = objectMapper.readValue<ServerMessage>(
Expand Down