diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index b6b12a842..a328f3ddc 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -32,9 +32,6 @@ class StatusMessagesController < ApplicationController @aspects = current_user.aspects @selected_contacts = @aspects.map { |aspect| aspect.contacts }.flatten.uniq @aspect_ids = @aspects.map{|x| x.id} - - pp @aspect_ids.inspect - render :layout => nil end @@ -51,8 +48,6 @@ class StatusMessagesController < ApplicationController end if @status_message.save - Rails.logger.info("event=create type=status_message chars=#{params[:status_message][:text].length}") - # always send to all aspects if public if params[:status_message][:public] || params[:status_message][:aspect_ids].first == "all_aspects" aspect_ids = current_user.aspects.map{|a| a.id} @@ -91,7 +86,7 @@ class StatusMessagesController < ApplicationController def normalize_public_flag! # mobile || desktop conditions - public_flag = params[:status_message][:aspect_ids].first == 'public' || params[:status_message][:public] + public_flag = (params[:status_message][:aspect_ids] && params[:status_message][:aspect_ids].first == 'public') || params[:status_message][:public] public_flag.to_s.match(/(true)|(on)/) ? public_flag = true : public_flag = false params[:status_message][:public] = public_flag public_flag diff --git a/app/models/activity_streams/photo.rb b/app/models/activity_streams/photo.rb index 0ccd12e64..d4a0fca89 100644 --- a/app/models/activity_streams/photo.rb +++ b/app/models/activity_streams/photo.rb @@ -10,7 +10,6 @@ class ActivityStreams::Photo < Post xml_attr :image_height xml_attr :image_width xml_attr :object_url - xml_attr :provider_display_name xml_attr :actor_url xml_attr :objectId diff --git a/app/models/post.rb b/app/models/post.rb index 92d4f5693..5798e067e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -12,6 +12,7 @@ class Post < ActiveRecord::Base include Diaspora::Likeable xml_attr :diaspora_handle + xml_attr :provider_display_name xml_attr :public xml_attr :created_at diff --git a/app/models/status_message.rb b/app/models/status_message.rb index d6e7eb6db..284cb517f 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -21,7 +21,7 @@ class StatusMessage < Post has_many :photos, :dependent => :destroy, :foreign_key => :status_message_guid, :primary_key => :guid validate :presence_of_content - attr_accessible :text + attr_accessible :text, :provider_display_name serialize :youtube_titles, Hash after_create :create_mentions diff --git a/app/views/shared/_publisher.mobile.haml b/app/views/shared/_publisher.mobile.haml index 827191a97..77291aa11 100644 --- a/app/views/shared/_publisher.mobile.haml +++ b/app/views/shared/_publisher.mobile.haml @@ -13,6 +13,7 @@ = form_for StatusMessage.new, {:data => {:ajax => false}} do |status| #message_container + = status.hidden_field :provider_display_name, :value => 'mobile' = status.text_area :text, :placeholder => t('.whats_on_your_mind'), :style => "width:300px", :rows => 4, :autofocus => "autofocus" %fieldset diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 9cd47b1ba..5321f0fd4 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -40,10 +40,19 @@ = render 'status_messages/status_message', :post => post, :photos => post.photos .info + %span.via + - if post.activity_streams? + = t('.via', :link => link_to("#{post.provider_display_name}", post.actor_url)).html_safe + – + - elsif post.provider_display_name == 'mobile' + = t('.via', :link => nil) + mobile + – + - if post.public? %span.post_scope{:title => t('.viewable_to_anyone')} = t('public') - · + – - else - if user_signed_in? && post.author.owner_id == current_user.id - aspects = aspects_with_post(all_aspects, post) @@ -56,12 +65,8 @@ - else %span.post_scope = t('limited') - · + – - %span.via - - if post.activity_streams? - = t('.via', :link => link_to("#{post.provider_display_name}", post.actor_url)).html_safe - · - if user_signed_in? - unless @commenting_disabled diff --git a/app/views/shared/_stream_element.mobile.haml b/app/views/shared/_stream_element.mobile.haml index 5a131251c..970cd130a 100644 --- a/app/views/shared/_stream_element.mobile.haml +++ b/app/views/shared/_stream_element.mobile.haml @@ -25,6 +25,13 @@ .info %span.time{:integer => post.created_at.to_i} = t('ago', :time => time_ago_in_words(post.created_at)) + %span.via + - if post.activity_streams? + = t('.via', :link => link_to("#{post.provider_display_name}", post.actor_url)).html_safe + - elsif post.provider_display_name == 'mobile' + = t('.via', :link => nil) + mobile + – %span.scope_scope - if post.public? @@ -32,9 +39,6 @@ - else = t('limited') - %span.via - - if post.activity_streams? - = t('.via', :link => link_to("#{post.provider_display_name}", post.actor_url)).html_safe - if post.is_a?(StatusMessage) = render 'status_messages/status_message', :post => post, :photos => post.photos diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb index ab3d6a9c3..76ea6feb5 100644 --- a/spec/controllers/status_messages_controller_spec.rb +++ b/spec/controllers/status_messages_controller_spec.rb @@ -77,10 +77,12 @@ describe StatusMessagesController do it 'takes public in aspect ids' do post :create, status_message_hash.merge(:aspect_ids => ['public']) + response.status.should == 302 end it 'takes all_aspects in aspect ids' do post :create, status_message_hash.merge(:aspect_ids => ['all_aspects']) + response.status.should == 302 end it "dispatches the post to the specified services" do @@ -113,6 +115,13 @@ describe StatusMessagesController do post :create, status_message_hash end + it 'respsects provider_display_name' do + status_message_hash.merge!(:aspect_ids => ['public']) + status_message_hash[:status_message].merge!(:provider_display_name => "mobile") + post :create, status_message_hash + StatusMessage.first.provider_display_name.should == 'mobile' + end + it 'sends the errors in the body on js' do post :create, status_message_hash.merge!(:format => 'js', :status_message => {:text => ''}) response.body.should include('Status message requires a message or at least one photo') diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 7c56147c8..07701aeb1 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -37,6 +37,13 @@ describe Post do end end + describe '.diaspora_initialize' do + it 'takes provider_display_name' do + sm = Factory.build(:status_message, :provider_display_name => 'mobile') + StatusMessage.diaspora_initialize(sm.attributes.merge(:author => bob.person)).provider_display_name.should == 'mobile' + end + end + describe '#mutable?' do it 'should be false by default' do post = @user.post :status_message, :text => "hello", :to => @aspect.id