mirror of
https://github.com/jech/galene.git
synced 2024-11-23 00:55:58 +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"`
|
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 {
|
type client interface {
|
||||||
Group() *group
|
Group() *group
|
||||||
Id() string
|
Id() string
|
||||||
Credentials() clientCredentials
|
Credentials() clientCredentials
|
||||||
|
SetPermissions(clientPermissions)
|
||||||
pushConn(id string, conn upConnection, tracks []upTrack, label string) error
|
pushConn(id string, conn upConnection, tracks []upTrack, label string) error
|
||||||
pushClient(id, username string, add bool) 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", ""}
|
return clientCredentials{"RECORDING", ""}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (client *diskClient) SetPermissions(perms clientPermissions) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (client *diskClient) pushClient(id, username string, add bool) error {
|
func (client *diskClient) pushClient(id, username string, add bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
16
group.go
16
group.go
|
@ -190,10 +190,8 @@ func addClient(name string, c client) (*group, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
w, ok := c.(*webClient)
|
|
||||||
if ok {
|
c.SetPermissions(perms)
|
||||||
w.permissions = perms
|
|
||||||
}
|
|
||||||
|
|
||||||
if !perms.Op && atomic.LoadUint32(&g.locked) != 0 {
|
if !perms.Op && atomic.LoadUint32(&g.locked) != 0 {
|
||||||
return nil, userError("group is locked")
|
return nil, userError("group is locked")
|
||||||
|
@ -396,14 +394,8 @@ func getDescription(name string) (*groupDescription, error) {
|
||||||
return &desc, nil
|
return &desc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientPermission struct {
|
func getPermission(desc *groupDescription, creds clientCredentials) (clientPermissions, error) {
|
||||||
Op bool `json:"op,omitempty"`
|
var p clientPermissions
|
||||||
Present bool `json:"present,omitempty"`
|
|
||||||
Record bool `json:"record,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func getPermission(desc *groupDescription, creds clientCredentials) (clientPermission, error) {
|
|
||||||
var p clientPermission
|
|
||||||
if !desc.AllowAnonymous && creds.Username == "" {
|
if !desc.AllowAnonymous && creds.Username == "" {
|
||||||
return p, userError("anonymous users not allowed in this group, please choose a username")
|
return p, userError("anonymous users not allowed in this group, please choose a username")
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ type webClient struct {
|
||||||
group *group
|
group *group
|
||||||
id string
|
id string
|
||||||
credentials clientCredentials
|
credentials clientCredentials
|
||||||
permissions clientPermission
|
permissions clientPermissions
|
||||||
requested map[string]uint32
|
requested map[string]uint32
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
writeCh chan interface{}
|
writeCh chan interface{}
|
||||||
|
@ -111,6 +111,10 @@ func (c *webClient) Credentials() clientCredentials {
|
||||||
return c.credentials
|
return c.credentials
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *webClient) SetPermissions(perms clientPermissions) {
|
||||||
|
c.permissions = perms
|
||||||
|
}
|
||||||
|
|
||||||
func (c *webClient) pushClient(id, username string, add bool) error {
|
func (c *webClient) pushClient(id, username string, add bool) error {
|
||||||
kind := "add"
|
kind := "add"
|
||||||
if !add {
|
if !add {
|
||||||
|
@ -177,7 +181,7 @@ type clientMessage struct {
|
||||||
Id string `json:"id,omitempty"`
|
Id string `json:"id,omitempty"`
|
||||||
Username string `json:"username,omitempty"`
|
Username string `json:"username,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
Permissions clientPermission `json:"permissions,omitempty"`
|
Permissions clientPermissions `json:"permissions,omitempty"`
|
||||||
Group string `json:"group,omitempty"`
|
Group string `json:"group,omitempty"`
|
||||||
Value string `json:"value,omitempty"`
|
Value string `json:"value,omitempty"`
|
||||||
Offer *webrtc.SessionDescription `json:"offer,omitempty"`
|
Offer *webrtc.SessionDescription `json:"offer,omitempty"`
|
||||||
|
|
Loading…
Reference in a new issue