/
channel.go
61 lines (47 loc) · 1.16 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
// Copyright 2015 Bobby Powers. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package slackfs
import (
"fmt"
"github.com/bpowers/slack"
)
type Channel struct {
slack.Channel
Session
}
func NewChannel(sc slack.Channel, conn *FSConn) *Channel {
c := new(Channel)
c.Channel = sc
c.Session.Init(c, conn, conn.api.GetChannelHistory)
return c
}
func (c *Channel) BaseChannel() *slack.BaseChannel {
return &c.Channel.BaseChannel
}
func (c *Channel) Id() string {
return c.Channel.Id
}
func (c *Channel) Name() string {
return c.Channel.Name
}
func (c *Channel) IsOpen() bool {
return c.Channel.IsMember
}
func NewChannelDir(parent *DirNode, id string, priv interface{}) (*DirNode, error) {
if _, ok := priv.(*Channel); !ok {
return nil, fmt.Errorf("NewChannelDir called w non-chan: %#v", priv)
}
dir, err := NewDirNode(parent, id, priv)
if err != nil {
return nil, fmt.Errorf("NewDirNode: %s", err)
}
for _, attrFactory := range roomAttrs {
n, err := attrFactory(dir)
if err != nil {
return nil, fmt.Errorf("attrFactory: %s", err)
}
n.Activate()
}
return dir, nil
}