Feat: add password for player
This commit is contained in:
@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"gralias/broker"
|
||||
"gralias/models"
|
||||
"gralias/repos"
|
||||
"log/slog"
|
||||
"time"
|
||||
@ -61,7 +63,6 @@ func (cm *CronManager) CleanupRooms() {
|
||||
cm.log.Error("failed to get players for room", "room_id", room.ID, "err", err)
|
||||
continue
|
||||
}
|
||||
|
||||
if len(players) == 0 {
|
||||
cm.log.Info("deleting empty room", "room_id", room.ID)
|
||||
if err := cm.repo.RoomDeleteByID(ctx, room.ID); err != nil {
|
||||
@ -72,7 +73,6 @@ func (cm *CronManager) CleanupRooms() {
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
creatorInRoom := false
|
||||
for _, player := range players {
|
||||
if player.Username == room.CreatorName {
|
||||
@ -80,7 +80,6 @@ func (cm *CronManager) CleanupRooms() {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
isInactive := false
|
||||
// If the creator is in the room and the room is more than one hour old, check for inactivity
|
||||
if creatorInRoom && time.Since(room.CreatedAt) > time.Hour {
|
||||
@ -104,7 +103,6 @@ func (cm *CronManager) CleanupRooms() {
|
||||
reason = "inactive"
|
||||
}
|
||||
cm.log.Info("deleting room", "room_id", room.ID, "reason", reason)
|
||||
|
||||
for _, player := range players {
|
||||
if player.IsBot {
|
||||
if err := cm.repo.PlayerDelete(ctx, room.ID); err != nil {
|
||||
@ -116,14 +114,12 @@ func (cm *CronManager) CleanupRooms() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := cm.repo.RoomDeleteByID(ctx, room.ID); err != nil {
|
||||
cm.log.Error("failed to delete room", "room_id", room.ID, "reason", reason, "err", err)
|
||||
}
|
||||
if err := cm.repo.SettingsDeleteByRoomID(ctx, room.ID); err != nil {
|
||||
cm.log.Error("failed to delete settings for room", "room_id", room.ID, "reason", reason, "err", err)
|
||||
}
|
||||
|
||||
// Move to the next room
|
||||
continue
|
||||
}
|
||||
@ -131,6 +127,10 @@ func (cm *CronManager) CleanupRooms() {
|
||||
if err := tx.Commit(); err != nil {
|
||||
cm.log.Error("failed to commit transaction", "err", err)
|
||||
}
|
||||
broker.Notifier.Notifier <- broker.NotificationEvent{
|
||||
EventName: models.NotifyRoomListUpdate,
|
||||
Payload: "",
|
||||
}
|
||||
}
|
||||
|
||||
func (cm *CronManager) CleanupActions() {
|
||||
|
Reference in New Issue
Block a user