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):
- A user opens the app page (Home) in Slack.
- Slack sends a request to
POST integrations/slack/events- We schedule an async worker with the params we received and return
HTTP 200.- 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
- 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.
- On your GitPod instance terminal:
- Check out this feature branch:
cd /workspace/gitlab && git checkout 363635-slack-app_home_opened - Ensure yarn and gems are installed (the branch's versions can be behind
master):cd /workspace/gitlab && yarn && bundle. - Enable the feature flag:
cd /workspace/gitlab && bundle exec rails c, thenFeature.enable(:slack_events_app_home_opened) - Restart GDK:
cd /workspace/gitlab-development-kit && gdk restart
- Check out this feature branch:
- Visit your GitPod instance server
https://<your-unique>.gitpod.io:- Choose a GitLab project, and go
Settings > Integrations. - Choose
Slack application - Click the
Install Slack appbutton. - Go through the Slack installation process (install to the Ecosystem Test Workspace (select it from the dropdown top-right).
- Choose a GitLab project, and go
- From the Ecosystems Slack Workspace:
- On the sidebar, view the App Home:
Apps > GitLab (dev). - The page should load according to the designs.
- Click
Connect GitLab accountand follow the prompts to authorize connecting your GitLab account. - 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.
- On the sidebar, view the App Home:
Screenshots or screen recordings
This is a screen recording of the last step (4) of the above QA instructions.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #363635 (closed)