mirror of
https://github.com/jech/galene.git
synced 2024-11-28 19:45:58 +01:00
Implement group description.
This commit is contained in:
parent
7183730a68
commit
8399ee2c4a
3 changed files with 18 additions and 9 deletions
2
README
2
README
|
@ -99,6 +99,8 @@ fields, all of which are optional.
|
|||
respectively with operator privileges, with presenter privileges, and
|
||||
as passive listeners;
|
||||
- `public`: if true, then the group is visible on the landing page;
|
||||
- `description`: a human-readable description of the group; this is
|
||||
displayed on the landing page for public groups;
|
||||
- `max-clients`: the maximum number of clients that may join the group at
|
||||
a time;
|
||||
- `allow-recording`: if true, then recording is allowed in this group;
|
||||
|
|
|
@ -75,7 +75,7 @@ type Group struct {
|
|||
name string
|
||||
|
||||
mu sync.Mutex
|
||||
description *groupDescription
|
||||
description *description
|
||||
// indicates that the group no longer exists, but it still has clients
|
||||
dead bool
|
||||
locked *string
|
||||
|
@ -90,7 +90,7 @@ func (g *Group) Name() string {
|
|||
func (g *Group) Locked() (bool, string) {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
if(g.locked != nil) {
|
||||
if g.locked != nil {
|
||||
return true, *g.locked
|
||||
} else {
|
||||
return false, ""
|
||||
|
@ -135,7 +135,7 @@ func (g *Group) API() *webrtc.API {
|
|||
return groups.api
|
||||
}
|
||||
|
||||
func Add(name string, desc *groupDescription) (*Group, error) {
|
||||
func Add(name string, desc *description) (*Group, error) {
|
||||
groups.mu.Lock()
|
||||
defer groups.mu.Unlock()
|
||||
|
||||
|
@ -429,10 +429,11 @@ func matchUser(user ClientCredentials, users []ClientCredentials) (bool, bool) {
|
|||
return false, false
|
||||
}
|
||||
|
||||
type groupDescription struct {
|
||||
type description struct {
|
||||
loadTime time.Time `json:"-"`
|
||||
modTime time.Time `json:"-"`
|
||||
fileSize int64 `json:"-"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Redirect string `json:"redirect,omitempty"`
|
||||
Public bool `json:"public,omitempty"`
|
||||
MaxClients int `json:"max-clients,omitempty"`
|
||||
|
@ -443,7 +444,7 @@ type groupDescription struct {
|
|||
Other []ClientCredentials `json:"other,omitempty"`
|
||||
}
|
||||
|
||||
func descriptionChanged(name string, old *groupDescription) (bool, error) {
|
||||
func descriptionChanged(name string, old *description) (bool, error) {
|
||||
fi, err := os.Stat(filepath.Join(Directory, name+".json"))
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
@ -454,14 +455,14 @@ func descriptionChanged(name string, old *groupDescription) (bool, error) {
|
|||
return false, err
|
||||
}
|
||||
|
||||
func GetDescription(name string) (*groupDescription, error) {
|
||||
func GetDescription(name string) (*description, error) {
|
||||
r, err := os.Open(filepath.Join(Directory, name+".json"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer r.Close()
|
||||
|
||||
var desc groupDescription
|
||||
var desc description
|
||||
|
||||
fi, err := r.Stat()
|
||||
if err != nil {
|
||||
|
@ -479,7 +480,7 @@ func GetDescription(name string) (*groupDescription, error) {
|
|||
return &desc, nil
|
||||
}
|
||||
|
||||
func (desc *groupDescription) GetPermission (creds ClientCredentials) (ClientPermissions, error) {
|
||||
func (desc *description) GetPermission(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")
|
||||
|
@ -513,6 +514,7 @@ func (desc *groupDescription) GetPermission (creds ClientCredentials) (ClientPer
|
|||
|
||||
type Public struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ClientCount int `json:"clientCount"`
|
||||
}
|
||||
|
||||
|
@ -522,6 +524,7 @@ func GetPublic() []Public {
|
|||
if g.Public() {
|
||||
gs = append(gs, Public{
|
||||
Name: g.name,
|
||||
Description: g.description.Description,
|
||||
ClientCount: len(g.clients),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -44,8 +44,12 @@ async function listPublicGroups() {
|
|||
td.appendChild(a);
|
||||
tr.appendChild(td);
|
||||
let td2 = document.createElement('td');
|
||||
td2.textContent = `(${group.clientCount} clients)`;
|
||||
if(group.description)
|
||||
td2.textContent = group.description;
|
||||
tr.appendChild(td2);
|
||||
let td3 = document.createElement('td');
|
||||
td3.textContent = `(${group.clientCount} clients)`;
|
||||
tr.appendChild(td3);
|
||||
table.appendChild(tr);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue