mirror of
https://github.com/m1k1o/neko.git
synced 2025-06-14 16:52:47 +02:00
add lock controls for users.
This commit is contained in:
parent
2290c4a065
commit
61fcf7f699
20 changed files with 277 additions and 113 deletions
|
@ -7,7 +7,6 @@ import (
|
|||
)
|
||||
|
||||
func (h *MessageHandler) controlRelease(id string, session types.Session) error {
|
||||
|
||||
// check if session is host
|
||||
if !h.sessions.IsHost(id) {
|
||||
h.logger.Debug().Str("id", id).Msg("is not the host")
|
||||
|
@ -34,6 +33,13 @@ func (h *MessageHandler) controlRelease(id string, session types.Session) error
|
|||
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() {
|
||||
h.logger.Debug().Msg("control is locked")
|
||||
return nil
|
||||
}
|
||||
|
||||
// set host
|
||||
err := h.sessions.SetHost(id)
|
||||
if err != nil {
|
||||
|
@ -91,6 +97,13 @@ func (h *MessageHandler) controlGive(id string, session types.Session, payload *
|
|||
return nil
|
||||
}
|
||||
|
||||
// check if control is locked or giver is admin
|
||||
_, ok := h.locked["control"]
|
||||
if ok && !session.Admin() {
|
||||
h.logger.Debug().Msg("control is locked")
|
||||
return nil
|
||||
}
|
||||
|
||||
// set host
|
||||
err := h.sessions.SetHost(payload.ID)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue