mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 08:16:00 +08:00
DEV: Centralize user updates to a single MessageBus channel. (#17058)
Introduces an interface to publish user updates on the server side and helps to reduce the growing number of subscriptions on the client side.
This commit is contained in:

committed by
GitHub

parent
bd32656157
commit
94c3bbc2d1
@ -143,12 +143,14 @@ describe UserNotificationScheduleProcessor do
|
||||
user.user_option.update(timezone: "UTC")
|
||||
schedule = standard_schedule
|
||||
travel_to Time.new(2020, 12, 31, 1, 0, 0, "+00:00") do
|
||||
MessageBus.expects(:publish).with(
|
||||
"/do-not-disturb/#{user.id}",
|
||||
{ ends_at: Time.new(2020, 12, 31, 7, 59, 0, "+00:00").httpdate },
|
||||
user_ids: [user.id]
|
||||
)
|
||||
UserNotificationScheduleProcessor.create_do_not_disturb_timings_for(schedule)
|
||||
messages = MessageBus.track_publish(User.publish_updates_channel(user.id)) do
|
||||
UserNotificationScheduleProcessor.create_do_not_disturb_timings_for(schedule)
|
||||
end
|
||||
|
||||
expect(messages.size).to eq(1)
|
||||
expect(messages[0].data[:type]).to eq(User::PUBLISH_DO_NOT_STATUS_TYPE)
|
||||
expect(messages[0].data[:payload][:ends_at]).to eq(Time.new(2020, 12, 31, 7, 59, 0, "+00:00").httpdate)
|
||||
expect(messages[0].user_ids).to contain_exactly(user.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user