mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
remove user kick.
This commit is contained in:
parent
592b2cfd3a
commit
3f312c84ad
@ -38,7 +38,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ADMIN_KICK = "admin/kick"
|
|
||||||
ADMIN_CONTROL = "admin/control"
|
ADMIN_CONTROL = "admin/control"
|
||||||
ADMIN_RELEASE = "admin/release"
|
ADMIN_RELEASE = "admin/release"
|
||||||
ADMIN_GIVE = "admin/give"
|
ADMIN_GIVE = "admin/give"
|
||||||
|
@ -83,34 +83,3 @@ func (h *MessageHandlerCtx) adminGive(session types.Session, payload *message.Ad
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MessageHandlerCtx) adminKick(session types.Session, payload *message.Admin) error {
|
|
||||||
if !session.Admin() {
|
|
||||||
h.logger.Debug().Msg("user not admin")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
target, ok := h.sessions.Get(payload.ID)
|
|
||||||
if !ok {
|
|
||||||
h.logger.Debug().Str("id", payload.ID).Msg("can't find target session")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if target.Admin() {
|
|
||||||
h.logger.Debug().Msg("target is an admin, baling")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := target.Disconnect("kicked"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
h.sessions.Broadcast(
|
|
||||||
message.AdminTarget{
|
|
||||||
Event: event.ADMIN_KICK,
|
|
||||||
Target: target.ID(),
|
|
||||||
ID: session.ID(),
|
|
||||||
}, []string{payload.ID})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -104,11 +104,6 @@ func (h *MessageHandlerCtx) Message(session types.Session, raw []byte) error {
|
|||||||
err = utils.Unmarshal(payload, raw, func() error {
|
err = utils.Unmarshal(payload, raw, func() error {
|
||||||
return h.adminGive(session, payload)
|
return h.adminGive(session, payload)
|
||||||
})
|
})
|
||||||
case event.ADMIN_KICK:
|
|
||||||
payload := &message.Admin{}
|
|
||||||
err = utils.Unmarshal(payload, raw, func() error {
|
|
||||||
return h.adminKick(session, payload)
|
|
||||||
})
|
|
||||||
default:
|
default:
|
||||||
return errors.Errorf("unknown message event %s", header.Event)
|
return errors.Errorf("unknown message event %s", header.Event)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user