mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 02:34:28 +08:00
FEATURE: Publish read topic tracking events for private messages. (#14274)
Follow-up to fc1fd1b41689694b3916dc4e10605eb9b8bb89b7
This commit is contained in:

committed by
GitHub

parent
1e05175364
commit
412587f70a
@ -203,4 +203,22 @@ describe PrivateMessageTopicTrackingState do
|
||||
expect(data['payload']['group_ids']).to contain_exactly(group.id)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.publish_read' do
|
||||
it 'should publish the right message_bus message' do
|
||||
message = MessageBus.track_publish(described_class.user_channel(user.id)) do
|
||||
PrivateMessageTopicTrackingState.publish_read(private_message.id, 1, user)
|
||||
end.first
|
||||
|
||||
data = message.data
|
||||
|
||||
expect(message.user_ids).to contain_exactly(user.id)
|
||||
expect(message.group_ids).to eq(nil)
|
||||
expect(data["topic_id"]).to eq(private_message.id)
|
||||
expect(data["message_type"]).to eq(described_class::READ_MESSAGE_TYPE)
|
||||
expect(data["payload"]["last_read_post_number"]).to eq(1)
|
||||
expect(data["payload"]["highest_post_number"]).to eq(1)
|
||||
expect(data["payload"]["notification_level"]).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user