FIX: Set first visit PM notification level to group default notification level.
https://meta.discourse.org/t/notifications-not-received-for-private-messages-im-invited-to/71577/21?u=tgxworld
This commit is contained in:
parent
9331b4849d
commit
42e0aaed61
|
@ -194,7 +194,18 @@ SQL
|
|||
notification_type: Notification.types[:invited_to_private_message]
|
||||
).exists?
|
||||
|
||||
attrs[:notification_level] = notification_levels[:watching]
|
||||
group_notification_level = Group
|
||||
.joins("LEFT OUTER JOIN group_users gu ON gu.group_id = groups.id AND gu.user_id = #{user_id}")
|
||||
.joins("LEFT OUTER JOIN topic_allowed_groups tag ON tag.topic_id = #{topic_id}")
|
||||
.where("gu.id IS NOT NULL AND tag.id IS NOT NULL")
|
||||
.pluck(:default_notification_level)
|
||||
.first
|
||||
|
||||
if group_notification_level.present?
|
||||
attrs[:notification_level] = group_notification_level
|
||||
else
|
||||
attrs[:notification_level] = notification_levels[:watching]
|
||||
end
|
||||
else
|
||||
auto_track_after = UserOption.where(user_id: user_id).pluck(:auto_track_topics_after_msecs).first
|
||||
auto_track_after ||= SiteSetting.default_other_auto_track_topics_after_msecs
|
||||
|
|
|
@ -267,6 +267,31 @@ describe TopicUser do
|
|||
expect(TopicUser.get(topic, another_user).notification_level)
|
||||
.to eq(TopicUser.notification_levels[:regular])
|
||||
end
|
||||
|
||||
describe 'inviting a group' do
|
||||
let(:group) do
|
||||
Fabricate(:group,
|
||||
default_notification_level: NotificationLevels.topic_levels[:tracking]
|
||||
)
|
||||
end
|
||||
|
||||
it "should use group's default notification level" do
|
||||
another_user = Fabricate(:user)
|
||||
group.add(another_user)
|
||||
topic.invite_group(target_user, group)
|
||||
TopicUser.track_visit!(topic.id, another_user.id)
|
||||
|
||||
expect(TopicUser.get(topic, another_user).notification_level)
|
||||
.to eq(TopicUser.notification_levels[:tracking])
|
||||
|
||||
another_user = Fabricate(:user)
|
||||
topic.invite(target_user, another_user.username)
|
||||
TopicUser.track_visit!(topic.id, another_user.id)
|
||||
|
||||
expect(TopicUser.get(topic, another_user).notification_level)
|
||||
.to eq(TopicUser.notification_levels[:watching])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'auto tracking' do
|
||||
|
|
Loading…
Reference in New Issue