-
Notifications
You must be signed in to change notification settings - Fork 27
/
channel.go
85 lines (75 loc) · 1.79 KB
/
channel.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package slick
import (
"time"
"github.com/nlopes/slack"
)
// Channel is an abstraction of the Slack channels, with merged and
// distinguished data from IMs, Groups and Channels.
type Channel struct {
ID string
Created time.Time
IsOpen bool
LastRead string
Name string
Creator string
// Three mutually exclusives
IsChannel bool
IsGroup bool
IsIM bool
// Only with `IsChannel`
IsGeneral bool
Members []string
// Only for `IsGroup` (?)
IsMember bool
IsArchived bool
// Only for `IsIM`
User string
IsUserDeleted bool
// Only for `IsChannel || IsGroup`
Topic slack.Topic
Purpose slack.Purpose
}
func ChannelFromSlackGroup(group slack.Group) Channel {
return Channel{
ID: group.ID,
Created: group.Created.Time(),
IsOpen: group.IsOpen,
LastRead: group.LastRead,
Name: group.Name,
Creator: group.Creator,
Members: group.Members,
//IsMember: group.IsMember, wh00ps, not there anymore.
IsArchived: group.IsArchived,
Topic: group.Topic,
Purpose: group.Purpose,
IsGroup: true,
}
}
func ChannelFromSlackChannel(channel slack.Channel) Channel {
return Channel{
ID: channel.ID,
Created: channel.Created.Time(),
IsOpen: channel.IsOpen,
LastRead: channel.LastRead,
Name: channel.Name,
Creator: channel.Creator,
Members: channel.Members,
IsMember: channel.IsMember,
IsArchived: channel.IsArchived,
Topic: channel.Topic,
Purpose: channel.Purpose,
IsChannel: true,
}
}
func ChannelFromSlackIM(im slack.IM) Channel {
return Channel{
ID: im.ID,
Created: im.Created.Time(),
IsOpen: im.IsOpen,
LastRead: im.LastRead,
Name: im.User,
User: im.User,
IsUserDeleted: im.IsUserDeleted,
IsIM: true,
}
}