pass in mobile as provider_display_name on posts if posting from mobile

This commit is contained in:
danielgrippi 2011-09-28 22:15:09 -07:00
parent c3746aec7f
commit e3bf03636b
9 changed files with 38 additions and 17 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
&ndash;
- elsif post.provider_display_name == 'mobile'
= t('.via', :link => nil)
mobile
&ndash;
- if post.public?
%span.post_scope{:title => t('.viewable_to_anyone')}
= t('public')
·
&ndash;
- 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')
·
&ndash;
%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

View file

@ -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
&ndash;
%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

View file

@ -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')

View file

@ -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