Skip to content

Commit

Permalink
Set user presence at start up
Browse files Browse the repository at this point in the history
Fixes #175
  • Loading branch information
jpbruinsslot committed Mar 2, 2019
1 parent 3075f78 commit ca9ebaa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion service/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ func NewSlackService(config *config.Config) (*SlackService, error) {
}
}

// Get name of current user
// Get name of current user, and set presence to active
currentUser, err := svc.Client.GetUserInfo(svc.CurrentUserID)
if err != nil {
svc.CurrentUsername = "slack-term"
}
svc.CurrentUsername = currentUser.Name
svc.SetUserAsActive()

return svc, nil
}
Expand Down Expand Up @@ -248,6 +249,11 @@ func (s *SlackService) GetUserPresence(userID string) (string, error) {
return presence.Presence, nil
}

// Set current user presence to active
func (s *SlackService) SetUserAsActive() {
s.Client.SetUserPresence("auto")
}

// MarkAsRead will set the channel as read
func (s *SlackService) MarkAsRead(channelID string) {
s.Client.SetChannelReadMark(
Expand Down

0 comments on commit ca9ebaa

Please sign in to comment.