mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: when a post is moved copy notifications level (#9311)
This is a revert of 2c011252f1
More information on meta: https://meta.discourse.org/t/when-a-reply-is-moved-to-a-new-topic-the-followers-of-the-previous-topic-are-automatically-follower-of-the-new-topic-as-well/130025
This commit is contained in:
committed by
GitHub
parent
6d3d9ecf6c
commit
a0f59a55cc
@@ -332,8 +332,7 @@ class PostMover
|
|||||||
old_topic_id: original_topic.id,
|
old_topic_id: original_topic.id,
|
||||||
new_topic_id: destination_topic.id,
|
new_topic_id: destination_topic.id,
|
||||||
old_highest_post_number: destination_topic.highest_post_number,
|
old_highest_post_number: destination_topic.highest_post_number,
|
||||||
old_highest_staff_post_number: destination_topic.highest_staff_post_number,
|
old_highest_staff_post_number: destination_topic.highest_staff_post_number
|
||||||
default_notification_level: NotificationLevels.topic_levels[:regular]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DB.exec(<<~SQL, params)
|
DB.exec(<<~SQL, params)
|
||||||
@@ -342,9 +341,13 @@ class PostMover
|
|||||||
notifications_changed_at, notifications_reason_id)
|
notifications_changed_at, notifications_reason_id)
|
||||||
SELECT tu.user_id,
|
SELECT tu.user_id,
|
||||||
:new_topic_id AS topic_id,
|
:new_topic_id AS topic_id,
|
||||||
CASE
|
EXISTS(
|
||||||
WHEN p.user_id IS NULL THEN FALSE
|
SELECT 1
|
||||||
ELSE TRUE END AS posted,
|
FROM posts p
|
||||||
|
WHERE p.topic_id = :new_topic_id
|
||||||
|
AND p.user_id = tu.user_id
|
||||||
|
LIMIT 1
|
||||||
|
) AS posted,
|
||||||
(
|
(
|
||||||
SELECT MAX(lr.new_post_number)
|
SELECT MAX(lr.new_post_number)
|
||||||
FROM moved_posts lr
|
FROM moved_posts lr
|
||||||
@@ -365,19 +368,11 @@ class PostMover
|
|||||||
) AS last_emailed_post_number,
|
) AS last_emailed_post_number,
|
||||||
GREATEST(tu.first_visited_at, t.created_at) AS first_visited_at,
|
GREATEST(tu.first_visited_at, t.created_at) AS first_visited_at,
|
||||||
GREATEST(tu.last_visited_at, t.created_at) AS last_visited_at,
|
GREATEST(tu.last_visited_at, t.created_at) AS last_visited_at,
|
||||||
CASE
|
tu.notification_level,
|
||||||
WHEN p.user_id IS NOT NULL THEN tu.notification_level
|
|
||||||
ELSE :default_notification_level END AS notification_level,
|
|
||||||
tu.notifications_changed_at,
|
tu.notifications_changed_at,
|
||||||
tu.notifications_reason_id
|
tu.notifications_reason_id
|
||||||
FROM topic_users tu
|
FROM topic_users tu
|
||||||
JOIN topics t ON (t.id = :new_topic_id)
|
JOIN topics t ON (t.id = :new_topic_id)
|
||||||
LEFT OUTER JOIN
|
|
||||||
(
|
|
||||||
SELECT DISTINCT user_id
|
|
||||||
FROM posts
|
|
||||||
WHERE topic_id = :new_topic_id
|
|
||||||
) p ON (p.user_id = tu.user_id)
|
|
||||||
WHERE tu.topic_id = :old_topic_id
|
WHERE tu.topic_id = :old_topic_id
|
||||||
AND GREATEST(
|
AND GREATEST(
|
||||||
tu.last_read_post_number,
|
tu.last_read_post_number,
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ describe PostMover do
|
|||||||
last_read_post_number: 2,
|
last_read_post_number: 2,
|
||||||
highest_seen_post_number: 2,
|
highest_seen_post_number: 2,
|
||||||
last_emailed_post_number: 2,
|
last_emailed_post_number: 2,
|
||||||
notification_level: TopicUser.notification_levels[:regular],
|
notification_level: TopicUser.notification_levels[:tracking],
|
||||||
posted: false
|
posted: false
|
||||||
)
|
)
|
||||||
expect(TopicUser.find_by(topic: new_topic, user: user2))
|
expect(TopicUser.find_by(topic: new_topic, user: user2))
|
||||||
@@ -486,7 +486,7 @@ describe PostMover do
|
|||||||
last_read_post_number: 1,
|
last_read_post_number: 1,
|
||||||
highest_seen_post_number: 2,
|
highest_seen_post_number: 2,
|
||||||
last_emailed_post_number: 2,
|
last_emailed_post_number: 2,
|
||||||
notification_level: TopicUser.notification_levels[:regular],
|
notification_level: TopicUser.notification_levels[:watching],
|
||||||
posted: false
|
posted: false
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user