forked from flexd/slackinviter
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
team.go
62 lines (55 loc) · 1.01 KB
/
team.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"log"
"sync"
"github.com/nlopes/slack"
)
// Team information
type team struct {
mu sync.RWMutex
iconURL string
name string
domain string
}
// TODO(freeformz): default image?
func (t *team) Update(s *slack.TeamInfo) {
t.mu.Lock()
defer t.mu.Unlock()
t.name = s.Name
t.domain = s.Domain
if v, ok := s.Icon["image_default"]; ok {
if b, ok := v.(bool); ok && b {
t.iconURL = ""
return
}
}
var icons = []string{"132", "102", "88", "68", "44", "34"}
for _, i := range icons {
img, ok := s.Icon["image_"+i]
if ok {
if str, ok := img.(string); ok {
t.iconURL = str
}
return
}
}
log.Println("Unable to determine icon image")
}
//Icon information for the teams
func (t *team) Icon() string {
t.mu.RLock()
defer t.mu.RUnlock()
return t.iconURL
}
// Name of the team
func (t *team) Name() string {
t.mu.RLock()
defer t.mu.RUnlock()
return t.name
}
// Domain of the team
func (t *team) Domain() string {
t.mu.RLock()
defer t.mu.RUnlock()
return t.domain
}