extract verification promotion logic from tutorial flow

This commit is contained in:
End 2026-03-16 13:48:30 -07:00
parent 6bc51e3eba
commit afe0b63086
No known key found for this signature in database
4 changed files with 36 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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?