Add support for Slack App Home

What does this MR do and why?

This MR adds support for displaying a friendly "home" view for the GitLab Slack App #363635 (closed). The view prompts the user to connect their GitLab account.

The API endpoint that receives events from Slack (API::Integrations::Slack::Events) previously only responded with an in-request "challenge" to verify with Slack that the API endpoint is ready to receive events. This MR adds the first proper feature that does something with an event sent to this endpoint (the name of the event sent from Slack is app_home_opened).

The response to the "challenge" must be returned in request, but for all other events, we want to handle them asynchronously. So this MR adds some new classes in order to be able to do this. A new SlackEventService either calls UrlVerificationService directly to return the response for the "challenge" or queues a new worker SlackEventWorker to process the event async. In this MR the worker will only call one service AppHomeOpenedService. In the future, we anticipate more service classes will be written for the worker class to call to do other things.

A good summary of how the changes in this MR interact with Slack was written by a reviewer !96092 (comment 1088570040):

  1. A user opens the app page (Home) in Slack.
  2. Slack sends a request to POST integrations/slack/events
  3. We schedule an async worker with the params we received and return HTTP 200.
  4. The worker generates the Slack home page view using BlockKit and posts it back to the Slack API.

How to set up and validate locally

  1. Follow the Integrations Slack guide to stand up a GitPod instance that can integrate with the development Slack App. As mentioned in the guide, you will need access to the Ecosystems Slack Workspace.
  2. On your GitPod instance terminal:
    1. Check out this feature branch: cd /workspace/gitlab && git checkout 363635-slack-app_home_opened
    2. Ensure yarn and gems are installed (the branch's versions can be behind master): cd /workspace/gitlab && yarn && bundle.
    3. Enable the feature flag: cd /workspace/gitlab && bundle exec rails c, then Feature.enable(:slack_events_app_home_opened)
    4. Restart GDK: cd /workspace/gitlab-development-kit && gdk restart
  3. Visit your GitPod instance server https://<your-unique>.gitpod.io:
    1. Choose a GitLab project, and go Settings > Integrations.
    2. Choose Slack application
    3. Click the Install Slack app button.
    4. Go through the Slack installation process (install to the Ecosystem Test Workspace (select it from the dropdown top-right).
  4. From the Ecosystems Slack Workspace:
    1. On the sidebar, view the App Home: Apps > GitLab (dev).
    2. The page should load according to the designs.
    3. Click Connect GitLab account and follow the prompts to authorize connecting your GitLab account.
    4. Once connected, click away from the App Home, and then click back to it again. After a short wait, you should see the page load and confirm your account is connected.

Screenshots or screen recordings

This is a screen recording of the last step (4) of the above QA instructions.

slack480

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #363635 (closed)

Edited by Luke Duncalfe

Merge request reports

Loading