diff --git a/Procfile.dev b/Procfile.dev index 79a2c1c01..69fdfbdd5 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,4 +1,4 @@ -web: bin/rails server -p 3000 +web: bin/rails server -b 'ssl://0.0.0.0:3000?key=./localhost-key.pem&cert=./localhost.pem' worker: bundle exec sidekiq js: yarn build --watch css: yarn build:css --watch diff --git a/app/controllers/concerns/locales.rb b/app/controllers/concerns/locales.rb index 4e6f8d425..9dd7eea81 100644 --- a/app/controllers/concerns/locales.rb +++ b/app/controllers/concerns/locales.rb @@ -15,7 +15,7 @@ def set_locale(&action) end def default_url_options(options = {}) - options.merge({locale: resolve_locale}) + options.merge({locale: resolve_locale, host: request.host, port: request.port, protocol: request.protocol}) end def resolve_locale(locale = I18n.locale) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 6e237eed1..e5987f2f5 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -12,10 +12,19 @@ def show notification = current_user.notifications.find(params[:id]) notification.mark_as_read! - if (url = notification.to_notification.url) - redirect_to url + if notification.to_notification.respond_to?(:conversation) + conversation = notification.to_notification.conversation + if conversation.present? && conversation.id.present? + Rails.logger.info "Redirecting to conversation with ID: #{conversation.id}" + redirect_to conversation_path(conversation, locale: I18n.locale) + else + Rails.logger.error "Missing conversation or conversation ID. Notification ID: #{notification.id}, Notification Type: #{notification.to_notification.class.name}" + redirect_to notifications_path(locale: I18n.locale), alert: t(".missing_conversation") + end + elsif notification.to_notification.respond_to?(:url) + redirect_to notification.to_notification.url else - redirect_to notifications_path, notice: t(".notice") + redirect_to notifications_path(locale: I18n.locale), notice: t(".notice") end end end diff --git a/app/notifications/admin/new_conversation_notification.rb b/app/notifications/admin/new_conversation_notification.rb index 3398a2b0d..2f4f61709 100644 --- a/app/notifications/admin/new_conversation_notification.rb +++ b/app/notifications/admin/new_conversation_notification.rb @@ -17,7 +17,7 @@ def email_subject end def url - conversation_url(conversation) + conversation_url(conversation, locale: I18n.locale) end def conversation diff --git a/app/notifications/admin/subscription_change_notification.rb b/app/notifications/admin/subscription_change_notification.rb index 9209754a0..2a1e2c167 100644 --- a/app/notifications/admin/subscription_change_notification.rb +++ b/app/notifications/admin/subscription_change_notification.rb @@ -35,7 +35,7 @@ def plan end def url - admin_business_conversations_url(business) + admin_business_conversations_url(business, locale: I18n.locale) end def business diff --git a/app/notifications/new_message_notification.rb b/app/notifications/new_message_notification.rb index 1bdd07ee7..348ce2a18 100644 --- a/app/notifications/new_message_notification.rb +++ b/app/notifications/new_message_notification.rb @@ -20,7 +20,7 @@ def ios_subject end def url - conversation_url(conversation) + conversation_url(conversation, locale: I18n.locale) end def message diff --git a/config/environments/development.rb b/config/environments/development.rb index b8d62ce60..629ff1c7d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -3,6 +3,9 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # Redirect HTTP to HTTPS + config.force_ssl = true + # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. diff --git a/config/puma.rb b/config/puma.rb index 0154f49c5..df5b20915 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -14,8 +14,13 @@ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" # Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# Ensure SSL is enabled with mkcert certificates. # -port ENV.fetch("PORT", 3000) +ssl_bind '0.0.0.0', '3000', { + key: "./localhost-key.pem", + cert: "./localhost.pem", + verify_mode: "none" +} # Specifies the `environment` that Puma will run in. #