remove unused mute function.

This commit is contained in:
Miroslav Šedivý 2020-11-16 22:10:03 +01:00
parent 99068b893b
commit d87a10b23a
7 changed files with 0 additions and 76 deletions

View File

@ -13,7 +13,6 @@ type SessionCtx struct {
id string id string
name string name string
admin bool admin bool
muted bool
connected bool connected bool
manager *SessionManagerCtx manager *SessionManagerCtx
socket types.WebSocket socket types.WebSocket
@ -32,10 +31,6 @@ func (session *SessionCtx) Admin() bool {
return session.admin return session.admin
} }
func (session *SessionCtx) Muted() bool {
return session.muted
}
func (session *SessionCtx) IsHost() bool { func (session *SessionCtx) IsHost() bool {
return session.manager.host != nil && session.manager.host.ID() == session.ID() return session.manager.host != nil && session.manager.host.ID() == session.ID()
} }
@ -52,10 +47,6 @@ func (session *SessionCtx) Address() string {
return session.socket.Address() return session.socket.Address()
} }
func (session *SessionCtx) SetMuted(muted bool) {
session.muted = muted
}
func (session *SessionCtx) SetName(name string) { func (session *SessionCtx) SetName(name string) {
session.name = name session.name = name
} }

View File

@ -41,9 +41,7 @@ const (
ADMIN_BAN = "admin/ban" ADMIN_BAN = "admin/ban"
ADMIN_KICK = "admin/kick" ADMIN_KICK = "admin/kick"
ADMIN_LOCK = "admin/lock" ADMIN_LOCK = "admin/lock"
ADMIN_MUTE = "admin/mute"
ADMIN_UNLOCK = "admin/unlock" ADMIN_UNLOCK = "admin/unlock"
ADMIN_UNMUTE = "admin/unmute"
ADMIN_CONTROL = "admin/control" ADMIN_CONTROL = "admin/control"
ADMIN_RELEASE = "admin/release" ADMIN_RELEASE = "admin/release"
ADMIN_GIVE = "admin/give" ADMIN_GIVE = "admin/give"

View File

@ -36,7 +36,6 @@ type MembersListEntry struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"displayname"` Name string `json:"displayname"`
Admin bool `json:"admin"` Admin bool `json:"admin"`
Muted bool `json:"muted"`
} }
type Member struct { type Member struct {
@ -44,7 +43,6 @@ type Member struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"displayname"` Name string `json:"displayname"`
Admin bool `json:"admin"` Admin bool `json:"admin"`
Muted bool `json:"muted"`
} }
type MemberDisconnected struct { type MemberDisconnected struct {

View File

@ -6,11 +6,9 @@ type Session interface {
ID() string ID() string
Name() string Name() string
Admin() bool Admin() bool
Muted() bool
IsHost() bool IsHost() bool
Connected() bool Connected() bool
Address() string Address() string
SetMuted(muted bool)
SetName(name string) SetName(name string)
SetSocket(socket WebSocket) SetSocket(socket WebSocket)
SetPeer(peer Peer) SetPeer(peer Peer)

View File

@ -120,55 +120,6 @@ func (h *MessageHandlerCtx) adminGive(session types.Session, payload *message.Ad
}, nil) }, nil)
} }
func (h *MessageHandlerCtx) adminMute(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 session id")
return nil
}
if target.Admin() {
h.logger.Debug().Msg("target is an admin, baling")
return nil
}
target.SetMuted(true)
return h.sessions.Broadcast(
message.AdminTarget{
Event: event.ADMIN_MUTE,
Target: target.ID(),
ID: session.ID(),
}, nil)
}
func (h *MessageHandlerCtx) adminUnmute(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
}
target.SetMuted(false)
return h.sessions.Broadcast(
message.AdminTarget{
Event: event.ADMIN_UNMUTE,
Target: target.ID(),
ID: session.ID(),
}, nil)
}
func (h *MessageHandlerCtx) adminKick(session types.Session, payload *message.Admin) error { func (h *MessageHandlerCtx) adminKick(session types.Session, payload *message.Admin) error {
if !session.Admin() { if !session.Admin() {
h.logger.Debug().Msg("user not admin") h.logger.Debug().Msg("user not admin")

View File

@ -151,16 +151,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.adminKick(session, payload) return h.adminKick(session, payload)
}) })
case event.ADMIN_MUTE:
payload := &message.Admin{}
err = utils.Unmarshal(payload, raw, func() error {
return h.adminMute(session, payload)
})
case event.ADMIN_UNMUTE:
payload := &message.Admin{}
err = utils.Unmarshal(payload, raw, func() error {
return h.adminUnmute(session, payload)
})
default: default:
return errors.Errorf("unknown message event %s", header.Event) return errors.Errorf("unknown message event %s", header.Event)
} }

View File

@ -35,7 +35,6 @@ func (h *MessageHandlerCtx) SessionConnected(session types.Session) error {
ID: session.ID(), ID: session.ID(),
Name: session.Name(), Name: session.Name(),
Admin: session.Admin(), Admin: session.Admin(),
Muted: session.Muted(),
}) })
} }
@ -70,7 +69,6 @@ func (h *MessageHandlerCtx) SessionConnected(session types.Session) error {
ID: session.ID(), ID: session.ID(),
Name: session.Name(), Name: session.Name(),
Admin: session.Admin(), Admin: session.Admin(),
Muted: session.Muted(),
}, nil) }, nil)
} }