MS profiles should send, need to just make the parser now

This commit is contained in:
maxwell 2010-07-28 18:32:00 -07:00
parent e14e391a22
commit 049361ea15
6 changed files with 44 additions and 19 deletions

View file

@ -17,9 +17,8 @@ class UsersController < ApplicationController
def update
@user = User.where(:id => params[:id]).first
puts params.inspect
if @user.update_attributes(params[:user])
if @user.update_profile(params[:user])
flash[:notice] = "Successfully updated user."
redirect_to @user
else

View file

@ -1,10 +1,14 @@
class Profile
include MongoMapper::EmbeddedDocument
require 'lib/diaspora/webhooks'
include Diaspora::Webhooks
include ROXML
xml_reader :person_id
xml_accessor :first_name
xml_accessor :last_name
xml_accessor :image_url
key :first_name, String
key :last_name, String
@ -20,5 +24,12 @@ class Profile
# self.image_url = self._parent_document.url + self.image_url
# end
# end
def person_id
self._parent_document.id
end
def to_diaspora_xml
self.to_xml.to_s
end
end

View file

@ -28,6 +28,17 @@ class User < Person
end
false
end
##profile
def update_profile(params)
if self.update_attributes(params)
puts self.profile.class
self.profile.notify_people!
true
else
false
end
end
######### Friend Requesting
def send_friend_request_to(friend_url)

View file

@ -10,6 +10,10 @@ module Diaspora
push_to(people_with_permissions)
end
end
def notify_people!
push_to(people_with_permissions)
end
def subscribe_to_ostatus(feed_url)
@@queue.add_subscription_request(feed_url)
@ -22,9 +26,12 @@ module Diaspora
end
def push_to(recipients)
puts "FOOBATT"
@@queue.add_hub_notification(APP_CONFIG[:pubsub_server], User.owner.url + self.class.to_s.pluralize.underscore + '.atom')
unless recipients.empty?
recipients.map!{|x| x = x.url + "receive/"}
puts self.class
puts "made it in here!"
xml = self.class.build_xml_for(self)
Rails.logger.info("Adding xml for #{self} to message queue to #{recipients}")
@@queue.add_post_request( recipients, xml )
@ -54,6 +61,7 @@ module Diaspora
[*posts].each {|x| xml << x.to_diaspora_xml}
xml += "</posts>"
xml += "</XML>"
end
end
end

View file

@ -46,7 +46,7 @@ class MessageHandler
case query.type
when :post
http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body =>{:xml => query.body}
http.callback { puts query.destination; process; process}
http.callback { puts query.destination; puts query.body; process; process}
when :get
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
http.callback {send_to_seed(query, http.response); process}

View file

@ -59,26 +59,22 @@ describe User do
end
it 'should be able to update their profile and send it to their friends' do
pending
Factory.create(:person)
p = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clowntown.com"}}
profile = {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clowntown.com"}
@user = Factory.create(:user, :profile => Profile.new(profile))
profile = {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://awesome.com"}
@user = Factory.create(:user)
p = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com"}}
@user.update_profile(profile)
@user.update_profile(p).should == true
@user.profile.image_url.should == "http://awesome.com"
#puts @user.to_xml.to_s
@user.profile.image_url.should == "http://clown.com"
Profile.should_receive(:build_xml_for)
n = Profile.send :class_variable_get, :@@queue
n.should_receive(:process)
end
it 'should fix the image_url 'do
pending
profile = Profile.new(:image_url => "/images/foo.jpg")
user = Factory.create(:user, :profile => profile)
puts user.profile.image_url
end
end