mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add ADMIN_CONTROL.
This commit is contained in:
parent
4457df94a3
commit
c0e5804b3b
@ -38,14 +38,24 @@ func sessionDataToMember(id string, session message.SessionData) (*oldTypes.Memb
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) sendControlHost(request message.ControlHost, send func(payload any) error) error {
|
func (s *session) sendControlHost(request message.ControlHost, send func(payload any) error) error {
|
||||||
|
lastHostID := s.lastHostID
|
||||||
|
|
||||||
if request.HasHost {
|
if request.HasHost {
|
||||||
s.lastHostID = request.ID
|
s.lastHostID = request.ID
|
||||||
|
|
||||||
if request.ID == request.HostID {
|
if request.ID == request.HostID {
|
||||||
return send(&oldMessage.Control{
|
if request.ID == lastHostID || lastHostID == "" {
|
||||||
Event: oldEvent.CONTROL_LOCKED,
|
return send(&oldMessage.Control{
|
||||||
ID: request.HostID,
|
Event: oldEvent.CONTROL_LOCKED,
|
||||||
})
|
ID: request.HostID,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return send(&oldMessage.AdminTarget{
|
||||||
|
Event: oldEvent.ADMIN_CONTROL,
|
||||||
|
ID: request.ID,
|
||||||
|
Target: lastHostID,
|
||||||
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return send(&oldMessage.ControlTarget{
|
return send(&oldMessage.ControlTarget{
|
||||||
Event: oldEvent.CONTROL_GIVE,
|
Event: oldEvent.CONTROL_GIVE,
|
||||||
@ -56,7 +66,9 @@ func (s *session) sendControlHost(request message.ControlHost, send func(payload
|
|||||||
}
|
}
|
||||||
|
|
||||||
if request.ID != "" {
|
if request.ID != "" {
|
||||||
if request.ID == s.lastHostID {
|
s.lastHostID = ""
|
||||||
|
|
||||||
|
if request.ID == lastHostID {
|
||||||
return send(&oldMessage.Control{
|
return send(&oldMessage.Control{
|
||||||
Event: oldEvent.CONTROL_RELEASE,
|
Event: oldEvent.CONTROL_RELEASE,
|
||||||
ID: request.ID,
|
ID: request.ID,
|
||||||
@ -530,29 +542,17 @@ func (s *session) wsToClient(msg []byte, sendMsg func([]byte) error) error {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
// Admin Events
|
// Admin Events
|
||||||
case:
|
|
||||||
send(&oldMessage.AdminLock{
|
|
||||||
Event: oldEvent.ADMIN_UNLOCK,
|
|
||||||
})
|
|
||||||
case:
|
case:
|
||||||
send(&oldMessage.AdminLock{
|
send(&oldMessage.AdminLock{
|
||||||
Event: oldEvent.ADMIN_LOCK,
|
Event: oldEvent.ADMIN_LOCK,
|
||||||
})
|
})
|
||||||
case:
|
case:
|
||||||
send(&oldMessage.AdminTarget{
|
send(&oldMessage.AdminLock{
|
||||||
Event: oldEvent.ADMIN_CONTROL,
|
Event: oldEvent.ADMIN_UNLOCK,
|
||||||
} // )oldMessage.Admin
|
|
||||||
case:
|
|
||||||
send(&oldMessage.AdminTarget{
|
|
||||||
Event: oldEvent.ADMIN_RELEASE,
|
|
||||||
} // )oldMessage.Admin
|
|
||||||
case:
|
|
||||||
send(&oldMessage.AdminTarget{
|
|
||||||
Event: oldEvent.ADMIN_MUTE,
|
|
||||||
})
|
})
|
||||||
case:
|
case:
|
||||||
send(&oldMessage.AdminTarget{
|
send(&oldMessage.AdminTarget{
|
||||||
Event: oldEvent.ADMIN_UNMUTE,
|
Event: oldEvent.ADMIN_BAN,
|
||||||
})
|
})
|
||||||
case:
|
case:
|
||||||
send(&oldMessage.AdminTarget{
|
send(&oldMessage.AdminTarget{
|
||||||
@ -560,7 +560,11 @@ func (s *session) wsToClient(msg []byte, sendMsg func([]byte) error) error {
|
|||||||
})
|
})
|
||||||
case:
|
case:
|
||||||
send(&oldMessage.AdminTarget{
|
send(&oldMessage.AdminTarget{
|
||||||
Event: oldEvent.ADMIN_BAN,
|
Event: oldEvent.ADMIN_MUTE,
|
||||||
|
})
|
||||||
|
case:
|
||||||
|
send(&oldMessage.AdminTarget{
|
||||||
|
Event: oldEvent.ADMIN_UNMUTE,
|
||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user