From 0be0bcfc7dcc8fcdc4a2675244696c7cb1639794 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Thu, 20 Oct 2022 16:24:56 +0300 Subject: [PATCH] FIX: Do not show a 404 page when visiting messages (#18652) * DEV: Use list controller and action It used an empty action handler which just returned the app and it required another request to get the topic list. By using the correct controller and action we can preload the topic list. --- config/routes.rb | 2 +- spec/requests/list_controller_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 0092fec3f0..27d7f27b6e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -478,7 +478,7 @@ Discourse::Application.routes.draw do get "#{root_path}/:username/messages/:filter" => "user_actions#private_messages", constraints: { username: RouteFormat.username } get "#{root_path}/:username/messages/group/:group_name" => "user_actions#private_messages", constraints: { username: RouteFormat.username, group_name: RouteFormat.username } get "#{root_path}/:username/messages/group/:group_name/:filter" => "user_actions#private_messages", constraints: { username: RouteFormat.username, group_name: RouteFormat.username } - get "#{root_path}/:username/messages/tags/:tag_id" => "user_actions#private_messages", constraints: StaffConstraint.new + get "#{root_path}/:username/messages/tags/:tag_id" => "list#private_messages_tag", constraints: { username: RouteFormat.username } get "#{root_path}/:username.json" => "users#show", constraints: { username: RouteFormat.username }, defaults: { format: :json } get({ "#{root_path}/:username" => "users#show", constraints: { username: RouteFormat.username } }.merge(index == 1 ? { as: 'user' } : {})) put "#{root_path}/:username" => "users#update", constraints: { username: RouteFormat.username }, defaults: { format: :json } diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rb index 46a80983c1..7b08772566 100644 --- a/spec/requests/list_controller_spec.rb +++ b/spec/requests/list_controller_spec.rb @@ -186,6 +186,16 @@ RSpec.describe ListController do expect(response.parsed_body["topic_list"]["topics"].first["id"]) .to eq(private_message.id) end + + it 'should work for users who are allowed and direct links' do + SiteSetting.pm_tags_allowed_for_groups = group.name + group.add(user) + sign_in(user) + + get "/u/#{user.username}/messages/tags/#{tag.name}" + + expect(response.status).to eq(200) + end end describe '#private_messages_group' do