FEATURE: Publish everyone's status to everyone (#17343)
This commit is contained in:
parent
7d3b22135c
commit
ef923f1bb1
|
@ -116,8 +116,8 @@ export default {
|
|||
user.updateDoNotDisturbStatus(data.ends_at);
|
||||
});
|
||||
|
||||
bus.subscribe(`/user-status/${user.id}`, (data) => {
|
||||
appEvents.trigger("current-user-status:changed", data);
|
||||
bus.subscribe(`/user-status`, (data) => {
|
||||
appEvents.trigger("user-status:changed", data);
|
||||
});
|
||||
|
||||
const site = container.lookup("site:main");
|
||||
|
|
|
@ -1185,13 +1185,7 @@ User.reopen(Evented, {
|
|||
trackStatus() {
|
||||
this.addObserver("status", this, "_statusChanged");
|
||||
|
||||
if (this.isCurrent) {
|
||||
this.appEvents.on(
|
||||
"current-user-status:changed",
|
||||
this,
|
||||
this._updateStatus
|
||||
);
|
||||
}
|
||||
this.appEvents.on("user-status:changed", this, this._updateStatus);
|
||||
|
||||
if (this.status && this.status.ends_at) {
|
||||
this._scheduleStatusClearing(this.status.ends_at);
|
||||
|
@ -1200,13 +1194,7 @@ User.reopen(Evented, {
|
|||
|
||||
stopTrackingStatus() {
|
||||
this.removeObserver("status", this, "_statusChanged");
|
||||
if (this.isCurrent) {
|
||||
this.appEvents.off(
|
||||
"current-user-status:changed",
|
||||
this,
|
||||
this._updateStatus
|
||||
);
|
||||
}
|
||||
this.appEvents.off("user-status:changed", this, this._updateStatus);
|
||||
this._unscheduleStatusClearing();
|
||||
},
|
||||
|
||||
|
@ -1244,8 +1232,8 @@ User.reopen(Evented, {
|
|||
this.set("status", null);
|
||||
},
|
||||
|
||||
_updateStatus(status) {
|
||||
this.set("status", status);
|
||||
_updateStatus(statuses) {
|
||||
this.set("status", statuses[this.id]);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -676,7 +676,7 @@ class User < ActiveRecord::Base
|
|||
payload = nil
|
||||
end
|
||||
|
||||
MessageBus.publish("/user-status/#{id}", payload, user_ids: [id])
|
||||
MessageBus.publish("/user-status", { id => payload }, group_ids: [Group::AUTO_GROUPS[:trust_level_0]])
|
||||
end
|
||||
|
||||
def password=(password)
|
||||
|
|
|
@ -98,12 +98,12 @@ describe UserStatusController do
|
|||
end
|
||||
|
||||
expect(messages.size).to eq(1)
|
||||
expect(messages[0].channel).to eq("/user-status/#{user.id}")
|
||||
expect(messages[0].user_ids).to eq([user.id])
|
||||
expect(messages[0].channel).to eq("/user-status")
|
||||
expect(messages[0].group_ids).to eq([Group::AUTO_GROUPS[:trust_level_0]])
|
||||
|
||||
expect(messages[0].data[:description]).to eq(status)
|
||||
expect(messages[0].data[:emoji]).to eq(emoji)
|
||||
expect(messages[0].data[:ends_at]).to eq(ends_at)
|
||||
expect(messages[0].data[user.id][:description]).to eq(status)
|
||||
expect(messages[0].data[user.id][:emoji]).to eq(emoji)
|
||||
expect(messages[0].data[user.id][:ends_at]).to eq(ends_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -145,9 +145,10 @@ describe UserStatusController do
|
|||
messages = MessageBus.track_publish { delete "/user-status.json" }
|
||||
|
||||
expect(messages.size).to eq(1)
|
||||
expect(messages[0].channel).to eq("/user-status/#{user.id}")
|
||||
expect(messages[0].data).to eq(nil)
|
||||
expect(messages[0].user_ids).to eq([user.id])
|
||||
expect(messages[0].channel).to eq("/user-status")
|
||||
expect(messages[0].group_ids).to eq([Group::AUTO_GROUPS[:trust_level_0]])
|
||||
|
||||
expect(messages[0].data[user.id]).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue