IZ MS fix a nasty bug where status messages with posts were not persisted in a users aspects stream. also, fixed the code link for joindiaspora.com
This commit is contained in:
parent
137cde185f
commit
1661158f95
8 changed files with 23 additions and 19 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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|
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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/)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue