Skip to content

Commit bfe7b75

Browse files
committed
Fix bug with AIs creating a new entry in the database on startup
1 parent bb866f2 commit bfe7b75

File tree

1 file changed

+3
-1
lines changed
  • games-server/src/main/kotlin/net/zomis/games/server2/db

1 file changed

+3
-1
lines changed

games-server/src/main/kotlin/net/zomis/games/server2/db/SuperTable.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ class SuperTable(private val dynamoDB: AmazonDynamoDB) {
246246
val provider = event.provider
247247
val providerId = event.loginName
248248
val skValue = Prefix.OAUTH.sk("$provider/$providerId")
249-
val existing = this.gsiLookup(QuerySpec().withHashKey(this.sk, skValue)).singleOrNull()
249+
val existing = this.gsiLookup(QuerySpec().withHashKey(this.sk, skValue)).firstOrNull()
250+
// TODO: Cleanup database and change to singleOrNull()
250251

251252
val timestamp = Instant.now().epochSecond
252253

@@ -256,6 +257,7 @@ class SuperTable(private val dynamoDB: AmazonDynamoDB) {
256257
val pkValue = Prefix.PLAYER.sk(uuid)
257258
event.client.updateInfo(event.loginName, UUID.fromString(uuid))
258259
if (event.provider == ServerAIProvider) {
260+
logger.info { "AI Logged in: ${event.loginName} using id from database $uuid. Skipping timestamp update" }
259261
// Server AI times should be updated when the AI is used, not when starting the server
260262
return
261263
}

0 commit comments

Comments
 (0)