Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/controllers/backend/verifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file added app/frontend/images/riceathon/RiceathonGlow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/models/onboarding_scenarios/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
33 changes: 33 additions & 0 deletions app/models/onboarding_scenarios/riceathon.rb
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions app/services/ralsei_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
1 change: 1 addition & 0 deletions config/slack_channels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ shared:
hack_club_the_game: C088DT8P7B8
hctg_bulletin: C0A7HQZFFNX
hctg_help: C0A9XULS1SL
riceathon: C07MLF9A8H5