diff --git a/plugins/discourse-presence/assets/javascripts/discourse/lib/presence.js.es6 b/plugins/discourse-presence/assets/javascripts/discourse/lib/presence.js.es6 index 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.rb index 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 do payload[:post_id] = post_id end - MessageBus.publish("/presence/#{topic_id}", payload, opts) + MessageBus.publish("/presence-plugin/#{topic_id}", payload, opts) render json: success_json end @@ -172,7 +172,7 @@ after_initialize do end Discourse::Application.routes.append do - mount ::Presence::Engine, at: '/presence' + mount ::Presence::Engine, at: '/presence-plugin' end end diff --git a/plugins/discourse-presence/spec/requests/presence_controller_spec.rb b/plugins/discourse-presence/spec/requests/presence_controller_spec.rb index 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 do describe '#handle_message' do context 'when not logged in' do it '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 do it 'returns the right response when user disables the presence feature' do user.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 do user.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 do it 'returns the right response when the presence site settings is disabled' do SiteSetting.presence_enabled = false - post '/presence/publish.json' + post '/presence-plugin/publish.json' expect(response.status).to eq(404) end it '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) end it '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 do it 'returns the right response when user does not have access to the topic' do group.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) end it '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 do it 'returns the right response when user can not edit a post' do Fabricate(: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 do end it '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 do freeze_time messages = 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 do message = 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 do freeze_time messages = 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 do message = 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 do it 'publishes the right message for a private message' do messages = 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 do SiteSetting.enable_whispers = true messages = 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 do it 'publishes the message to staff group when staff_only param override is present' do messages = 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 do sign_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 do locked_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 do post = 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 do SiteSetting.trusted_users_can_edit_others = false 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', @@ -323,7 +323,7 @@ describe ::Presence::PresencesController do SiteSetting.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 do post = 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 do SiteSetting.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 do it 'publishes the right message when closing composer in public topic' do messages = 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 do it 'publishes the right message when closing composer in private topic' do messages = 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 do post = 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, }