Archived
2
0

change dissconnect messages to keys for i18n

This commit is contained in:
Craig 2020-04-18 20:57:28 +00:00
parent a04ac47812
commit 5da903f3fe
4 changed files with 15 additions and 12 deletions

View File

@ -2,6 +2,7 @@ package broadcast
import ( import (
"github.com/rs/zerolog" "github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"n.eko.moe/neko/internal/gst" "n.eko.moe/neko/internal/gst"
"n.eko.moe/neko/internal/types/config" "n.eko.moe/neko/internal/types/config"
) )
@ -15,7 +16,7 @@ type BroadcastManager struct {
func New(config *config.Broadcast) *BroadcastManager { func New(config *config.Broadcast) *BroadcastManager {
return &BroadcastManager{ return &BroadcastManager{
logger: log.With().Str("module", "remote").Logger(), logger: log.With().Str("module", "remote").Logger(),
config: config config: config,
} }
} }
@ -34,7 +35,9 @@ func (manager *BroadcastManager) Start() {
} }
func (manager *BroadcastManager) Shutdown() error { func (manager *BroadcastManager) Shutdown() error {
if (manager.pipeline != nil) { if manager.pipeline != nil {
manager.pipeline.Stop() manager.pipeline.Stop()
} }
return nil
} }

View File

@ -230,7 +230,7 @@ func (h *MessageHandler) adminKick(id string, session types.Session, payload *me
return nil return nil
} }
if err := target.Kick("You have been kicked"); err != nil { if err := target.Kick("kicked"); err != nil {
return err return err
} }
@ -280,7 +280,7 @@ func (h *MessageHandler) adminBan(id string, session types.Session, payload *mes
h.banned[address[0]] = true h.banned[address[0]] = true
if err := target.Kick("You have been banned"); err != nil { if err := target.Kick("banned"); err != nil {
return err return err
} }

View File

@ -29,7 +29,7 @@ func (h *MessageHandler) Connected(id string, socket *WebSocket) (bool, string,
ok, banned := h.banned[address] ok, banned := h.banned[address]
if ok && banned { if ok && banned {
h.logger.Debug().Str("address", address).Msg("banned") h.logger.Debug().Str("address", address).Msg("banned")
return false, "This IP has been banned", nil return false, "banned", nil
} }
} }
@ -37,7 +37,7 @@ func (h *MessageHandler) Connected(id string, socket *WebSocket) (bool, string,
session, ok := h.sessions.Get(id) session, ok := h.sessions.Get(id)
if !ok || !session.Admin() { if !ok || !session.Admin() {
h.logger.Debug().Msg("server locked") h.logger.Debug().Msg("server locked")
return false, "Server is currently locked", nil return false, "locked", nil
} }
} }

View File

@ -131,7 +131,7 @@ func (ws *WebSocketHandler) Upgrade(w http.ResponseWriter, r *http.Request) erro
if err = connection.WriteJSON(message.Disconnect{ if err = connection.WriteJSON(message.Disconnect{
Event: event.SYSTEM_DISCONNECT, Event: event.SYSTEM_DISCONNECT,
Message: "invalid password", Message: "invalid_password",
}); err != nil { }); err != nil {
ws.logger.Error().Err(err).Msg("failed to send disconnect") ws.logger.Error().Err(err).Msg("failed to send disconnect")
} }