M docs/slack_bot.md => docs/slack_bot.md +3 -2
@@ 4,5 4,6 @@
* Create a new Slack App from a manifest and select you Workspace in https://api.slack.com/apps
* Copy the manifest from `docs/slack_bot_manifest.yaml` and paste it in the creation wizard
* Change `<link_url>` values with the current link url
-* From the `Basic Information` section copy the Client ID, Client Secret and Signing Secret into the slack section
-of the config.ini file (`client-secret`, `client-id`, `signing-secret`)
+* From the `Basic Information` section copy the Client ID, Client Secret and
+ Signing Secret into the slack section of the config.ini file
+ (`client-secret`, `client-id`, `signing-secret`)
M docs/slack_bot_manifest.yaml => docs/slack_bot_manifest.yaml +1 -1
@@ 19,7 19,7 @@ features:
url: https://<link_url>/slack/command
- command: /link-add-short
description: Add a new short link
- usage_hint: code:<code> domain:<domain>
+ usage_hint: url code:<code> domain:<domain>
url: https://<link_url>/slack/command
oauth_config:
scopes:
M slack/commands.go => slack/commands.go +10 -13
@@ 120,20 120,8 @@ func linkAddShort(c echo.Context, surl, teamID, slackUser, text string) (*SlackC
return commandResp, nil
}
- if domstr == "" {
- block.Text.Text = lt.Translate("Wrong domain argument")
- commandResp := &SlackCommandResponse{
- Text: "Error",
- Blocks: []SlackBlock{block},
- }
- return commandResp, nil
- }
-
- // Check that the domain exists, it is a short service domain
- // and belong to the slack connection organization
opts = &database.FilterOptions{
Filter: sq.And{
- sq.Eq{"d.lookup_name": strings.ToLower(domstr)},
sq.Eq{"d.service": models.DomainServiceShort},
sq.Eq{"d.status": models.DomainStatusApproved},
sq.Eq{"d.is_active": true},
@@ 145,7 133,16 @@ func linkAddShort(c echo.Context, surl, teamID, slackUser, text string) (*SlackC
sq.Eq{"d.level": models.DomainLevelSystem},
},
},
- Limit: 1,
+ Limit: 1,
+ OrderBy: "d.level, id DESC", // Return org domains first
+ }
+
+ if domstr != "" {
+ // If domain was specified, use it
+ opts.Filter = sq.And{
+ opts.Filter,
+ sq.Eq{"d.lookup_name": strings.ToLower(domstr)},
+ }
}
domains, err := models.GetDomains(ctx, opts)
M slack/routes.go => slack/routes.go +1 -2
@@ 143,8 143,8 @@ func (s *Service) ConnectUser(c echo.Context) error {
req := c.Request()
if req.Method == "POST" {
- // Should not be reached, but just in case
if !org.SlackConnID.Valid {
+ // Should not be reached, but just in case
messages.Error(c, lt.Translate("Something went wrong. The user could not be linked."))
return links.Render(c, http.StatusOK, "connect_user.html", gmap)
@@ 161,7 161,6 @@ func (s *Service) ConnectUser(c echo.Context) error {
}
messages.Success(c, lt.Translate("User connected successfully"))
return c.Redirect(http.StatusMovedPermanently, c.Echo().Reverse("accounts:settings"))
-
}
return links.Render(c, http.StatusOK, "connect_user.html", gmap)