diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index f01e71a912305a334ace816715351c9b8867b8c0..ee5ed172e06a942152ca97d2364e0f899ad867a2 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -53,7 +53,9 @@ class PhotosController < ApplicationController if @photo.save raise 'MongoMapper failed to catch a failed save' unless @photo.id - current_user.add_to_streams(@photo, params[:photo][:aspect_ids]) + + aspects = current_user.aspects_from_ids(params[:photo][:aspect_ids]) + current_user.add_to_streams(@photo, aspects) current_user.dispatch_post(@photo, :to => params[:photo][:aspect_ids]) unless @photo.pending if params[:photo][:set_profile_photo] diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 0856aa73c132a4d016856639404bb638dc79ee90..265a5adec2b28c0f8c12a1c56544f348bfef6196 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -17,21 +17,21 @@ class StatusMessagesController < ApplicationController public_flag.to_s.match(/(true)/) ? public_flag = true : public_flag = false params[:status_message][:public] = public_flag @status_message = current_user.build_post(:status_message, params[:status_message]) - + aspects = current_user.aspects_from_ids(params[:aspect_ids]) if photos || @status_message.save!(:safe => true) raise 'MongoMapper failed to catch a failed save' unless @status_message.id @status_message.photos += photos unless photos.nil? - current_user.add_to_streams(@status_message, params[:status_message][:aspect_ids]) - current_user.dispatch_post(@status_message, :to => params[:status_message][:aspect_ids], :url => post_url(@status_message)) + current_user.add_to_streams(@status_message, aspects) + current_user.dispatch_post(@status_message, :url => post_url(@status_message)) for photo in photos photo.public = public_flag photo.save - current_user.add_to_streams(photo, params[:status_message][:aspect_ids]) - current_user.dispatch_post(photo, :to => params[:status_message][:aspect_ids]) + current_user.add_to_streams(photo, aspects) + current_user.dispatch_post(photo) end respond_to do |format| diff --git a/app/models/user.rb b/app/models/user.rb index 6b1eacaf371eb7b9af1d96774cbfbeb30cd68cbd..10e9099bb61a0b246fe2d9bb739a3ce46c259cc7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -156,19 +156,18 @@ class User Rails.logger.debug("Saving post: #{post}") post.user_refs += 1 post.save - aspects = self.aspects_with_person(post.person) - self.add_to_streams(post, aspects.map{|x| x.id} ) + aspects_to_insert = self.aspects_with_person(post.person) + self.add_to_streams(post, aspects_to_insert) post end - def add_to_streams(post, aspect_ids) + def add_to_streams(post, aspects_to_insert) self.raw_visible_posts << post self.save - post.socket_to_uid(self, :aspect_ids => aspect_ids) if post.respond_to? :socket_to_uid - target_aspects = aspects_from_ids(aspect_ids) - target_aspects.each do |aspect| + post.socket_to_uid(self, :aspect_ids => aspects_to_insert.map{|x| x.id}) if post.respond_to? :socket_to_uid + aspects_to_insert.each do |aspect| aspect.posts << post aspect.save end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0e493159cc30cadac47d27738acd9f06e5a10880..ee7628b76773a54b8bb5cfa0a9cc1b0b3179243a 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -93,7 +93,7 @@ %li= link_to '@joindiaspora', "http://twitter.com/joindiaspora" %li= link_to 'github', "https://github.com/diaspora/diaspora" %li= link_to t('layouts.header.blog'), "http://blog.joindiaspora.com" - %li= link_to t('layouts.header.code'), "#{root_url.chomp('/')}/source.tar.gz" + %li= link_to t('layouts.header.code'), "#{root_url.chomp('/')}/source.tar.gz" unless request.url.match(/joindiaspora.com/) %li= link_to t('.whats_new'), 'https://github.com/diaspora/diaspora/wiki/Changelog' -if !@landing_page && request.url.match(/joindiaspora.com/) diff --git a/lib/postzord/dispatch.rb b/lib/postzord/dispatch.rb index 96db24f0e786de6591355c5e23cf02f256d98bfc..0a8d0ed136fc47987f61b5d8dcdd64d568c542ef 100644 --- a/lib/postzord/dispatch.rb +++ b/lib/postzord/dispatch.rb @@ -33,6 +33,7 @@ class Postzord::Dispatch end protected + def deliver_to_remote(people) people.each do |person| enc_xml = @salmon_factory.xml_for(person) diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb index cd3497dc61f3c7c950dbecc5cf6b8cba165cd01f..65509c217432a235699b4b7388b3ccd768089ad4 100644 --- a/spec/controllers/status_message_controller_spec.rb +++ b/spec/controllers/status_message_controller_spec.rb @@ -30,7 +30,7 @@ describe StatusMessagesController do message = user1.build_post :status_message, :message => @url, :to => aspect1.id message[:youtube_titles]= {@video_id => "title"} message.save! - user1.add_to_streams(message, aspect1.id) + user1.add_to_streams(message, [aspect1]) user1.dispatch_post message, :to => aspect1.id get :show, :id => message.id diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 8750736a60c13861f91c05a9c516bfbbcc9d9a39..ca2aaf23c7ffa7fe842d85656759328855b7b2eb 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -22,24 +22,25 @@ describe User do @post = user.build_post(:status_message, @params) @post.save @aspect_ids = @params[:to] + @aspects = user.aspects_from_ids(@aspect_ids) end it 'saves post into visible post ids' do proc { - user.add_to_streams(@post, @aspect_ids) + user.add_to_streams(@post, @aspects) }.should change(user.raw_visible_posts, :count).by(1) user.reload.raw_visible_posts.should include @post end it 'saves post into each aspect in aspect_ids' do - user.add_to_streams(@post, @aspect_ids) + user.add_to_streams(@post, @aspects) aspect.reload.post_ids.should include @post.id aspect1.reload.post_ids.should include @post.id end it 'sockets the post to the poster' do @post.should_receive(:socket_to_uid).with(user, anything) - user.add_to_streams(@post, @aspect_ids) + user.add_to_streams(@post, @aspects) end end diff --git a/spec/support/user_methods.rb b/spec/support/user_methods.rb index d0288d7fa441f1aeacf6b776864bc4bebd52f565..b5facc06d350c5430e8ec8d86e38dde96e3a34dc 100644 --- a/spec/support/user_methods.rb +++ b/spec/support/user_methods.rb @@ -21,8 +21,9 @@ class User raise 'MongoMapper failed to catch a failed save' unless p.id self.aspects.reload - - add_to_streams(p, opts[:to]) + + aspects = self.aspects_from_ids(opts[:to]) + add_to_streams(p, aspects) dispatch_post(p, :to => opts[:to]) end p