add ADMIN_CONTROL.

This commit is contained in:
Miroslav Šedivý 2024-07-21 00:33:04 +02:00
parent 4457df94a3
commit c0e5804b3b

View File

@ -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,
}) })
*/ */