We Value Your Privacy
\n\n We use cookies to enhance your browsing experience, serve personalized ads or content, and analyze our traffic. By clicking \"Accept All\", you consent to our use of cookies.\n
\ndiff --git a/app/controllers/comfy/admin/web_settings_controller.rb b/app/controllers/comfy/admin/web_settings_controller.rb index 49f018b17..65cb560c9 100644 --- a/app/controllers/comfy/admin/web_settings_controller.rb +++ b/app/controllers/comfy/admin/web_settings_controller.rb @@ -46,7 +46,8 @@ def subdomain_params :email_name, :email_signature, :enable_2fa, - :email_notification_strategy + :email_notification_strategy, + :track_email_opens, ) end end \ No newline at end of file diff --git a/app/controllers/mailbox/tracking_controller.rb b/app/controllers/mailbox/tracking_controller.rb new file mode 100644 index 000000000..a34d9c24e --- /dev/null +++ b/app/controllers/mailbox/tracking_controller.rb @@ -0,0 +1,17 @@ +class Mailbox::TrackingController < ApplicationController + def open + emails = params[:emails] + message_id = params[:message_id] + email_uuid = params[:email_uuid] + message = Message.find_by(id: message_id, email_message_id: email_uuid) + ip = request.ip + user_agent = request.user_agent + + if message + message.update(opened: true) + # mark as opened + end + + render json: { status: 200, code: 'OK' } + end +end \ No newline at end of file diff --git a/app/mailers/e_mailer.rb b/app/mailers/e_mailer.rb index f978dabac..d4c6923a7 100755 --- a/app/mailers/e_mailer.rb +++ b/app/mailers/e_mailer.rb @@ -3,6 +3,7 @@ def ship @message = params[:message] @message_thread = params[:message_thread] @subdomain = Subdomain.current + @recipients = @message_thread.recipients @from = if @subdomain.email_name.present? "#{@subdomain.email_name} <#{@subdomain.name}@#{ENV["APP_HOST"]}>" else @@ -30,7 +31,7 @@ def ship mail_settings = { # This will make the mail addresses visible to all (no Blank Carbon Copy) - to: @message_thread.recipients, + to: @recipients, subject: @message_thread.subject, from: @from, message_id: email_message_id(@message) diff --git a/app/views/comfy/admin/web_settings/_form.haml b/app/views/comfy/admin/web_settings/_form.haml index 17362827f..d4b330cf9 100644 --- a/app/views/comfy/admin/web_settings/_form.haml +++ b/app/views/comfy/admin/web_settings/_form.haml @@ -82,10 +82,15 @@ = f.check_box :forum_enabled %label Forum + .form-group + = f.check_box :track_email_opens + %label + Email Tracking .form-group#tracking-checkbox = f.check_box :tracking_enabled %label - Tracking + Web Visit Tracking + .form-group.consent-text = f.label :cookies_consent_ui diff --git a/app/views/e_mailer/ship.html.erb b/app/views/e_mailer/ship.html.erb index f4bf7b249..e4f0c01ed 100644 --- a/app/views/e_mailer/ship.html.erb +++ b/app/views/e_mailer/ship.html.erb @@ -3,6 +3,10 @@
+ <% if @subdomain.track_email_opens %> + <% tracking_link = "#{root_url(subdomain: @subdomain.subdomain_name)}email_tracking/open/?emails=#{@recipients.join(',')}&message_id=#{@message.id}&email_uuid=#{@message.email_message_id}" %> +