This PR adds a reload-safe onboarding Help Center generation status path. Previously, generation progress was pushed through ActionCable, which meant the onboarding UI could lose context after a page reload or missed websocket event. The new endpoint exposes the current generation id, raw Redis generation state, and Help Center article/category counts so clients can recover state by fetching from the backend. **What changed** - Added an onboarding Help Center generation status endpoint. - Persisted `help_center_generation_id` when generation is enqueued. - Removed Help Center generation ActionCable broadcasts completely. - Kept generation progress in Redis as the backend source of truth. - Kept Help Center generation out of the onboarding hot path; the existing onboarding controller does not start generation yet. **How to test** 1. Start Help Center generation for an account. 2. Fetch the onboarding generation status endpoint and verify it returns the generation id, Redis state, and article/category counts. 3. Reload the onboarding UI or client state and fetch again to confirm progress can be recovered without relying on websocket events. 4. Verify skipped/completed generation states are reflected from Redis. ## Related PRs - https://github.com/chatwoot/chatwoot/pull/14569 - https://github.com/chatwoot/chatwoot/pull/14568 - https://github.com/chatwoot/chatwoot/pull/14567 - https://github.com/chatwoot/chatwoot/pull/14619 - https://github.com/chatwoot/chatwoot/pull/14565 (Primary onboarding PR)
52 lines
1.4 KiB
Ruby
52 lines
1.4 KiB
Ruby
class Api::V1::Accounts::OnboardingsController < Api::V1::Accounts::BaseController
|
|
before_action :check_admin_authorization?
|
|
|
|
def update
|
|
@account = Current.account
|
|
finalize = finalizing_account_details?
|
|
|
|
@account.assign_attributes(account_params)
|
|
@account.custom_attributes.merge!(custom_attributes_params)
|
|
@account.custom_attributes.delete('onboarding_step') if finalize
|
|
@account.save!
|
|
|
|
# TODO: re-enable when the help center generation UI is ready to surface progress
|
|
# Onboarding::HelpCenterCreationService.new(@account, Current.user).perform if finalize && website.present?
|
|
|
|
render 'api/v1/accounts/update', format: :json
|
|
end
|
|
|
|
def help_center_generation
|
|
render json: help_center_generation_status
|
|
end
|
|
|
|
private
|
|
|
|
def finalizing_account_details?
|
|
@account.custom_attributes['onboarding_step'] == 'account_details'
|
|
end
|
|
|
|
def website
|
|
custom_attributes_params[:website]
|
|
end
|
|
|
|
def account_params
|
|
params.permit(:name, :locale)
|
|
end
|
|
|
|
def custom_attributes_params
|
|
params.permit(:industry, :company_size, :timezone, :referral_source, :user_role, :website)
|
|
end
|
|
|
|
def help_center_generation_status
|
|
{
|
|
generation_id: nil,
|
|
state: nil,
|
|
articles_count: 0,
|
|
categories_count: 0
|
|
}
|
|
end
|
|
end
|
|
|
|
Api::V1::Accounts::OnboardingsController.prepend_mod_with('Api::V1::Accounts::OnboardingsController')
|