mirror of
https://github.com/jech/galene.git
synced 2024-12-22 23:35:46 +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()
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue