diff --git a/CHANGELOG.md b/CHANGELOG.md index ff22b3b2..45fec71b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -# 0.25.5 - 2025-04-13 +# 0.25.5 - 2025-04-15 ## Removed @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `rake points:migrate_to_lonlat` task now also tries to extract latitude and longitude from `raw_data` column before using `longitude` and `latitude` columns to fill `lonlat` column. - Docker entrypoints are now using `DATABASE_NAME` environment variable to check if Postgres is existing/available. +## Added + +- You can now provide SMTP settings in ENV vars to send emails. + # 0.25.4 - 2025-04-02 diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index d409087c..f77c7a54 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -2,6 +2,8 @@ class HomeController < ApplicationController def index + # redirect_to 'https://dawarich.app', allow_other_host: true and return unless SELF_HOSTED + redirect_to map_url if current_user @points = current_user.tracked_points.without_raw_data if current_user diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 3c34c814..071c3510 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,6 @@ +# frozen_string_literal: true + class ApplicationMailer < ActionMailer::Base - default from: "from@example.com" - layout "mailer" + default from: ENV['SMTP_FROM'] + layout 'mailer' end diff --git a/app/services/points/raw_data_lonlat_extractor.rb b/app/services/points/raw_data_lonlat_extractor.rb index 81071976..b14b086a 100644 --- a/app/services/points/raw_data_lonlat_extractor.rb +++ b/app/services/points/raw_data_lonlat_extractor.rb @@ -18,7 +18,7 @@ class Points::RawDataLonlatExtractor # rubocop:disable Metrics/MethodLength def extract_lonlat(point) - if point.raw_data['activitySegment']['waypointPath']['waypoints'][0] + if point.raw_data.dig('activitySegment', 'waypointPath', 'waypoints', 0) # google_semantic_history_parser [ point.raw_data['activitySegment']['waypointPath']['waypoints'][0]['lngE7'].to_f / 10**7, @@ -30,7 +30,7 @@ class Points::RawDataLonlatExtractor point.raw_data['longitudeE7'].to_f / 10**7, point.raw_data['latitudeE7'].to_f / 10**7 ] - elsif point.raw_data['position']['LatLng'] + elsif point.raw_data.dig('position', 'LatLng') # google phone export raw_coordinates = point.raw_data['position']['LatLng'] if raw_coordinates.include?('°') @@ -41,7 +41,7 @@ class Points::RawDataLonlatExtractor elsif point.raw_data['lon'] && point.raw_data['lat'] # gpx_track_importer, owntracks [point.raw_data['lon'], point.raw_data['lat']] - elsif point.raw_data['geometry']['coordinates'][0] && point.raw_data['geometry']['coordinates'][1] + elsif point.raw_data.dig('geometry', 'coordinates', 0) && point.raw_data.dig('geometry', 'coordinates', 1) # geojson [ point.raw_data['geometry']['coordinates'][0], diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb index 5d5296b6..c968119a 100644 --- a/app/views/devise/shared/_links.html.erb +++ b/app/views/devise/shared/_links.html.erb @@ -5,7 +5,7 @@ <% end %> - <% if !SELF_HOSTED && devise_mapping&.registerable? && controller_name != 'registrations' %> + <% if !SELF_HOSTED && defined?(devise_mapping) && devise_mapping&.registerable? && controller_name != 'registrations' %>
<%= link_to "Register", new_registration_path(resource_name) %>
diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb index 085cbd74..9ec36f26 100644 --- a/app/views/shared/_navbar.html.erb +++ b/app/views/shared/_navbar.html.erb @@ -126,7 +126,7 @@ <% else %>
  • <%= link_to 'Login', new_user_session_path %>
  • - <% if !SELF_HOSTED && devise_mapping&.registerable? %> + <% if !SELF_HOSTED && defined?(devise_mapping) && devise_mapping&.registerable? %>
  • <%= link_to 'Register', new_user_registration_path %>
  • <% end %> <% end %> diff --git a/config/environments/production.rb b/config/environments/production.rb index 947c8e4e..a5487d47 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -107,4 +107,17 @@ Rails.application.configure do config.action_mailer.default_url_options = { host: hosts.first, port: 3000 } config.hosts.concat(hosts) if hosts.present? + + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: ENV['SMTP_SERVER'], + port: ENV['SMTP_PORT'], + domain: ENV['SMTP_DOMAIN'], + user_name: ENV['SMTP_USERNAME'], + password: ENV['SMTP_PASSWORD'], + authentication: 'plain', + enable_starttls: true, + open_timeout: 5, + read_timeout: 5 + } end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 06f98338..05def9ab 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -24,7 +24,7 @@ Devise.setup do |config| # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' + config.mailer_sender = ENV['SMTP_FROM'] # Configure the class responsible to send e-mails. # config.mailer = 'Devise::Mailer'