diff --git a/group/group.go b/group/group.go index 831b2fd..69e0c4f 100644 --- a/group/group.go +++ b/group/group.go @@ -106,28 +106,10 @@ func (g *Group) SetLocked(locked bool, message string) { } } -func (g *Group) Public() bool { +func (g *Group) Description() *Description { g.mu.Lock() defer g.mu.Unlock() - return g.description.Public -} - -func (g *Group) Redirect() string { - g.mu.Lock() - defer g.mu.Unlock() - return g.description.Redirect -} - -func (g *Group) AllowRecording() bool { - g.mu.Lock() - defer g.mu.Unlock() - return g.description.AllowRecording -} - -func (g *Group) DisplayName() string { - g.mu.Lock() - defer g.mu.Unlock() - return g.description.DisplayName + return g.description } func (g *Group) EmptyTime() time.Duration { @@ -1021,12 +1003,13 @@ type Public struct { func GetPublic() []Public { gs := make([]Public, 0) Range(func(g *Group) bool { - if g.Public() { + desc := g.Description() + if desc.Public { locked, _ := g.Locked() gs = append(gs, Public{ Name: g.name, - DisplayName: g.DisplayName(), - Description: g.description.Description, + DisplayName: desc.DisplayName, + Description: desc.Description, Locked: locked, ClientCount: len(g.clients), }) diff --git a/group/group_test.go b/group/group_test.go index 4873bcb..4bba819 100644 --- a/group/group_test.go +++ b/group/group_test.go @@ -29,18 +29,6 @@ func TestGroup(t *testing.T) { if locked, _ := g.Locked(); locked { t.Errorf("Locked: expected false, got %v", locked) } - if public := g.Public(); public { - t.Errorf("Public: expected false, got %v", public) - } - if public := g2.Public(); !public { - t.Errorf("Public: expected true, got %v", public) - } - if redirect := g.Redirect(); redirect != "" { - t.Errorf("Redirect: expected empty, got %v", redirect) - } - if ar := g.AllowRecording(); ar { - t.Errorf("Allow Recording: expected false, got %v", ar) - } api, err := g.API() if err != nil || api == nil { t.Errorf("Couldn't get API: %v", err) diff --git a/rtpconn/webclient.go b/rtpconn/webclient.go index b7e22cd..5d7480a 100644 --- a/rtpconn/webclient.go +++ b/rtpconn/webclient.go @@ -822,7 +822,7 @@ func getGroupStatus(g *group.Group) map[string]interface{} { status["locked"] = message } } - if dn := g.DisplayName(); dn != "" { + if dn := g.Description().DisplayName; dn != "" { status["displayName"] = dn } return status @@ -1265,7 +1265,7 @@ func setPermissions(g *group.Group, id string, perm string) error { switch perm { case "op": c.permissions.Op = true - if g.AllowRecording() { + if g.Description().AllowRecording { c.permissions.Record = true } case "unop": @@ -1360,7 +1360,7 @@ func handleClientMessage(c *webClient, m clientMessage) error { Value: s, }) } - if redirect := g.Redirect(); redirect != "" { + if redirect := g.Description().Redirect; redirect != "" { // We normally redirect at the HTTP level, but the group // description could have been edited in the meantime. return c.write(clientMessage{ diff --git a/webserver/webserver.go b/webserver/webserver.go index a263010..187fc03 100644 --- a/webserver/webserver.go +++ b/webserver/webserver.go @@ -305,7 +305,7 @@ func groupHandler(w http.ResponseWriter, r *http.Request) { return } - if redirect := g.Redirect(); redirect != "" { + if redirect := g.Description().Redirect; redirect != "" { http.Redirect(w, r, redirect, http.StatusPermanentRedirect) return }