mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: invited staged users would sometimes not get notified of replies
This commit is contained in:
@@ -692,7 +692,7 @@ module Email
|
||||
if result.post
|
||||
@incoming_email.update_columns(topic_id: result.post.topic_id, post_id: result.post.id)
|
||||
if result.post.topic && result.post.topic.private_message?
|
||||
add_other_addresses(result.post.topic, user)
|
||||
add_other_addresses(result.post, user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -707,7 +707,7 @@ module Email
|
||||
html
|
||||
end
|
||||
|
||||
def add_other_addresses(topic, sender)
|
||||
def add_other_addresses(post, sender)
|
||||
%i(to cc bcc).each do |d|
|
||||
if @mail[d] && @mail[d].address_list && @mail[d].address_list.addresses
|
||||
@mail[d].address_list.addresses.each do |address_field|
|
||||
@@ -718,13 +718,14 @@ module Email
|
||||
next unless email["@"]
|
||||
if should_invite?(email)
|
||||
user = find_or_create_user(email, display_name)
|
||||
if user && can_invite?(topic, user)
|
||||
topic.topic_allowed_users.create!(user_id: user.id)
|
||||
topic.add_small_action(sender, "invited_user", user.username)
|
||||
if user && can_invite?(post.topic, user)
|
||||
post.topic.topic_allowed_users.create!(user_id: user.id)
|
||||
TopicUser.auto_notification_for_staging(user.id, post.topic_id, TopicUser.notification_reasons[:auto_watch])
|
||||
post.topic.add_small_action(sender, "invited_user", user.username)
|
||||
end
|
||||
# cap number of staged users created per email
|
||||
if @staged_users.count > SiteSetting.maximum_staged_users_per_email
|
||||
topic.add_moderator_post(sender, I18n.t("emails.incoming.maximum_staged_user_per_email_reached"))
|
||||
post.topic.add_moderator_post(sender, I18n.t("emails.incoming.maximum_staged_user_per_email_reached"))
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@@ -508,12 +508,9 @@ class PostCreator
|
||||
|
||||
if @user.staged
|
||||
TopicUser.auto_notification_for_staging(@user.id, @topic.id, TopicUser.notification_reasons[:auto_watch])
|
||||
elsif @user.user_option.notification_level_when_replying === NotificationLevels.topic_levels[:watching]
|
||||
TopicUser.auto_notification(@user.id, @topic.id, TopicUser.notification_reasons[:created_post], NotificationLevels.topic_levels[:watching])
|
||||
elsif @user.user_option.notification_level_when_replying === NotificationLevels.topic_levels[:regular]
|
||||
TopicUser.auto_notification(@user.id, @topic.id, TopicUser.notification_reasons[:created_post], NotificationLevels.topic_levels[:regular])
|
||||
else
|
||||
TopicUser.auto_notification(@user.id, @topic.id, TopicUser.notification_reasons[:created_post], NotificationLevels.topic_levels[:tracking])
|
||||
notification_level = @user.user_option.notification_level_when_replying || NotificationLevels.topic_levels[:tracking]
|
||||
TopicUser.auto_notification(@user.id, @topic.id, TopicUser.notification_reasons[:created_post], notification_level)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user