DEV: removes dead code (message_link) (#24648)

Linking to a message ID is now handled by the frontend router: `chat.channel.near-message`
This commit is contained in:
Joffrey JAFFEUX 2023-11-30 11:13:37 +01:00 committed by GitHub
parent 0b65aa8b77
commit a1690e0401
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 54 deletions

View File

@ -5,9 +5,9 @@ module Chat
# Other endpoints use set_channel_and_chatable_with_access_check, but
# these endpoints require a standalone find because they need to be
# able to get deleted channels and recover them.
before_action :find_chat_message, only: %i[rebake message_link]
before_action :find_chat_message, only: %i[rebake]
before_action :set_channel_and_chatable_with_access_check,
except: %i[respond message_link set_user_chat_status dismiss_retention_reminder]
except: %i[respond set_user_chat_status dismiss_retention_reminder]
def respond
render
@ -32,17 +32,6 @@ module Chat
render json: success_json
end
def message_link
raise Discourse::NotFound if @message.blank? || @message.deleted_at.present?
raise Discourse::NotFound if @message.chat_channel.blank?
set_channel_and_chatable_with_access_check(chat_channel_id: @message.chat_channel_id)
render json:
success_json.merge(
chat_channel_id: @chat_channel.id,
chat_channel_title: @chat_channel.title(current_user),
)
end
def set_user_chat_status
params.require(:chat_enabled)

View File

@ -1,28 +0,0 @@
import { inject as service } from "@ember/service";
import { ajax } from "discourse/lib/ajax";
import { defaultHomepage } from "discourse/lib/utilities";
import DiscourseRoute from "discourse/routes/discourse";
export default class ChatMessageRoute extends DiscourseRoute {
@service chat;
@service router;
async model(params) {
return ajax(`/chat/message/${params.messageId}.json`)
.then((response) => {
this.router.transitionTo(
"chat.channel.near-message",
response.chat_channel_title,
response.chat_channel_id,
params.messageId
);
})
.catch(() => this.router.replaceWith("/404"));
}
beforeModel() {
if (!this.chat.userCanChat) {
return this.router.transitionTo(`discovery.${defaultHomepage()}`);
}
}
}

View File

@ -78,7 +78,6 @@ Chat::Engine.routes.draw do
get "/browse/open" => "chat#respond"
get "/browse/archived" => "chat#respond"
post "/dismiss-retention-reminder" => "chat#dismiss_retention_reminder"
get "/message/:message_id" => "chat#message_link"
put ":chat_channel_id/react/:message_id" => "chat#react"
put "/:chat_channel_id/:message_id/rebake" => "chat#rebake"
post "/:chat_channel_id/quote" => "chat#quote_messages"

View File

@ -453,16 +453,4 @@ RSpec.describe Chat::ChatController do
EXPECTED
end
end
describe "#message_link" do
it "ensures message's channel can be seen" do
channel = Fabricate(:category_channel, chatable: Fabricate(:category))
message = Fabricate(:chat_message, chat_channel: channel)
Guardian.any_instance.expects(:can_join_chat_channel?).with(channel)
sign_in(Fabricate(:user))
get "/chat/message/#{message.id}.json"
end
end
end