mirror of
https://github.com/System-End/identity-vault.git
synced 2026-04-19 15:18:23 +00:00
extract verification promotion logic from tutorial flow
This commit is contained in:
parent
6bc51e3eba
commit
afe0b63086
4 changed files with 36 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue