FEATURE: Publish read topic tracking events for private messages. (#14274)

Follow-up to fc1fd1b41689694b3916dc4e10605eb9b8bb89b7
This commit is contained in:
Alan Guo Xiang Tan
2021-09-09 09:16:53 +08:00
committed by GitHub
parent 1e05175364
commit 412587f70a
8 changed files with 242 additions and 100 deletions

View File

@ -226,7 +226,14 @@ describe TopicUser do
freeze_time tomorrow
Fabricate(:post, topic: topic, user: user)
TopicUser.update_last_read(user, topic.id, 2, 1, 0)
channel = TopicTrackingState.unread_channel_key(user.id)
messages = MessageBus.track_publish(channel) do
TopicUser.update_last_read(user, topic.id, 2, 1, 0)
end
expect(messages.blank?).to eq(false)
topic_user = TopicUser.get(topic, user)
expect(topic_user.last_read_post_number).to eq(2)
@ -270,6 +277,20 @@ describe TopicUser do
.to eq(TopicUser.notification_levels[:regular])
end
it 'should publish the right message_bus message' do
TopicUser.update_last_read(user, topic.id, 1, 1, 0)
Fabricate(:post, topic: topic, user: user)
channel = PrivateMessageTopicTrackingState.user_channel(user.id)
messages = MessageBus.track_publish(channel) do
TopicUser.update_last_read(user, topic.id, 2, 1, 0)
end
expect(messages.blank?).to eq(false)
end
describe 'inviting a group' do
let(:group) do
Fabricate(:group,