Skip to content

Commit

Permalink
feat: add a log message when a user leaves a room
Browse files Browse the repository at this point in the history
  • Loading branch information
sne11ius committed May 31, 2024
1 parent d2232ce commit c808109
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/src/main/kotlin/pp/api/Rooms.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Rooms {
// connection - so we cannot care for any errors here.
}
Log.info("User ${user.username} left room ${room.roomId}")
update(room - session)
update(room - session withInfo "User ${user.username} left")
}
}

Expand Down
8 changes: 3 additions & 5 deletions api/src/main/kotlin/pp/api/data/Room.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ class Room(
*/
operator fun minus(session: Session): Room {
val user = this.findUserWithSession(session)
return user
?.let {
this.copy(users = this.users - user)
}
?: this
return user?.let {
this.copy(users = this.users - user)
} ?: this
}

/**
Expand Down

0 comments on commit c808109

Please sign in to comment.