-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_channels.go
executable file
·42 lines (38 loc) · 1.14 KB
/
list_channels.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
package server
import (
"context"
"github.com/pkg/errors"
"github.com/thavlik/t4vd/sources/pkg/api"
"go.uber.org/zap"
)
func (s *Server) ListChannels(ctx context.Context, req api.ListChannelsRequest) (*api.ListChannelsResponse, error) {
if req.ProjectID == "" {
return nil, errMissingProjectID
}
channels, err := s.store.ListChannels(ctx, req.ProjectID)
if err != nil {
return nil, errors.Wrap(err, "store.ListChannels")
}
s.log.Debug("channels listed",
zap.String("projectID", req.ProjectID),
zap.Int("len", len(channels)))
return &api.ListChannelsResponse{
Channels: channels,
}, nil
}
func (s *Server) ListChannelIDs(ctx context.Context, req api.ListChannelIDsRequest) (*api.ListChannelIDsResponse, error) {
if req.ProjectID == "" {
return nil, errMissingProjectID
}
channelIDs, err := s.store.ListChannelIDs(ctx, req.ProjectID, req.Blacklist)
if err != nil {
return nil, errors.Wrap(err, "store.ListChannelIDs")
}
s.log.Debug("channel IDs listed",
zap.String("projectID", req.ProjectID),
zap.Bool("blacklist", req.Blacklist),
zap.Int("len", len(channelIDs)))
return &api.ListChannelIDsResponse{
IDs: channelIDs,
}, nil
}