mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 04:59:22 -06:00
20e7fb1c95
Regression was created here: https://github.com/discourse/discourse/pull/8750 When tag or category is added and the user is watching that category/tag we changed notification type to `edited` instead of `new post`. However, the logic here should be a little bit more sophisticated. If the user has already seen the post, notification should be `edited`. However, when user hasn't yet seen post, notification should be "new reply". The case for that is when for example topic is under private category and set for publishing later. In that case, we modify an existing topic, however, for a user, it is like a new post. Discussion on meta: https://meta.discourse.org/t/publication-of-timed-topics-dont-trigger-new-topic-notifications/139335/13
16 lines
468 B
Ruby
16 lines
468 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class NotifyCategoryChange < ::Jobs::Base
|
|
def execute(args)
|
|
post = Post.find_by(id: args[:post_id])
|
|
|
|
if post&.topic&.visible?
|
|
post_alerter = PostAlerter.new
|
|
post_alerter.notify_post_users(post, User.where(id: args[:notified_user_ids]), include_tag_watchers: false)
|
|
post_alerter.notify_first_post_watchers(post, post_alerter.category_watchers(post.topic))
|
|
end
|
|
end
|
|
end
|
|
end
|