DEV: Rename discourse-presence endpoints and messagebus channels (#14089)
We are working to introduce a general core API for presence, which will clash with this plugin's `/presence` namespace This commit introduces no functional change. There may be a slight interruption in discourse-presence functionality during a deploy of this commit.
This commit is contained in:
parent
ec352a1969
commit
5eb4e642a6
|
@ -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,
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue