Fix mention in #newhere message when invited by another person

fixes #7701
closes #7702
This commit is contained in:
Benjamin Neff 2018-01-25 03:02:04 +01:00 committed by Dennis Schubert
parent f23966ef87
commit 746ff52256
No known key found for this signature in database
GPG key ID: 5A0304BEA7966D7E
10 changed files with 38 additions and 23 deletions

View file

@ -8,6 +8,7 @@
## Bug fixes ## Bug fixes
* Fix invite link on the contacts page when the user has no contacts [#7690](https://github.com/diaspora/diaspora/pull/7690) * 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) * 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 ## Features
* Check if redis is running in script/server [#7685](https://github.com/diaspora/diaspora/pull/7685) * Check if redis is running in script/server [#7685](https://github.com/diaspora/diaspora/pull/7685)

View file

@ -178,6 +178,9 @@ app.views.Publisher = Backbone.View.extend({
if (gon.preloads.getting_started) { if (gon.preloads.getting_started) {
this.open(); this.open();
this.viewGettingStarted.show(); this.viewGettingStarted.show();
if (gon.preloads.mentioned_person) {
this.mention.addPersonToMentions(gon.preloads.mentioned_person);
}
} }
}, },

View file

@ -30,7 +30,12 @@ class StreamsController < ApplicationController
end end
def multi 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) stream_responder(Stream::Multi)
end end

View file

@ -17,7 +17,7 @@ module InterimStreamHackinessHelper
if params[:prefill].present? if params[:prefill].present?
params[:prefill] params[:prefill]
elsif defined?(@stream) elsif defined?(@stream)
@stream.publisher.text @stream.publisher.prefill
else else
nil nil
end end

View file

@ -9,12 +9,4 @@ class Publisher
self.prefill = opts[:prefill] self.prefill = opts[:prefill]
self.public = opts[:public] self.public = opts[:public]
end end
def text
return unless prefill.present?
Diaspora::MessageRenderer.new(
prefill,
mentioned_people: Diaspora::Mentionable.people_from_string(prefill)
).plain_text
end
end end

View file

@ -46,7 +46,7 @@ class Stream::Multi < Stream::Base
if inviter = self.user.invited_by.try(:person) if inviter = self.user.invited_by.try(:person)
prefill << I18n.t("shared.publisher.new_user_prefill.invited_by") prefill << I18n.t("shared.publisher.new_user_prefill.invited_by")
prefill << "@{#{inviter.name} ; #{inviter.diaspora_handle}}!" prefill << "@{#{inviter.diaspora_handle}}!"
end end
prefill prefill

View file

@ -5,6 +5,8 @@
# the COPYRIGHT file. # the COPYRIGHT file.
describe StreamsController, :type => :controller do describe StreamsController, :type => :controller do
include_context :gon
before do before do
sign_in alice sign_in alice
end end
@ -26,6 +28,18 @@ describe StreamsController, :type => :controller do
get :multi, :format => :mobile get :multi, :format => :mobile
expect(response).to be_success expect(response).to be_success
end 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 end
streams = { streams = {

View file

@ -35,4 +35,11 @@ describe InterimStreamHackinessHelper, type: :helper do
expect(commenting_disabled?(post)).to eq(true) expect(commenting_disabled?(post)).to eq(true)
end end
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 end

View file

@ -15,13 +15,6 @@ describe Publisher do
end end
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| %w(open public).each do |property|
describe "##{property}" do describe "##{property}" do
it 'defaults to closed' do it 'defaults to closed' do

View file

@ -62,7 +62,7 @@ describe Stream::Multi do
end end
it 'includes a mention of the inviter' do 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) expect(@stream.send(:publisher_prefill)).to include(mention)
end end
end end