Commit 78e9c96a authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Make SetPermissions part of the client interface.

parent 0064aa6f
......@@ -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
}
......
......@@ -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
}
......
......@@ -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"`
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment