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 (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"n.eko.moe/neko/internal/gst"
"n.eko.moe/neko/internal/types/config"
)
@ -14,8 +15,8 @@ type BroadcastManager struct {
func New(config *config.Broadcast) *BroadcastManager {
return &BroadcastManager{
logger: log.With().Str("module", "remote").Logger(),
config: config
logger: log.With().Str("module", "remote").Logger(),
config: config,
}
}
@ -28,13 +29,15 @@ func (manager *BroadcastManager) Start() {
)
if err != nil {
manager.logger.Panic().Err(err).Msg("unable to create rtmp pipeline")
}
}
manager.pipeline.Start()
manager.pipeline.Start()
}
func (manager *BroadcastManager) Shutdown() error {
if (manager.pipeline != nil) {
manager.pipeline.Stop()
}
if manager.pipeline != nil {
manager.pipeline.Stop()
}
return nil
}

View File

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

View File

@ -29,7 +29,7 @@ func (h *MessageHandler) Connected(id string, socket *WebSocket) (bool, string,
ok, banned := h.banned[address]
if ok && 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)
if !ok || !session.Admin() {
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{
Event: event.SYSTEM_DISCONNECT,
Message: "invalid password",
Message: "invalid_password",
}); err != nil {
ws.logger.Error().Err(err).Msg("failed to send disconnect")
}