diff --git a/app/controllers/backend/verifications_controller.rb b/app/controllers/backend/verifications_controller.rb index 108d898..f607acf 100644 --- a/app/controllers/backend/verifications_controller.rb +++ b/app/controllers/backend/verifications_controller.rb @@ -90,8 +90,8 @@ module Backend if ident.present? && ident.slack_id.present? && ident.promote_click_count == 0 scenario = ident.onboarding_scenario_instance if scenario&.promote_on_verification - Tutorial::AgreeJob.perform_later(ident) - Rails.logger.info "Enqueued auto-promotion for identity #{ident.id} (verification #{@verification.id})" + RalseiEngine.promote_on_verification(ident) + Rails.logger.info "Auto-promoted identity #{ident.id} on verification #{@verification.id}" end end rescue => e diff --git a/app/models/onboarding_scenarios/base.rb b/app/models/onboarding_scenarios/base.rb index 8129297..727ed11 100644 --- a/app/models/onboarding_scenarios/base.rb +++ b/app/models/onboarding_scenarios/base.rb @@ -120,6 +120,9 @@ module OnboardingScenarios def before_first_message = nil def after_promotion = nil + + def after_verification_promotion(identity) = nil + # Handle custom actions - return step symbol, template string, or hash def handle_action(action_id) = nil diff --git a/app/models/onboarding_scenarios/riceathon.rb b/app/models/onboarding_scenarios/riceathon.rb index 4de3143..e74a08f 100644 --- a/app/models/onboarding_scenarios/riceathon.rb +++ b/app/models/onboarding_scenarios/riceathon.rb @@ -23,5 +23,11 @@ module OnboardingScenarios def logo_path = "images/riceathon/RiceathonGlow.png" def card_attributes = { wide_logo: true } + + # When user is promoted via verification approval, send them the welcome message + # ensures theysee the CoC + def after_verification_promotion(identity) + RalseiEngine.send_step(identity, :welcome) + end end end diff --git a/app/services/ralsei_engine.rb b/app/services/ralsei_engine.rb index 9d4517e..ff52b72 100644 --- a/app/services/ralsei_engine.rb +++ b/app/services/ralsei_engine.rb @@ -94,6 +94,31 @@ module RalseiEngine Rails.logger.info "RalseiEngine: promoted #{identity.public_id}" end + # Promote user when verification is approved + def promote_on_verification(identity) + return if identity.promote_click_count > 0 + + Rails.logger.info "RalseiEngine: promoting #{identity.public_id} on verification approval" + scenario = identity.onboarding_scenario_instance + + SlackService.promote_user(identity.slack_id) + + promotion_channels = scenario&.promotion_channels + if promotion_channels.present? + SlackService.add_to_channels(user_id: identity.slack_id, channel_ids: promotion_channels) + end + + track_dialogue_event("dialogue.promoted", scenario: scenario&.class&.slug, trigger: "verification_approved") + + scenario&.after_promotion + + identity.increment!(:promote_click_count, 1) + + scenario&.after_verification_promotion(identity) + + Rails.logger.info "RalseiEngine: promoted #{identity.public_id} on verification" + end + def send_message(identity, template_name) return unless identity.slack_id.present?