move locks and bans to state.

This commit is contained in:
Miroslav Šedivý 2022-09-13 20:04:43 +02:00
parent 06e25df962
commit e045bd8a1e
6 changed files with 88 additions and 33 deletions

View file

@ -34,8 +34,7 @@ func (h *MessageHandler) controlRequest(id string, session types.Session) error
// check for host
if !h.sessions.HasHost() {
// check if control is locked or user is admin
_, ok := h.Locked["control"]
if ok && !session.Admin() {
if h.state.IsLocked("control") && !session.Admin() {
h.logger.Debug().Msg("control is locked")
return nil
}
@ -98,8 +97,7 @@ func (h *MessageHandler) controlGive(id string, session types.Session, payload *
}
// check if control is locked or giver is admin
_, ok := h.Locked["control"]
if ok && !session.Admin() {
if h.state.IsLocked("control") && !session.Admin() {
h.logger.Debug().Msg("control is locked")
return nil
}