A platform for community discussion. Free, open, simple.
DEV: Rename discourse-presence endpoints and messagebus channels (#14089)
David Taylor5eb4e642a6c5
diff --git a/plugins/discourse-presence/assets/javascripts/discourse/lib/presence.js.es6 b/plugins/discourse-presence/assets/javascripts/discourse/lib/presence.js.es6index 2146ce582a8..7db5048f674 100644--- a/plugins/discourse-presence/assets/javascripts/discourse/lib/presence.js.es6+++ b/plugins/discourse-presence/assets/javascripts/discourse/lib/presence.js.es6@@ -98,7 +98,7 @@ const Presence = EmberObject.extend({@discourseComputed("topicId")channel(topicId) {- return `/presence/${topicId}`;+ return `/presence-plugin/${topicId}`;},publish(state, whisper, postId, staffOnly) {@@ -134,7 +134,7 @@ const Presence = EmberObject.extend({data.staff_only = true;}- return ajax("/presence/publish", {+ return ajax("/presence-plugin/publish", {type: "POST",data,});diff --git a/plugins/discourse-presence/plugin.rb b/plugins/discourse-presence/plugin.rbindex a61d97ee806..d20f4a2b1d3 100644--- a/plugins/discourse-presence/plugin.rb+++ b/plugins/discourse-presence/plugin.rb@@ -15,7 +15,7 @@ PLUGIN_NAME ||= -"discourse-presence"after_initialize do- MessageBus.register_client_message_filter('/presence/') do |message|+ MessageBus.register_client_message_filter('/presence-plugin/') do |message|published_at = message.data["published_at"]if published_at@@ -146,7 +146,7 @@ after_initialize dopayload[:post_id] = post_idend- MessageBus.publish("/presence/#{topic_id}", payload, opts)+ MessageBus.publish("/presence-plugin/#{topic_id}", payload, opts)render json: success_jsonend@@ -172,7 +172,7 @@ after_initialize doendDiscourse::Application.routes.append do- mount ::Presence::Engine, at: '/presence'+ mount ::Presence::Engine, at: '/presence-plugin'endenddiff --git a/plugins/discourse-presence/spec/requests/presence_controller_spec.rb b/plugins/discourse-presence/spec/requests/presence_controller_spec.rbindex 9f374dbd404..adededeeb3a 100644--- a/plugins/discourse-presence/spec/requests/presence_controller_spec.rb+++ b/plugins/discourse-presence/spec/requests/presence_controller_spec.rb@@ -6,7 +6,7 @@ describe ::Presence::PresencesController dodescribe '#handle_message' docontext 'when not logged in' doit 'should raise the right error' do- post '/presence/publish.json'+ post '/presence-plugin/publish.json'expect(response.status).to eq(403)end@@ -40,7 +40,7 @@ describe ::Presence::PresencesController doit 'returns the right response when user disables the presence feature' douser.user_option.update_column(:hide_profile_and_presence, true)- post '/presence/publish.json'+ post '/presence-plugin/publish.json'expect(response.status).to eq(404)end@@ -49,7 +49,7 @@ describe ::Presence::PresencesController douser.user_option.update_column(:hide_profile_and_presence, true)SiteSetting.allow_users_to_hide_profile = false- post '/presence/publish.json', params: { topic_id: public_topic.id, state: 'replying' }+ post '/presence-plugin/publish.json', params: { topic_id: public_topic.id, state: 'replying' }expect(response.status).to eq(200)end@@ -57,19 +57,19 @@ describe ::Presence::PresencesController doit 'returns the right response when the presence site settings is disabled' doSiteSetting.presence_enabled = false- post '/presence/publish.json'+ post '/presence-plugin/publish.json'expect(response.status).to eq(404)endit 'returns the right response if required params are missing' do- post '/presence/publish.json'+ post '/presence-plugin/publish.json'expect(response.status).to eq(400)endit 'returns the right response if topic_id is invalid' do- post '/presence/publish.json', params: { topic_id: -999, state: 'replying' }+ post '/presence-plugin/publish.json', params: { topic_id: -999, state: 'replying' }expect(response.status).to eq(400)end@@ -77,13 +77,13 @@ describe ::Presence::PresencesController doit 'returns the right response when user does not have access to the topic' dogroup.remove(user)- post '/presence/publish.json', params: { topic_id: private_topic.id, state: 'replying' }+ post '/presence-plugin/publish.json', params: { topic_id: private_topic.id, state: 'replying' }expect(response.status).to eq(403)endit 'returns the right response when an invalid state is provided with a post_id' do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: public_topic.id,post_id: public_topic.first_post.id,state: 'some state'@@ -95,7 +95,7 @@ describe ::Presence::PresencesController doit 'returns the right response when user can not edit a post' doFabricate(:post, topic: private_topic, user: private_topic.user)- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: private_topic.id,post_id: private_topic.first_post.id,state: 'editing'@@ -105,7 +105,7 @@ describe ::Presence::PresencesController doendit 'returns the right response when an invalid post_id is given' do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: public_topic.id,post_id: -9,state: 'editing'@@ -118,7 +118,7 @@ describe ::Presence::PresencesController dofreeze_timemessages = MessageBus.track_publish do- post '/presence/publish.json', params: { topic_id: public_topic.id, state: 'replying' }+ post '/presence-plugin/publish.json', params: { topic_id: public_topic.id, state: 'replying' }expect(response.status).to eq(200)end@@ -127,7 +127,7 @@ describe ::Presence::PresencesController domessage = messages.first- expect(message.channel).to eq("/presence/#{public_topic.id}")+ expect(message.channel).to eq("/presence-plugin/#{public_topic.id}")expect(message.data.dig(:user, :id)).to eq(user.id)expect(message.data[:published_at]).to eq(Time.zone.now.to_i)expect(message.group_ids).to eq(nil)@@ -138,7 +138,7 @@ describe ::Presence::PresencesController dofreeze_timemessages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: private_topic.id,state: 'replying'}@@ -150,7 +150,7 @@ describe ::Presence::PresencesController domessage = messages.first- expect(message.channel).to eq("/presence/#{private_topic.id}")+ expect(message.channel).to eq("/presence-plugin/#{private_topic.id}")expect(message.data.dig(:user, :id)).to eq(user.id)expect(message.data[:published_at]).to eq(Time.zone.now.to_i)expect(message.group_ids).to contain_exactly(group.id)@@ -159,7 +159,7 @@ describe ::Presence::PresencesController doit 'publishes the right message for a private message' domessages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: private_message.id,state: 'replying'}@@ -185,7 +185,7 @@ describe ::Presence::PresencesController doSiteSetting.enable_whispers = truemessages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: public_topic.id,state: 'replying',is_whisper: true@@ -204,7 +204,7 @@ describe ::Presence::PresencesController doit 'publishes the message to staff group when staff_only param override is present' domessages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: public_topic.id,state: 'replying',staff_only: true@@ -226,7 +226,7 @@ describe ::Presence::PresencesController dosign_in(admin)messages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: public_topic.id,post_id: public_topic.first_post.id,state: 'editing',@@ -250,7 +250,7 @@ describe ::Presence::PresencesController dolocked_post = Fabricate(:post, topic: public_topic, locked_by_id: admin.id)messages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: public_topic.id,post_id: locked_post.id,state: 'editing',@@ -271,7 +271,7 @@ describe ::Presence::PresencesController dopost = Fabricate(:post, topic: public_topic, user: user)messages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: public_topic.id,post_id: post.id,state: 'editing',@@ -299,7 +299,7 @@ describe ::Presence::PresencesController doSiteSetting.trusted_users_can_edit_others = falsemessages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: public_topic.id,post_id: post.id,state: 'editing',@@ -323,7 +323,7 @@ describe ::Presence::PresencesController doSiteSetting.min_trust_to_edit_wiki_post = TrustLevel.levels[:basic]messages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: public_topic.id,post_id: post.id,state: 'editing',@@ -348,7 +348,7 @@ describe ::Presence::PresencesController dopost = Fabricate(:post, topic: private_message, user: user)messages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: private_message.id,post_id: post.id,state: 'editing',@@ -383,7 +383,7 @@ describe ::Presence::PresencesController doSiteSetting.min_trust_to_edit_wiki_post = TrustLevel.levels[:basic]messages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: private_message.id,post_id: post.id,state: 'editing',@@ -408,7 +408,7 @@ describe ::Presence::PresencesController doit 'publishes the right message when closing composer in public topic' domessages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: public_topic.id,state: described_class::CLOSED_STATE,}@@ -426,7 +426,7 @@ describe ::Presence::PresencesController doit 'publishes the right message when closing composer in private topic' domessages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: private_topic.id,state: described_class::CLOSED_STATE,}@@ -446,7 +446,7 @@ describe ::Presence::PresencesController dopost = Fabricate(:post, topic: private_message, user: user)messages = MessageBus.track_publish do- post '/presence/publish.json', params: {+ post '/presence-plugin/publish.json', params: {topic_id: private_message.id,state: described_class::CLOSED_STATE,}