mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
SetProfile changed as Update.
This commit is contained in:
parent
22407825fe
commit
a6fbafc079
@ -84,7 +84,7 @@ func (h *MembersHandler) membersUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// TODO: Join structs?
|
// TODO: Join structs?
|
||||||
// TODO: Update independent props.
|
// TODO: Update independent props.
|
||||||
member.SetProfile(types.MemberProfile{
|
if err := h.sessions.Update(member.ID(), types.MemberProfile{
|
||||||
Secret: data.Secret,
|
Secret: data.Secret,
|
||||||
Name: data.Name,
|
Name: data.Name,
|
||||||
IsAdmin: data.IsAdmin,
|
IsAdmin: data.IsAdmin,
|
||||||
@ -93,7 +93,10 @@ func (h *MembersHandler) membersUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
CanWatch: data.CanWatch,
|
CanWatch: data.CanWatch,
|
||||||
CanHost: data.CanHost,
|
CanHost: data.CanHost,
|
||||||
CanAccessClipboard: data.CanAccessClipboard,
|
CanAccessClipboard: data.CanAccessClipboard,
|
||||||
})
|
}); err != nil {
|
||||||
|
utils.HttpInternalServerError(w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
utils.HttpSuccess(w)
|
utils.HttpSuccess(w)
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,21 @@ func (manager *SessionManagerCtx) Create(id string, profile types.MemberProfile)
|
|||||||
return session
|
return session
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (manager *SessionManagerCtx) Update(id string, profile types.MemberProfile) error {
|
||||||
|
manager.membersMu.Lock()
|
||||||
|
session, ok := manager.members[id]
|
||||||
|
if !ok {
|
||||||
|
manager.membersMu.Unlock()
|
||||||
|
return fmt.Errorf("Member not found.")
|
||||||
|
}
|
||||||
|
|
||||||
|
session.profile = profile
|
||||||
|
manager.membersMu.Unlock()
|
||||||
|
|
||||||
|
manager.emmiter.Emit("profile_changed", session)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (manager *SessionManagerCtx) Get(id string) (types.Session, bool) {
|
func (manager *SessionManagerCtx) Get(id string) (types.Session, bool) {
|
||||||
manager.membersMu.Lock()
|
manager.membersMu.Lock()
|
||||||
session, ok := manager.members[id]
|
session, ok := manager.members[id]
|
||||||
|
@ -59,11 +59,6 @@ func (session *SessionCtx) CanAccessClipboard() bool {
|
|||||||
return session.profile.CanAccessClipboard
|
return session.profile.CanAccessClipboard
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) SetProfile(profile types.MemberProfile) {
|
|
||||||
session.profile = profile
|
|
||||||
session.manager.emmiter.Emit("profile_changed", session)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
// runtime
|
// runtime
|
||||||
// ---
|
// ---
|
||||||
|
@ -25,7 +25,6 @@ type Session interface {
|
|||||||
CanWatch() bool
|
CanWatch() bool
|
||||||
CanHost() bool
|
CanHost() bool
|
||||||
CanAccessClipboard() bool
|
CanAccessClipboard() bool
|
||||||
SetProfile(profile MemberProfile)
|
|
||||||
|
|
||||||
IsHost() bool
|
IsHost() bool
|
||||||
IsConnected() bool
|
IsConnected() bool
|
||||||
@ -43,6 +42,7 @@ type Session interface {
|
|||||||
|
|
||||||
type SessionManager interface {
|
type SessionManager interface {
|
||||||
Create(id string, profile MemberProfile) Session
|
Create(id string, profile MemberProfile) Session
|
||||||
|
Update(id string, profile MemberProfile) error
|
||||||
Get(id string) (Session, bool)
|
Get(id string) (Session, bool)
|
||||||
Delete(id string) error
|
Delete(id string) error
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user