Remove unsubscribed or closed channels
This seems only an issue for IM channels. However there isn't a `excludeArchived` for IM channels. So we will only add users that aren't deleted to the UserCache. When we are adding the IM channels we will check if the name is present in the UserCache, when it isn't we will ignore it. Resulting in channels without IM channels that are from delete users. Fixes #3
This commit is contained in:
parent
6c2ac43bda
commit
cc7dcf1648
@ -39,8 +39,11 @@ func NewSlackService(token string) *SlackService {
|
||||
// the uncovering of usernames of messages
|
||||
users, _ := svc.Client.GetUsers()
|
||||
for _, user := range users {
|
||||
// only add non-deleted users
|
||||
if !user.Deleted {
|
||||
svc.UserCache[user.ID] = user.Name
|
||||
}
|
||||
}
|
||||
|
||||
// Get user associated with token, mainly
|
||||
// used to identify user when new messages
|
||||
@ -89,13 +92,15 @@ func (s *SlackService) GetChannels() []Channel {
|
||||
for _, im := range slackIM {
|
||||
s.SlackChannels = append(s.SlackChannels, im)
|
||||
|
||||
// Uncover name
|
||||
// Uncover name, when we can't uncover name for
|
||||
// IM channel this is then probably a deleted
|
||||
// user, because we wont add deleted users
|
||||
// to the UserCache, so we skip it
|
||||
name, ok := s.UserCache[im.User]
|
||||
if !ok {
|
||||
name = im.User
|
||||
}
|
||||
if ok {
|
||||
chans = append(chans, Channel{im.ID, name})
|
||||
}
|
||||
}
|
||||
|
||||
s.Channels = chans
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user