-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmodel.go
67 lines (60 loc) · 1.83 KB
/
model.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
63
64
65
66
67
package bearychat
// Team information
type Team struct {
Id string `json:"id"`
Subdomain string `json:"subdomain"`
Name string `json:"name"`
UserId string `json:"uid"`
Description string `json:"description"`
EmailDomain string `json:"email_domain"`
Inactive bool `json:"inactive"`
CreatedAt string `json:"created"` // TODO parse date
UpdatedAt string `json:"updated"` // TODO parse date
}
const (
UserRoleOwner = "owner"
UserRoleAdmin = "admin"
UserRoleNormal = "normal"
UserRoleVisitor = "visitor"
)
const (
UserTypeNormal = "normal"
UserTypeAssistant = "assistant"
UserTypeHubot = "hubot"
)
// User information
type User struct {
Id string `json:"id"`
TeamId string `json:"team_id"`
VChannelId string `json:"vchannel_id"`
Name string `json:"name"`
FullName string `json:"full_name"`
Email string `json:"email"`
AvatarUrl string `json:"avatar_url"`
Role string `json:"role"`
Type string `json:"type"`
Conn string `json:"conn"`
CreatedAt string `json:"created"` // TODO parse date
UpdatedAt string `json:"updated"` // TODO parse date
}
// IsOnline tells user connection status.
func (u User) IsOnline() bool {
return u.Conn == "connected"
}
// IsNormal tells if this user a normal user (owner, admin or normal)
func (u User) IsNormal() bool {
return u.Type == UserTypeNormal && u.Role != UserRoleVisitor
}
// Channel information.
type Channel struct {
Id string `json:"id"`
TeamId string `json:"team_id"`
UserId string `json:"uid"`
VChannelId string `json:"vchannel_id"`
Name string `json:"name"`
IsPrivate bool `json:"private"`
IsGeneral bool `json:"general"`
Topic string `json:"topic"`
CreatedAt string `json:"created"` // TODO parse date
UpdatedAt string `json:"updated"` // TODO parse date
}