diff --git a/app/bot/bot.go b/app/bot/bot.go index b7cedf7..43bf052 100644 --- a/app/bot/bot.go +++ b/app/bot/bot.go @@ -12,6 +12,7 @@ import ( "github.com/etcinit/phabulous/app/modules/core" "github.com/etcinit/phabulous/app/modules/dev" "github.com/etcinit/phabulous/app/modules/extension" + "github.com/jacobstr/confer" "github.com/nlopes/slack" ) @@ -234,6 +235,11 @@ func (b *Bot) MakeSlack() *slack.Client { return b.Slacker.Slack } +// MakeConfig returns an instance of the configuration store. +func (b *Bot) MakeConfig() *confer.Config { + return b.Slacker.Config +} + // HandleUsage shows usage tip. func (b *Bot) HandleUsage(ev *slack.MessageEvent, matches []string) { b.Slacker.SimplePost( diff --git a/app/modules/core/command_summon.go b/app/modules/core/command_summon.go index 166c9e6..e1ec390 100644 --- a/app/modules/core/command_summon.go +++ b/app/modules/core/command_summon.go @@ -6,6 +6,8 @@ import ( "strings" "github.com/etcinit/gonduit/requests" + "github.com/etcinit/phabulous/app/gonduit/extensions" + phabulousRequests "github.com/etcinit/phabulous/app/gonduit/extensions/requests" "github.com/etcinit/phabulous/app/messages" "github.com/etcinit/phabulous/app/modules" "github.com/nlopes/slack" @@ -94,9 +96,48 @@ func (c *SummonCommand) GetHandler() modules.Handler { return } + slackMap, err := extensions.PhabulousToSlack( + conn, + phabulousRequests.PhabulousToSlackRequest{ + UserPHIDs: (*res)[0].Reviewers, + }, + ) + if err != nil { + s.Excuse(ev, err) + return + } + + slackUsers, err := s.MakeSlack().GetUsers() + if err != nil { + s.Excuse(ev, err) + return + } + reviewerNames := []string{} for _, reviewerPHID := range (*res)[0].Reviewers { + if slackUserInfo, ok := (*slackMap)[reviewerPHID]; ok { + var foundUser *slack.User + for _, user := range slackUsers { + if user.ID == slackUserInfo.AccountID { + foundUser = &user + break + } + } + + if foundUser != nil { + reviewerNames = append( + reviewerNames, + fmt.Sprintf( + "@%s :slack:", + foundUser.Name, + ), + ) + + continue + } + } + nameRes, err := conn.PHIDQuerySingle(reviewerPHID) if err != nil { s.Excuse(ev, err) diff --git a/app/modules/extension/command_whois.go b/app/modules/extension/command_whois.go index d83c711..fae9719 100644 --- a/app/modules/extension/command_whois.go +++ b/app/modules/extension/command_whois.go @@ -98,8 +98,8 @@ func toSlack( if len(*accounts) == 0 { s.Post( ev.Channel, - "I was unable to find a Phabricator user linked with that "+ - "Slack account. Make sure they are linked under "+ + "I was unable to find a Slack user linked with that "+ + "Phabricator account. Make sure they are linked under "+ "_External Accounts_ in the user's Phabricator settings.", messages.IconTasks, true, diff --git a/app/modules/interfaces.go b/app/modules/interfaces.go index 7401108..2ac9220 100644 --- a/app/modules/interfaces.go +++ b/app/modules/interfaces.go @@ -3,6 +3,7 @@ package modules import ( "github.com/etcinit/gonduit" "github.com/etcinit/phabulous/app/messages" + "github.com/jacobstr/confer" "github.com/nlopes/slack" ) @@ -22,6 +23,7 @@ type Service interface { MakeGonduit() (*gonduit.Conn, error) MakeRTM() *slack.RTM MakeSlack() *slack.Client + MakeConfig() *confer.Config GetModules() []Module }