Commit 066f8d12 authored by Dan Hansen's avatar Dan Hansen

Mention the person who invited a user on first message

parent 3118f7a0
......@@ -11,11 +11,21 @@ module InterimStreamHackinessHelper
end
##### These methods need to go away once we pass publisher object into the partial ######
def publisher_prefill_text
def publisher_formatted_text
if params[:prefill].present?
params[:prefill]
elsif defined?(@stream)
@stream.publisher.prefill
@stream.publisher.text
else
nil
end
end
def publisher_hidden_text
if params[:prefill].present?
params[:prefill]
elsif defined?(@stream)
@stream.publisher.prefill
else
nil
end
......
......@@ -56,9 +56,9 @@
#publisher_textarea_wrapper
= link_to( image_tag('deletelabel.png'), "#", :id => "hide_publisher", :title => t('.discard_post'))
%ul#photodropzone
= status.text_area :fake_text, :rows => 2, :value => h(publisher_prefill_text), :tabindex => 1, :placeholder => t('.whats_on_your_mind'),
= status.text_area :fake_text, :rows => 2, :value => h(publisher_formatted_text), :tabindex => 1, :placeholder => t('.whats_on_your_mind'),
:title => "1. #{t('shared.public_explain.share')}", 'data-content' => t('shared.public_explain.new_user_welcome_message')
= status.hidden_field :text, :value => '', :class => 'clear_on_submit'
= status.hidden_field :text, :value => h(publisher_hidden_text), :class => 'clear_on_submit'
#file-upload{:title => t('.upload_photos')}
= image_tag 'icons/camera.svg', :height => 14
......
......@@ -742,7 +742,8 @@ en:
discard_post: "Discard post"
new_user_prefill:
hello: "Hey everyone, I'm #%{new_user_tag}. "
i_like: "I'm interested in %{tags}."
i_like: "I'm interested in %{tags}. "
invited_by: "Thanks for the invite, "
add_contact:
enter_a_diaspora_username: "Enter a Diaspora username:"
your_diaspora_username_is: "Your Diaspora username is: %{diaspora_handle}"
......
......@@ -3,10 +3,14 @@ class Publisher
def initialize(user, opts={})
self.user = user
self.open = (opts[:open] == true)? true : false
self.open = opts[:open]
self.prefill = opts[:prefill]
self.public = (opts[:public] == true)? true : false
self.explain = (opts[:explain] == true)? true : false
self.public = opts[:public]
self.explain = opts[:explain]
end
def text
formatted_message
end
def open?
......@@ -20,4 +24,12 @@ class Publisher
def explain?
self.explain
end
private
def formatted_message
if self.prefill.present?
StatusMessage.new(:text => self.prefill).
format_mentions(self.prefill, :plain_text => true)
end
end
end
......@@ -55,6 +55,11 @@ class Stream::Multi < Stream::Base
prefill << I18n.t("shared.publisher.new_user_prefill.i_like", :tags => tag_string)
end
if inviter = self.user.invited_by.try(:person)
prefill << I18n.t("shared.publisher.new_user_prefill.invited_by")
prefill << "@{#{inviter.name} ; #{inviter.diaspora_handle}}!"
end
prefill
end
......
......@@ -489,7 +489,10 @@ var Publisher = {
});
Publisher.autocompletion.initialize();
Publisher.hiddenInput().val(Publisher.input().val());
if(Publisher.hiddenInput().val() === "") {
Publisher.hiddenInput().val(Publisher.input().val());
}
Publisher.input().autoResize();
Publisher.input().keydown(Publisher.autocompletion.keyDownHandler);
Publisher.input().keyup(Publisher.autocompletion.keyUpHandler);
......
......@@ -9,8 +9,6 @@ describe Publisher do
@publisher = Publisher.new(alice)
end
describe "#prefill" do
it 'defaults to nothing' do
@publisher.prefill.should be_blank
......@@ -21,6 +19,13 @@ describe Publisher do
end
end
describe '#text' do
it 'is a formatted version of the prefill' do
p = Publisher.new(alice, :prefill => "@{ alice ; alice@pod.com }")
p.text.should == "alice"
end
end
["open", "public", "explain"].each do |property|
describe "##{property}?" do
......
......@@ -44,11 +44,25 @@ describe Stream::Multi do
end
it 'returns includes new user hashtag' do
@stream.send(:publisher_prefill).include?("#NewHere").should be_true
@stream.send(:publisher_prefill).should include("#NewHere")
end
it 'includes followed hashtags' do
@stream.send(:publisher_prefill).include?("#cats").should be_true
@stream.send(:publisher_prefill).should include("#cats")
end
context 'when invited by another user' do
before do
@user = Factory(:user, :invited_by => alice)
@inviter = alice.person
@stream = Stream::Multi.new(@user)
end
it 'includes a mention of the inviter' do
mention = "@{#{@inviter.name} ; #{@inviter.diaspora_handle}}"
@stream.send(:publisher_prefill).should include(mention)
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment