mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 21:42:46 +08:00
FIX: Unsubscribing via key associated with deleted topic (#20275)
Currently, clicking on the unsubscribe link with a `key` associated with a deleted topic results in an HTTP 500 response. This change fixes that by skipping any attempt to run topic related flow if topic isn't present.
This commit is contained in:
parent
9704d9aed6
commit
5a6e5a4012
|
@ -8,6 +8,8 @@ module EmailControllerHelper
|
||||||
|
|
||||||
topic = unsubscribe_key.associated_topic
|
topic = unsubscribe_key.associated_topic
|
||||||
|
|
||||||
|
return if topic.blank?
|
||||||
|
|
||||||
controller.instance_variable_set(:@topic, topic)
|
controller.instance_variable_set(:@topic, topic)
|
||||||
controller.instance_variable_set(
|
controller.instance_variable_set(
|
||||||
:@watching_topic,
|
:@watching_topic,
|
||||||
|
|
|
@ -317,6 +317,15 @@ RSpec.describe EmailController do
|
||||||
expect(response.body).not_to include("unwatch_category")
|
expect(response.body).not_to include("unwatch_category")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "displays form even if topic is deleted" do
|
||||||
|
post.topic.trash!
|
||||||
|
|
||||||
|
navigate_to_unsubscribe
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
expect(response.body).to include(I18n.t("unsubscribe.all", sitename: SiteSetting.title))
|
||||||
|
end
|
||||||
|
|
||||||
def create_category_user(notification_level)
|
def create_category_user(notification_level)
|
||||||
CategoryUser.create!(
|
CategoryUser.create!(
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user