From 8adcee3f1c0c7d227fb6b11a54aa60a2b7067e78 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 12:31:39 -0500 Subject: [PATCH 01/32] fix: Allow unsafe redirect to external host in notifications controller --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 6e237eed1..6472be36b 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -13,7 +13,7 @@ def show notification.mark_as_read! if (url = notification.to_notification.url) - redirect_to url + redirect_to url, allow_other_host: true else redirect_to notifications_path, notice: t(".notice") end From b1a086403705e652daae73fab67d229115c2b021 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 12:37:19 -0500 Subject: [PATCH 02/32] feat: Enable SSL in Puma configuration for local development --- config/puma.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/puma.rb b/config/puma.rb index 0154f49c5..b098d5a40 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -14,8 +14,12 @@ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" # Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# Uncomment the following lines to enable SSL with mkcert certificates. # -port ENV.fetch("PORT", 3000) +ssl_bind '127.0.0.1', '3000', { + key: "./localhost-key.pem", + cert: "./localhost.pem" +} # Specifies the `environment` that Puma will run in. # From 15f359fa5a497479b18407a8b2db720f1e337af2 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 12:47:21 -0500 Subject: [PATCH 03/32] fix: Update comment to clarify SSL configuration in puma.rb --- config/puma.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/puma.rb b/config/puma.rb index b098d5a40..2188c4229 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -14,7 +14,7 @@ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" # Specifies the `port` that Puma will listen on to receive requests; default is 3000. -# Uncomment the following lines to enable SSL with mkcert certificates. +# Ensure SSL is enabled with mkcert certificates. # ssl_bind '127.0.0.1', '3000', { key: "./localhost-key.pem", From 9b855ddd6ff2fe3b115b409126fe843079c64e9f Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 12:48:39 -0500 Subject: [PATCH 04/32] feat: Configure Puma to use SSL with verify_mode set to none --- config/puma.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/puma.rb b/config/puma.rb index 2188c4229..47ac69446 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -18,7 +18,8 @@ # ssl_bind '127.0.0.1', '3000', { key: "./localhost-key.pem", - cert: "./localhost.pem" + cert: "./localhost.pem", + verify_mode: "none" } # Specifies the `environment` that Puma will run in. From a7989825c1b41f713a8b2f5793360ce5bd1b190a Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 12:49:34 -0500 Subject: [PATCH 05/32] fix: Update Puma SSL binding to 0.0.0.0 on port 3001 --- config/puma.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/puma.rb b/config/puma.rb index 47ac69446..f75cf88cb 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -16,7 +16,7 @@ # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # Ensure SSL is enabled with mkcert certificates. # -ssl_bind '127.0.0.1', '3000', { +ssl_bind '0.0.0.0', '3001', { key: "./localhost-key.pem", cert: "./localhost.pem", verify_mode: "none" From 98440e8845c275d1b92765a7c4621a393cfdef1b Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 12:58:01 -0500 Subject: [PATCH 06/32] feat: Update Procfile.dev to use SSL port 3001 for Rails server --- Procfile.dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile.dev b/Procfile.dev index 79a2c1c01..69c8eebc8 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,4 +1,4 @@ -web: bin/rails server -p 3000 +web: bin/rails server -p 3001 worker: bundle exec sidekiq js: yarn build --watch css: yarn build:css --watch From 292d0771942ca2d3d087cd4aa2a15fb415898d77 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 12:59:17 -0500 Subject: [PATCH 07/32] chore: Update Procfile.dev to enable SSL for the Rails server --- Procfile.dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile.dev b/Procfile.dev index 69c8eebc8..401788ef3 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,4 +1,4 @@ -web: bin/rails server -p 3001 +web: bin/rails server -b 'ssl://0.0.0.0:3001?key=./localhost-key.pem&cert=./localhost.pem' worker: bundle exec sidekiq js: yarn build --watch css: yarn build:css --watch From 0ef10d5e82b6524800c6e315c9e4f78dac880da9 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 13:05:27 -0500 Subject: [PATCH 08/32] fix: Remove allow_other_host option from redirect_to in notifications_controller --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 6472be36b..6e237eed1 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -13,7 +13,7 @@ def show notification.mark_as_read! if (url = notification.to_notification.url) - redirect_to url, allow_other_host: true + redirect_to url else redirect_to notifications_path, notice: t(".notice") end From b1620a3c58075d4c5330dcaf89021808f2921f9e Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 13:07:01 -0500 Subject: [PATCH 09/32] fix: Update default_url_options to use correct host and port for URLs --- app/controllers/concerns/locales.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/concerns/locales.rb b/app/controllers/concerns/locales.rb index 4e6f8d425..aeac84e7f 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: "localhost", port: 3001, protocol: "https"}) end def resolve_locale(locale = I18n.locale) From 86e4494cdb9ef64585be195eea9dc09179030f70 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 13:08:26 -0500 Subject: [PATCH 10/32] fix: Update default_url_options to use request settings for URLs --- app/controllers/concerns/locales.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/concerns/locales.rb b/app/controllers/concerns/locales.rb index aeac84e7f..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, host: "localhost", port: 3001, protocol: "https"}) + options.merge({locale: resolve_locale, host: request.host, port: request.port, protocol: request.protocol}) end def resolve_locale(locale = I18n.locale) From 4839e032ce98f5ca3d022acb96aed283de266a19 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:09:08 -0500 Subject: [PATCH 11/32] fix: Correct URL construction in NotificationsController redirect --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 6e237eed1..53b898464 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -13,7 +13,7 @@ def show notification.mark_as_read! if (url = notification.to_notification.url) - redirect_to url + redirect_to URI.join(request.base_url, url).to_s else redirect_to notifications_path, notice: t(".notice") end From e7a15011674606369e24bf33601d3a7fd5a96bd0 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:10:04 -0500 Subject: [PATCH 12/32] fix: Correct URL construction in NotificationsController redirect logic --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 53b898464..044fb4806 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -13,7 +13,7 @@ def show notification.mark_as_read! if (url = notification.to_notification.url) - redirect_to URI.join(request.base_url, url).to_s + redirect_to URI.join("#{request.protocol}#{request.host_with_port}", url).to_s else redirect_to notifications_path, notice: t(".notice") end From a0927d11c23855126881c5882cf19195daabfb7a Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:10:36 -0500 Subject: [PATCH 13/32] fix: Use correct base URL for redirect in NotificationsController --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 044fb4806..53b898464 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -13,7 +13,7 @@ def show notification.mark_as_read! if (url = notification.to_notification.url) - redirect_to URI.join("#{request.protocol}#{request.host_with_port}", url).to_s + redirect_to URI.join(request.base_url, url).to_s else redirect_to notifications_path, notice: t(".notice") end From 63c3d9e31a2e9f671a6196bb6ecf261c7ed8f264 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:10:47 -0500 Subject: [PATCH 14/32] fix: Correct URL construction for redirection in NotificationsController --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 53b898464..044fb4806 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -13,7 +13,7 @@ def show notification.mark_as_read! if (url = notification.to_notification.url) - redirect_to URI.join(request.base_url, url).to_s + redirect_to URI.join("#{request.protocol}#{request.host_with_port}", url).to_s else redirect_to notifications_path, notice: t(".notice") end From 96bfa659143a39cbbcfc801a85ff0ee0ae7f5b1b Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:11:01 -0500 Subject: [PATCH 15/32] fix: Update URL redirection logic in NotificationsController to use base URL --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 044fb4806..53b898464 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -13,7 +13,7 @@ def show notification.mark_as_read! if (url = notification.to_notification.url) - redirect_to URI.join("#{request.protocol}#{request.host_with_port}", url).to_s + redirect_to URI.join(request.base_url, url).to_s else redirect_to notifications_path, notice: t(".notice") end From 1aa094e7734a157a248c8b7e3fb88e0ff5713ba1 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:11:31 -0500 Subject: [PATCH 16/32] fix: Correct URL construction in NotificationsController redirection logic --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 53b898464..fbf3383c3 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -13,7 +13,7 @@ def show notification.mark_as_read! if (url = notification.to_notification.url) - redirect_to URI.join(request.base_url, url).to_s + redirect_to URI.join("#{request.protocol}//#{request.host_with_port}", url).to_s else redirect_to notifications_path, notice: t(".notice") end From a7956b0d732b1aa7e806de62e4bf69978e2763eb Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:12:00 -0500 Subject: [PATCH 17/32] fix: Ensure redirection only occurs for valid notification URLs --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index fbf3383c3..7f02b7930 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -12,7 +12,7 @@ def show notification = current_user.notifications.find(params[:id]) notification.mark_as_read! - if (url = notification.to_notification.url) + if (url = notification.to_notification.url) && url.start_with?("/notifications") redirect_to URI.join("#{request.protocol}//#{request.host_with_port}", url).to_s else redirect_to notifications_path, notice: t(".notice") From 2b902a047da7244daa9daf9c0b72960e963cafa2 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:12:33 -0500 Subject: [PATCH 18/32] fix: Redirect to specific notification message instead of notifications index --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 7f02b7930..14633f5b8 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -12,7 +12,7 @@ def show notification = current_user.notifications.find(params[:id]) notification.mark_as_read! - if (url = notification.to_notification.url) && url.start_with?("/notifications") + if (url = notification.to_notification.url) && url.include?("/notifications/#{notification.id}") redirect_to URI.join("#{request.protocol}//#{request.host_with_port}", url).to_s else redirect_to notifications_path, notice: t(".notice") From 4b919471f3c56cc336d92d9c9eb195cf1916fa50 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:13:01 -0500 Subject: [PATCH 19/32] fix: Redirect to the correct conversation path in NotificationsController --- app/controllers/notifications_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 14633f5b8..5af5382fa 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -12,8 +12,8 @@ def show notification = current_user.notifications.find(params[:id]) notification.mark_as_read! - if (url = notification.to_notification.url) && url.include?("/notifications/#{notification.id}") - redirect_to URI.join("#{request.protocol}//#{request.host_with_port}", url).to_s + if (conversation_id = notification.to_notification.conversation_id) + redirect_to conversation_path(conversation_id) else redirect_to notifications_path, notice: t(".notice") end From 383f6b3ce4cc083d7a870a07f04d00670ac40242 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:13:24 -0500 Subject: [PATCH 20/32] fix: Resolve undefined method by accessing conversation ID correctly --- app/controllers/notifications_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 5af5382fa..a3ffe3155 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -12,8 +12,8 @@ def show notification = current_user.notifications.find(params[:id]) notification.mark_as_read! - if (conversation_id = notification.to_notification.conversation_id) - redirect_to conversation_path(conversation_id) + if (conversation = notification.to_notification.conversation) + redirect_to conversation_path(conversation.id) else redirect_to notifications_path, notice: t(".notice") end From fbde0765c9cf8481c3ce00eb12f03dd3a460864c Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:46:25 -0500 Subject: [PATCH 21/32] fix: Update Stripe webhook port to match application port 3001 --- Procfile.dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile.dev b/Procfile.dev index 401788ef3..ecb8e49ee 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -3,4 +3,4 @@ worker: bundle exec sidekiq js: yarn build --watch css: yarn build:css --watch redesign: yarn build:redesign --watch -stripe: stripe listen --forward-to localhost:3000/pay/webhooks/stripe +stripe: stripe listen --forward-to localhost:3001/pay/webhooks/stripe From 77450630f88052ade0342bb76a3b231767d2914b Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:52:20 -0500 Subject: [PATCH 22/32] fix: Change application and Stripe webhook ports back to 3000 --- Procfile.dev | 4 ++-- config/puma.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Procfile.dev b/Procfile.dev index ecb8e49ee..69fdfbdd5 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,6 +1,6 @@ -web: bin/rails server -b 'ssl://0.0.0.0:3001?key=./localhost-key.pem&cert=./localhost.pem' +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 redesign: yarn build:redesign --watch -stripe: stripe listen --forward-to localhost:3001/pay/webhooks/stripe +stripe: stripe listen --forward-to localhost:3000/pay/webhooks/stripe diff --git a/config/puma.rb b/config/puma.rb index f75cf88cb..df5b20915 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -16,7 +16,7 @@ # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # Ensure SSL is enabled with mkcert certificates. # -ssl_bind '0.0.0.0', '3001', { +ssl_bind '0.0.0.0', '3000', { key: "./localhost-key.pem", cert: "./localhost.pem", verify_mode: "none" From 892a04c9bf33cbe80cb83b8187cbc1bbcc62d1d2 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:54:17 -0500 Subject: [PATCH 23/32] feat: Add middleware to redirect HTTP traffic to HTTPS in development environment --- config/environments/development.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/environments/development.rb b/config/environments/development.rb index b8d62ce60..bffb66f3c 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.middleware.insert_before 0, Rack::SSL + # 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. From 6578f3791061e3a1d67884010337dcca8046466c Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 14:54:49 -0500 Subject: [PATCH 24/32] fix: Replace Rack::SSL with config.force_ssl in development environment --- config/environments/development.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index bffb66f3c..629ff1c7d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -4,7 +4,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Redirect HTTP to HTTPS - config.middleware.insert_before 0, Rack::SSL + 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 From 5cee0381b3c3f4512ae37bb7243b1ee9f674acd1 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 15:51:26 -0500 Subject: [PATCH 25/32] fix: Handle missing conversation method in NotificationsController --- app/controllers/notifications_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index a3ffe3155..80f30cae2 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -12,8 +12,11 @@ def show notification = current_user.notifications.find(params[:id]) notification.mark_as_read! - if (conversation = notification.to_notification.conversation) + if notification.to_notification.respond_to?(:conversation) + conversation = notification.to_notification.conversation redirect_to conversation_path(conversation.id) + elsif notification.to_notification.respond_to?(:conversation_url) + redirect_to notification.to_notification.conversation_url else redirect_to notifications_path, notice: t(".notice") end From 7cacf40ecabd7cc67099d5217116c85fd6c7fbdc Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 15:51:57 -0500 Subject: [PATCH 26/32] fix: Handle missing conversation ID in notifications redirect logic --- app/controllers/notifications_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 80f30cae2..b51dd99b8 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -14,7 +14,11 @@ def show if notification.to_notification.respond_to?(:conversation) conversation = notification.to_notification.conversation - redirect_to conversation_path(conversation.id) + if conversation.present? && conversation.id.present? + redirect_to conversation_path(conversation.id) + else + redirect_to notifications_path, alert: t(".missing_conversation") + end elsif notification.to_notification.respond_to?(:conversation_url) redirect_to notification.to_notification.conversation_url else From c96ef3609952c86f4e0b9dff2147838efab39969 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 15:52:28 -0500 Subject: [PATCH 27/32] chore: Add logging for conversation redirection in NotificationsController --- app/controllers/notifications_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index b51dd99b8..daa4633b6 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -15,8 +15,10 @@ def show 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.id) else + Rails.logger.error "Missing conversation or conversation ID" redirect_to notifications_path, alert: t(".missing_conversation") end elsif notification.to_notification.respond_to?(:conversation_url) From 6da5e96e817a5fd16d72f1ff5c9b3646058b9787 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 15:52:59 -0500 Subject: [PATCH 28/32] fix: Add logging for missing conversation or conversation ID in notifications controller --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index daa4633b6..65b9c3d82 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -18,7 +18,7 @@ def show Rails.logger.info "Redirecting to conversation with ID: #{conversation.id}" redirect_to conversation_path(conversation.id) else - Rails.logger.error "Missing conversation or conversation ID" + Rails.logger.error "Missing conversation or conversation ID. Notification ID: #{notification.id}, Notification Type: #{notification.to_notification.class.name}" redirect_to notifications_path, alert: t(".missing_conversation") end elsif notification.to_notification.respond_to?(:conversation_url) From a4a8b497ff04a202525926de0d951063e1078130 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 15:53:21 -0500 Subject: [PATCH 29/32] fix: Ensure valid conversation ID before redirecting in NotificationsController --- app/controllers/notifications_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 65b9c3d82..a24a37605 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -16,7 +16,12 @@ def show 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.id) + if conversation.id.present? + redirect_to conversation_path(conversation.id) + else + Rails.logger.error "Conversation ID is missing. Notification ID: #{notification.id}, Notification Type: #{notification.to_notification.class.name}" + redirect_to notifications_path, alert: t(".missing_conversation") + end else Rails.logger.error "Missing conversation or conversation ID. Notification ID: #{notification.id}, Notification Type: #{notification.to_notification.class.name}" redirect_to notifications_path, alert: t(".missing_conversation") From 764f3b9a81c6a7319ac66d6a28f73e05f7f03623 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 15:54:18 -0500 Subject: [PATCH 30/32] fix: Handle missing conversation ID in notifications redirection logic --- app/controllers/notifications_controller.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index a24a37605..65b9c3d82 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -16,12 +16,7 @@ def show conversation = notification.to_notification.conversation if conversation.present? && conversation.id.present? Rails.logger.info "Redirecting to conversation with ID: #{conversation.id}" - if conversation.id.present? - redirect_to conversation_path(conversation.id) - else - Rails.logger.error "Conversation ID is missing. Notification ID: #{notification.id}, Notification Type: #{notification.to_notification.class.name}" - redirect_to notifications_path, alert: t(".missing_conversation") - end + redirect_to conversation_path(conversation.id) else Rails.logger.error "Missing conversation or conversation ID. Notification ID: #{notification.id}, Notification Type: #{notification.to_notification.class.name}" redirect_to notifications_path, alert: t(".missing_conversation") From 7051d38989136909a07aab099dfd6dd867c4d279 Mon Sep 17 00:00:00 2001 From: "Matt (aider)" Date: Sat, 16 Nov 2024 15:55:13 -0500 Subject: [PATCH 31/32] fix: Ensure locale is set for conversation path redirection in notifications controller --- app/controllers/notifications_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 65b9c3d82..5d7125af5 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -16,15 +16,15 @@ def show 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.id) + redirect_to conversation_path(conversation.id, 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, alert: t(".missing_conversation") + redirect_to notifications_path(locale: I18n.locale), alert: t(".missing_conversation") end elsif notification.to_notification.respond_to?(:conversation_url) redirect_to notification.to_notification.conversation_url else - redirect_to notifications_path, notice: t(".notice") + redirect_to notifications_path(locale: I18n.locale), notice: t(".notice") end end end From d22266db3f0edcdf6e92c29028ae343604e0fa1a Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 18 Nov 2024 10:36:57 -0500 Subject: [PATCH 32/32] Fixed some issues with admin notifications --- app/controllers/notifications_controller.rb | 6 +++--- app/notifications/admin/new_conversation_notification.rb | 2 +- app/notifications/admin/subscription_change_notification.rb | 2 +- app/notifications/new_message_notification.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 5d7125af5..e5987f2f5 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -16,13 +16,13 @@ def show 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.id, locale: I18n.locale) + 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?(:conversation_url) - redirect_to notification.to_notification.conversation_url + elsif notification.to_notification.respond_to?(:url) + redirect_to notification.to_notification.url else redirect_to notifications_path(locale: I18n.locale), notice: t(".notice") 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