Commit 019f3659 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Remove accessors for group description fields.

Consult the description directly.
parent 06ee4cc3
......@@ -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),
})
......
......@@ -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)
......
......@@ -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{
......
......@@ -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
}
......
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