Skip to content

Commit

Permalink
fix add user to mailing list
Browse files Browse the repository at this point in the history
  • Loading branch information
haddadzineddine committed Dec 26, 2022
1 parent 1306d4f commit a0352e8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def create
else
# Attempt to register user to list
if params[:user][:register_mail_list]
Notifier.register_for_announce_list(@user.email).deliver rescue nil
helpers.subscribe(user: @user)
end

flash[:notice] = 'Account was successfully created'
Expand Down
10 changes: 10 additions & 0 deletions app/helpers/user_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module UserHelper

# factory methode
def subscribe(user)
if $SUBSCRIBE_SERVICE.upcase == "SYMPA"
return SympaSubscribeMailer.with(user).register_for_announce_list.deliver_now;
end
end

end
4 changes: 4 additions & 0 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base

end

13 changes: 13 additions & 0 deletions app/mailers/sympa_subscribe_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class SympaSubscribeMailer < ApplicationMailer

def register_for_announce_list

unless $SUBSCRIBE_LIST_NAME.nil? || $SUBSCRIBE_LIST_NAME.empty?
@user = params[:user]
@sub = "subscribe #{$SUBSCRIBE_LIST_NAME} #{@user.firstName} #{@user.lastName}"
mail(to: $SUBSCRIBE_SERVICE_MAIL, from: @user.email, subject: @sub)
end

end

end
Empty file.

0 comments on commit a0352e8

Please sign in to comment.