mirror of
https://github.com/m1k1o/neko.git
synced 2025-07-21 02:27:55 +02:00
move locks and bans to state.
This commit is contained in:
parent
06e25df962
commit
e045bd8a1e
6 changed files with 88 additions and 33 deletions
|
@ -14,8 +14,7 @@ func (h *MessageHandler) adminLock(id string, session types.Session, payload *me
|
|||
return nil
|
||||
}
|
||||
|
||||
_, ok := h.Locked[payload.Resource]
|
||||
if ok {
|
||||
if h.state.IsLocked(payload.Resource) {
|
||||
h.logger.Debug().Str("resource", payload.Resource).Msg("resource already locked...")
|
||||
return nil
|
||||
}
|
||||
|
@ -30,7 +29,7 @@ func (h *MessageHandler) adminLock(id string, session types.Session, payload *me
|
|||
h.sessions.SetControlLocked(true)
|
||||
}
|
||||
|
||||
h.Locked[payload.Resource] = id
|
||||
h.state.Lock(payload.Resource, id)
|
||||
|
||||
if err := h.sessions.Broadcast(
|
||||
message.AdminLock{
|
||||
|
@ -51,8 +50,7 @@ func (h *MessageHandler) adminUnlock(id string, session types.Session, payload *
|
|||
return nil
|
||||
}
|
||||
|
||||
_, ok := h.Locked[payload.Resource]
|
||||
if !ok {
|
||||
if !h.state.IsLocked(payload.Resource) {
|
||||
h.logger.Debug().Str("resource", payload.Resource).Msg("resource not locked...")
|
||||
return nil
|
||||
}
|
||||
|
@ -62,7 +60,7 @@ func (h *MessageHandler) adminUnlock(id string, session types.Session, payload *
|
|||
h.sessions.SetControlLocked(false)
|
||||
}
|
||||
|
||||
delete(h.Locked, payload.Resource)
|
||||
h.state.Unlock(payload.Resource)
|
||||
|
||||
if err := h.sessions.Broadcast(
|
||||
message.AdminLock{
|
||||
|
@ -302,7 +300,7 @@ func (h *MessageHandler) adminBan(id string, session types.Session, payload *mes
|
|||
}
|
||||
|
||||
h.logger.Debug().Str("address", remote).Msg("adding address to banned")
|
||||
h.Banned[address[0]] = id
|
||||
h.state.Ban(address[0], id)
|
||||
|
||||
if err := target.Kick("banned"); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue