Skip to content

Commit 3d88c84

Browse files
authored
Merge pull request #6224 from 7riumph/volunteers#create-bot-bugnsag
Attempt to address volunteer#create invalid email error in bot-bugsag
2 parents aced932 + 902f293 commit 3d88c84

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

app/controllers/volunteers_controller.rb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,22 @@ def create
3232
authorize @volunteer
3333

3434
if @volunteer.save
35-
@volunteer.invite!(current_user)
35+
# invitation error handling
36+
begin
37+
@volunteer.invite!(current_user)
38+
rescue => e
39+
flash[:alert] = "Volunteer invitation failed. Reason: #{e.message}"
40+
end
41+
3642
# call short io api here
37-
raw_token = @volunteer.raw_invitation_token
38-
invitation_url = Rails.application.routes.url_helpers.accept_user_invitation_url(invitation_token: raw_token, host: request.base_url)
39-
hash_of_short_urls = @volunteer.phone_number.blank? ? {0 => nil, 1 => nil} : handle_short_url([invitation_url, request.base_url + "/users/edit"])
40-
body_msg = account_activation_msg("volunteer", hash_of_short_urls)
41-
sms_status = deliver_sms_to @volunteer, body_msg
43+
invitation_url = Rails.application.routes.url_helpers.accept_user_invitation_url(invitation_token: @volunteer.raw_invitation_token, host: request.base_url)
44+
45+
hash_of_short_urls = {0 => nil, 1 => nil}
46+
if @volunteer.phone_number.present?
47+
hash_of_short_urls = handle_short_url([invitation_url, request.base_url + "/users/edit"])
48+
end
49+
50+
sms_status = deliver_sms_to @volunteer, account_activation_msg("volunteer", hash_of_short_urls)
4251
redirect_to edit_volunteer_path(@volunteer), notice: sms_acct_creation_notice("volunteer", sms_status)
4352
else
4453
render :new, status: :unprocessable_entity

0 commit comments

Comments
 (0)