diff --git a/app/controllers/backend/verifications_controller.rb b/app/controllers/backend/verifications_controller.rb index c9085947..f607acf2 100644 --- a/app/controllers/backend/verifications_controller.rb +++ b/app/controllers/backend/verifications_controller.rb @@ -84,6 +84,21 @@ def approve @verification.create_activity(key: "verification.approve", owner: current_user, recipient: @verification.identity, parameters: { ysws_eligible: ysws_eligible }) + # Auto-promote on verification approval for scenarios that opt in. + begin + ident = @verification.identity + if ident.present? && ident.slack_id.present? && ident.promote_click_count == 0 + scenario = ident.onboarding_scenario_instance + if scenario&.promote_on_verification + RalseiEngine.promote_on_verification(ident) + Rails.logger.info "Auto-promoted identity #{ident.id} on verification #{@verification.id}" + end + end + rescue => e + Rails.logger.error "Auto-promote on verification approval failed: #{e.message}" + Sentry.capture_exception(e) if defined?(Sentry) + end + redirect_to pending_backend_verifications_path end diff --git a/app/frontend/images/riceathon/RiceathonGlow.png b/app/frontend/images/riceathon/RiceathonGlow.png new file mode 100644 index 00000000..dc8ae557 Binary files /dev/null and b/app/frontend/images/riceathon/RiceathonGlow.png differ diff --git a/app/models/onboarding_scenarios/base.rb b/app/models/onboarding_scenarios/base.rb index 96d1e6cc..727ed11c 100644 --- a/app/models/onboarding_scenarios/base.rb +++ b/app/models/onboarding_scenarios/base.rb @@ -50,6 +50,9 @@ def slack_channels = [] # Returns array of channel names/IDs to add when promoting guest to full member def promotion_channels = [] + # Whether to auto-promote when identity verification in HCA is approved + def promote_on_verification = false + # Returns :internal_tutorial or :external_program def slack_onboarding_flow = :external_program @@ -117,6 +120,9 @@ def dark_mode_background_path = background_path 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 new file mode 100644 index 00000000..e74a08f5 --- /dev/null +++ b/app/models/onboarding_scenarios/riceathon.rb @@ -0,0 +1,33 @@ +module OnboardingScenarios + class Riceathon < Base + def self.slug = "riceathon" + + def title = "ready to start ricing?" + + def form_fields + [ :first_name, :last_name, :primary_email, :birthday, :country ] + end + + def slack_user_type = :multi_channel_guest + + def slack_channels = chans(:riceathon, :announcements, :welcome_to_hack_club, :identity_help) + + def promotion_channels = chans(:riceathon, :announcements, :welcome_to_hack_club, :identity_help) + + def next_action = :slack + + def use_dm_channel? = false + + def promote_on_verification = true + + 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 9d4517e2..ff52b720 100644 --- a/app/services/ralsei_engine.rb +++ b/app/services/ralsei_engine.rb @@ -94,6 +94,31 @@ def promote_user(identity) 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? diff --git a/config/slack_channels.yml b/config/slack_channels.yml index 9ac79dbb..84c3ed8b 100644 --- a/config/slack_channels.yml +++ b/config/slack_channels.yml @@ -49,3 +49,4 @@ shared: hack_club_the_game: C088DT8P7B8 hctg_bulletin: C0A7HQZFFNX hctg_help: C0A9XULS1SL + riceathon: C07MLF9A8H5