osem-fcy/app/controllers/concerns/invitation.rb
Rahul 9cc74e051c
add unsubscribe to email
If a user has opted out of emails then invitation mail will not be sent to the user
2021-03-06 03:47:18 +01:00

21 lines
667 B
Ruby

module Invitation
extend ActiveSupport::Concern
def booth_responsible_invite
if booth_params[:invite_responsible]
emails_array = booth_params[:invite_responsible].split(',')
emails_array.each do |email|
new_user = User.find_by(email: email)
if new_user.nil? || !new_user.opted_out?
User.invite!({ email: email }, current_user)
new_user = User.find_by(email: email)
end
if new_user && @booth.responsible_ids.exclude?(new_user.id)
BoothRequest.create(booth_id: @booth.id, user_id: new_user.id,
role: 'responsible')
end
end
end
end
end