diff --git a/client.go b/client.go index 9873306..686d5a5 100644 --- a/client.go +++ b/client.go @@ -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 } diff --git a/disk.go b/disk.go index e5d0dc0..f9a8db6 100644 --- a/disk.go +++ b/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 } diff --git a/group.go b/group.go index ecd89e8..1f09106 100644 --- a/group.go +++ b/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") } diff --git a/webclient.go b/webclient.go index 6a0c1d0..5d8dbd6 100644 --- a/webclient.go +++ b/webclient.go @@ -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"`