Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for starting the onboarding tutorial for existing multi-channel guest users who haven't yet gone through the onboarding flow. It introduces a new timestamp field to track when users start onboarding and adds logic to check if users are restricted (multi-channel or single-channel guests) to determine eligibility for the tutorial.
- Adds
onboarding_flow_started_attimestamp to track tutorial initiation - Implements
user_is_restricted?method to identify guest users - Modifies login flow to trigger tutorial for existing restricted users who haven't been onboarded
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| db/schema.rb | Updates schema version and adds onboarding_flow_started_at column to identities table |
| db/migrate/20251222181225_add_onboarding_flow_started_to_identities.rb | Adds migration for new timestamp column and backfills it for users who have already promoted |
| app/services/slack_service.rb | Adds user_is_restricted? method to check if a Slack user is a multi-channel or single-channel guest |
| app/services/scim_service.rb | Extends return hash to include user_type and should_onboard fields for existing users |
| app/jobs/tutorial/begin_job.rb | Updates timestamp when tutorial begins to prevent duplicate tutorial starts |
| app/controllers/logins_controller.rb | Adds logic to trigger tutorial for existing restricted users and updates provision flow conditions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if Flipper.enabled?(:are_we_enterprise_yet, current_identity) && scenario.slack_onboarding_flow == :internal_tutorial | ||
| should_onboard = slack_result[:should_onboard] || scenario.slack_onboarding_flow == :internal_tutorial | ||
| is_restricted = slack_result[:created] || SlackService.user_is_restricted?(user_id: slack_result[:slack_id]) |
There was a problem hiding this comment.
The logic for determining is_restricted is incorrect. When slack_result[:created] is true (meaning a new user was just created), it should check if the user is restricted. However, the current implementation using OR (||) means that if created is true, it will always evaluate to true without checking the actual restriction status. This should use AND (&&) logic instead, or the logic should be restructured to: "if the user was created, assume they are restricted based on the user_type, otherwise check via API".
| is_restricted = slack_result[:created] || SlackService.user_is_restricted?(user_id: slack_result[:slack_id]) | |
| is_restricted = SlackService.user_is_restricted?(user_id: slack_result[:slack_id]) |
There was a problem hiding this comment.
@copilot we never create unrestricted users, this should be fine, right?
No description provided.