mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Make SetPermissions part of the client interface.
This commit is contained in:
parent
0064aa6fd2
commit
78e9c96a53
4 changed files with 21 additions and 14 deletions
|
@ -5,10 +5,17 @@ type clientCredentials struct {
|
|||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
|
||||
type clientPermissions struct {
|
||||
Op bool `json:"op,omitempty"`
|
||||
Present bool `json:"present,omitempty"`
|
||||
Record bool `json:"record,omitempty"`
|
||||
}
|
||||
|
||||
type client interface {
|
||||
Group() *group
|
||||
Id() string
|
||||
Credentials() clientCredentials
|
||||
SetPermissions(clientPermissions)
|
||||
pushConn(id string, conn upConnection, tracks []upTrack, label string) error
|
||||
pushClient(id, username string, add bool) error
|
||||
}
|
||||
|
|
4
disk.go
4
disk.go
|
@ -36,6 +36,10 @@ func (client *diskClient) Credentials() clientCredentials {
|
|||
return clientCredentials{"RECORDING", ""}
|
||||
}
|
||||
|
||||
func (client *diskClient) SetPermissions(perms clientPermissions) {
|
||||
return
|
||||
}
|
||||
|
||||
func (client *diskClient) pushClient(id, username string, add bool) error {
|
||||
return nil
|
||||
}
|
||||
|
|
16
group.go
16
group.go
|
@ -190,10 +190,8 @@ func addClient(name string, c client) (*group, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
w, ok := c.(*webClient)
|
||||
if ok {
|
||||
w.permissions = perms
|
||||
}
|
||||
|
||||
c.SetPermissions(perms)
|
||||
|
||||
if !perms.Op && atomic.LoadUint32(&g.locked) != 0 {
|
||||
return nil, userError("group is locked")
|
||||
|
@ -396,14 +394,8 @@ func getDescription(name string) (*groupDescription, error) {
|
|||
return &desc, nil
|
||||
}
|
||||
|
||||
type clientPermission struct {
|
||||
Op bool `json:"op,omitempty"`
|
||||
Present bool `json:"present,omitempty"`
|
||||
Record bool `json:"record,omitempty"`
|
||||
}
|
||||
|
||||
func getPermission(desc *groupDescription, creds clientCredentials) (clientPermission, error) {
|
||||
var p clientPermission
|
||||
func getPermission(desc *groupDescription, creds clientCredentials) (clientPermissions, error) {
|
||||
var p clientPermissions
|
||||
if !desc.AllowAnonymous && creds.Username == "" {
|
||||
return p, userError("anonymous users not allowed in this group, please choose a username")
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ type webClient struct {
|
|||
group *group
|
||||
id string
|
||||
credentials clientCredentials
|
||||
permissions clientPermission
|
||||
permissions clientPermissions
|
||||
requested map[string]uint32
|
||||
done chan struct{}
|
||||
writeCh chan interface{}
|
||||
|
@ -111,6 +111,10 @@ func (c *webClient) Credentials() clientCredentials {
|
|||
return c.credentials
|
||||
}
|
||||
|
||||
func (c *webClient) SetPermissions(perms clientPermissions) {
|
||||
c.permissions = perms
|
||||
}
|
||||
|
||||
func (c *webClient) pushClient(id, username string, add bool) error {
|
||||
kind := "add"
|
||||
if !add {
|
||||
|
@ -177,7 +181,7 @@ type clientMessage struct {
|
|||
Id string `json:"id,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Permissions clientPermission `json:"permissions,omitempty"`
|
||||
Permissions clientPermissions `json:"permissions,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Value string `json:"value,omitempty"`
|
||||
Offer *webrtc.SessionDescription `json:"offer,omitempty"`
|
||||
|
|
Loading…
Reference in a new issue