Skip to content
Closed
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
21 changes: 6 additions & 15 deletions app/controllers/volunteers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,13 @@ def create
authorize @volunteer

if @volunteer.save
# invitation error handling
begin
@volunteer.invite!(current_user)
rescue => e
flash[:alert] = "Volunteer invitation failed. Reason: #{e.message}"
end

@volunteer.invite!(current_user)
# call short io api here
invitation_url = Rails.application.routes.url_helpers.accept_user_invitation_url(invitation_token: @volunteer.raw_invitation_token, host: request.base_url)

hash_of_short_urls = {0 => nil, 1 => nil}
if @volunteer.phone_number.present?
hash_of_short_urls = handle_short_url([invitation_url, request.base_url + "/users/edit"])
end

sms_status = deliver_sms_to @volunteer, account_activation_msg("volunteer", hash_of_short_urls)
raw_token = @volunteer.raw_invitation_token
invitation_url = Rails.application.routes.url_helpers.accept_user_invitation_url(invitation_token: raw_token, host: request.base_url)
hash_of_short_urls = @volunteer.phone_number.blank? ? {0 => nil, 1 => nil} : handle_short_url([invitation_url, request.base_url + "/users/edit"])
body_msg = account_activation_msg("volunteer", hash_of_short_urls)
sms_status = deliver_sms_to @volunteer, body_msg
redirect_to edit_volunteer_path(@volunteer), notice: sms_acct_creation_notice("volunteer", sms_status)
else
render :new, status: :unprocessable_entity
Expand Down
Loading