mirror of
https://github.com/jech/galene.git
synced 2024-11-10 02:35:58 +01:00
Remove accessors for group description fields.
Consult the description directly.
This commit is contained in:
parent
06ee4cc30f
commit
019f365981
4 changed files with 10 additions and 39 deletions
|
@ -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()
|
g.mu.Lock()
|
||||||
defer g.mu.Unlock()
|
defer g.mu.Unlock()
|
||||||
return g.description.Public
|
return g.description
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) EmptyTime() time.Duration {
|
func (g *Group) EmptyTime() time.Duration {
|
||||||
|
@ -1021,12 +1003,13 @@ type Public struct {
|
||||||
func GetPublic() []Public {
|
func GetPublic() []Public {
|
||||||
gs := make([]Public, 0)
|
gs := make([]Public, 0)
|
||||||
Range(func(g *Group) bool {
|
Range(func(g *Group) bool {
|
||||||
if g.Public() {
|
desc := g.Description()
|
||||||
|
if desc.Public {
|
||||||
locked, _ := g.Locked()
|
locked, _ := g.Locked()
|
||||||
gs = append(gs, Public{
|
gs = append(gs, Public{
|
||||||
Name: g.name,
|
Name: g.name,
|
||||||
DisplayName: g.DisplayName(),
|
DisplayName: desc.DisplayName,
|
||||||
Description: g.description.Description,
|
Description: desc.Description,
|
||||||
Locked: locked,
|
Locked: locked,
|
||||||
ClientCount: len(g.clients),
|
ClientCount: len(g.clients),
|
||||||
})
|
})
|
||||||
|
|
|
@ -29,18 +29,6 @@ func TestGroup(t *testing.T) {
|
||||||
if locked, _ := g.Locked(); locked {
|
if locked, _ := g.Locked(); locked {
|
||||||
t.Errorf("Locked: expected false, got %v", 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()
|
api, err := g.API()
|
||||||
if err != nil || api == nil {
|
if err != nil || api == nil {
|
||||||
t.Errorf("Couldn't get API: %v", err)
|
t.Errorf("Couldn't get API: %v", err)
|
||||||
|
|
|
@ -822,7 +822,7 @@ func getGroupStatus(g *group.Group) map[string]interface{} {
|
||||||
status["locked"] = message
|
status["locked"] = message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if dn := g.DisplayName(); dn != "" {
|
if dn := g.Description().DisplayName; dn != "" {
|
||||||
status["displayName"] = dn
|
status["displayName"] = dn
|
||||||
}
|
}
|
||||||
return status
|
return status
|
||||||
|
@ -1265,7 +1265,7 @@ func setPermissions(g *group.Group, id string, perm string) error {
|
||||||
switch perm {
|
switch perm {
|
||||||
case "op":
|
case "op":
|
||||||
c.permissions.Op = true
|
c.permissions.Op = true
|
||||||
if g.AllowRecording() {
|
if g.Description().AllowRecording {
|
||||||
c.permissions.Record = true
|
c.permissions.Record = true
|
||||||
}
|
}
|
||||||
case "unop":
|
case "unop":
|
||||||
|
@ -1360,7 +1360,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
Value: s,
|
Value: s,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if redirect := g.Redirect(); redirect != "" {
|
if redirect := g.Description().Redirect; redirect != "" {
|
||||||
// We normally redirect at the HTTP level, but the group
|
// We normally redirect at the HTTP level, but the group
|
||||||
// description could have been edited in the meantime.
|
// description could have been edited in the meantime.
|
||||||
return c.write(clientMessage{
|
return c.write(clientMessage{
|
||||||
|
|
|
@ -305,7 +305,7 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if redirect := g.Redirect(); redirect != "" {
|
if redirect := g.Description().Redirect; redirect != "" {
|
||||||
http.Redirect(w, r, redirect, http.StatusPermanentRedirect)
|
http.Redirect(w, r, redirect, http.StatusPermanentRedirect)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue