diff --git a/Changelog.md b/Changelog.md index 1b5f7cce3..9b41bf961 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ ## Bug fixes * Fix invite link on the contacts page when the user has no contacts [#7690](https://github.com/diaspora/diaspora/pull/7690) * Fixed the mobile bookmarklet when called without parameters [#7698](https://github.com/diaspora/diaspora/pull/7698) +* Properly build the #newhere message for people who got invited [#7702](https://github.com/diaspora/diaspora/pull/7702) ## Features * Check if redis is running in script/server [#7685](https://github.com/diaspora/diaspora/pull/7685) diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 19eb92296..84f957395 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -178,6 +178,9 @@ app.views.Publisher = Backbone.View.extend({ if (gon.preloads.getting_started) { this.open(); this.viewGettingStarted.show(); + if (gon.preloads.mentioned_person) { + this.mention.addPersonToMentions(gon.preloads.mentioned_person); + } } }, diff --git a/app/controllers/streams_controller.rb b/app/controllers/streams_controller.rb index 5e638e80d..89190168c 100644 --- a/app/controllers/streams_controller.rb +++ b/app/controllers/streams_controller.rb @@ -30,7 +30,12 @@ class StreamsController < ApplicationController end def multi - gon.preloads[:getting_started] = current_user.getting_started + if current_user.getting_started + gon.preloads[:getting_started] = true + inviter = current_user.invited_by.try(:person) + gon.preloads[:mentioned_person] = {name: inviter.name, handle: inviter.diaspora_handle} if inviter + end + stream_responder(Stream::Multi) end diff --git a/app/helpers/interim_stream_hackiness_helper.rb b/app/helpers/interim_stream_hackiness_helper.rb index 888155b00..b2c7056c7 100644 --- a/app/helpers/interim_stream_hackiness_helper.rb +++ b/app/helpers/interim_stream_hackiness_helper.rb @@ -17,7 +17,7 @@ module InterimStreamHackinessHelper if params[:prefill].present? params[:prefill] elsif defined?(@stream) - @stream.publisher.text + @stream.publisher.prefill else nil end diff --git a/lib/publisher.rb b/lib/publisher.rb index a6c6ab069..fd2808a80 100644 --- a/lib/publisher.rb +++ b/lib/publisher.rb @@ -9,12 +9,4 @@ class Publisher self.prefill = opts[:prefill] self.public = opts[:public] end - - def text - return unless prefill.present? - Diaspora::MessageRenderer.new( - prefill, - mentioned_people: Diaspora::Mentionable.people_from_string(prefill) - ).plain_text - end end diff --git a/lib/stream/multi.rb b/lib/stream/multi.rb index 3ca27a262..0304e0f1f 100644 --- a/lib/stream/multi.rb +++ b/lib/stream/multi.rb @@ -46,7 +46,7 @@ class Stream::Multi < Stream::Base if inviter = self.user.invited_by.try(:person) prefill << I18n.t("shared.publisher.new_user_prefill.invited_by") - prefill << "@{#{inviter.name} ; #{inviter.diaspora_handle}}!" + prefill << "@{#{inviter.diaspora_handle}}!" end prefill diff --git a/spec/controllers/streams_controller_spec.rb b/spec/controllers/streams_controller_spec.rb index 40f9fdf46..9eb5e56ee 100644 --- a/spec/controllers/streams_controller_spec.rb +++ b/spec/controllers/streams_controller_spec.rb @@ -5,6 +5,8 @@ # the COPYRIGHT file. describe StreamsController, :type => :controller do + include_context :gon + before do sign_in alice end @@ -26,6 +28,18 @@ describe StreamsController, :type => :controller do get :multi, :format => :mobile expect(response).to be_success end + + context "getting started" do + it "add the inviter to gon" do + user = FactoryGirl.create(:user, getting_started: true, invited_by: alice) + sign_in user + + get :multi + + expect(gon["preloads"][:mentioned_person][:name]).to eq(alice.person.name) + expect(gon["preloads"][:mentioned_person][:handle]).to eq(alice.person.diaspora_handle) + end + end end streams = { diff --git a/spec/helpers/interim_stream_hackiness_helper_spec.rb b/spec/helpers/interim_stream_hackiness_helper_spec.rb index 890e6e842..69bb04509 100644 --- a/spec/helpers/interim_stream_hackiness_helper_spec.rb +++ b/spec/helpers/interim_stream_hackiness_helper_spec.rb @@ -6,14 +6,14 @@ describe InterimStreamHackinessHelper, type: :helper do before do sign_in alice - def user_signed_in? + def user_signed_in? true end end it 'returns true if no user is signed in' do - def user_signed_in? - false + def user_signed_in? + false end expect(commenting_disabled?(double)).to eq(true) end @@ -22,7 +22,7 @@ describe InterimStreamHackinessHelper, type: :helper do @commenting_disabled = true expect(commenting_disabled?(double)).to eq(true) @commenting_disabled = false - expect(commenting_disabled?(double)).to eq(false) + expect(commenting_disabled?(double)).to eq(false) end it 'returns @stream.can_comment? if @stream is set' do @@ -35,4 +35,11 @@ describe InterimStreamHackinessHelper, type: :helper do expect(commenting_disabled?(post)).to eq(true) end end + + describe "#publisher_formatted_text" do + it "returns the prefill text from the stream" do + @stream = double(publisher: Publisher.new(alice, prefill: "hello world")) + expect(publisher_formatted_text).to eq("hello world") + end + end end diff --git a/spec/lib/publisher_spec.rb b/spec/lib/publisher_spec.rb index 55d9fdea8..22bd7360d 100644 --- a/spec/lib/publisher_spec.rb +++ b/spec/lib/publisher_spec.rb @@ -15,13 +15,6 @@ describe Publisher do end end - describe '#text' do - it 'is a formatted version of the prefill' do - p = Publisher.new(alice, prefill: "@{alice; #{alice.diaspora_handle}}") - expect(p.text).to eq("@alice") - end - end - %w(open public).each do |property| describe "##{property}" do it 'defaults to closed' do diff --git a/spec/lib/stream/multi_spec.rb b/spec/lib/stream/multi_spec.rb index 04dbd153d..3ef7e604a 100644 --- a/spec/lib/stream/multi_spec.rb +++ b/spec/lib/stream/multi_spec.rb @@ -62,7 +62,7 @@ describe Stream::Multi do end it 'includes a mention of the inviter' do - mention = "@{#{@inviter.name} ; #{@inviter.diaspora_handle}}" + mention = "@{#{@inviter.diaspora_handle}}" expect(@stream.send(:publisher_prefill)).to include(mention) end end