MS profiles should send, need to just make the parser now
This commit is contained in:
parent
e14e391a22
commit
049361ea15
6 changed files with 44 additions and 19 deletions
|
|
@ -17,9 +17,8 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@user = User.where(:id => params[:id]).first
|
@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."
|
flash[:notice] = "Successfully updated user."
|
||||||
redirect_to @user
|
redirect_to @user
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
class Profile
|
class Profile
|
||||||
include MongoMapper::EmbeddedDocument
|
include MongoMapper::EmbeddedDocument
|
||||||
|
require 'lib/diaspora/webhooks'
|
||||||
|
include Diaspora::Webhooks
|
||||||
include ROXML
|
include ROXML
|
||||||
|
|
||||||
|
xml_reader :person_id
|
||||||
xml_accessor :first_name
|
xml_accessor :first_name
|
||||||
xml_accessor :last_name
|
xml_accessor :last_name
|
||||||
xml_accessor :image_url
|
xml_accessor :image_url
|
||||||
|
|
||||||
|
|
||||||
key :first_name, String
|
key :first_name, String
|
||||||
key :last_name, String
|
key :last_name, String
|
||||||
key :image_url, String
|
key :image_url, String
|
||||||
|
|
@ -20,5 +24,12 @@ class Profile
|
||||||
# self.image_url = self._parent_document.url + self.image_url
|
# self.image_url = self._parent_document.url + self.image_url
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
def person_id
|
||||||
|
self._parent_document.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_diaspora_xml
|
||||||
|
self.to_xml.to_s
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,17 @@ class User < Person
|
||||||
false
|
false
|
||||||
end
|
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
|
######### Friend Requesting
|
||||||
def send_friend_request_to(friend_url)
|
def send_friend_request_to(friend_url)
|
||||||
unless Person.where(:url => friend_url).first
|
unless Person.where(:url => friend_url).first
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ module Diaspora
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify_people!
|
||||||
|
push_to(people_with_permissions)
|
||||||
|
end
|
||||||
|
|
||||||
def subscribe_to_ostatus(feed_url)
|
def subscribe_to_ostatus(feed_url)
|
||||||
@@queue.add_subscription_request(feed_url)
|
@@queue.add_subscription_request(feed_url)
|
||||||
@@queue.process
|
@@queue.process
|
||||||
|
|
@ -22,9 +26,12 @@ module Diaspora
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_to(recipients)
|
def push_to(recipients)
|
||||||
|
puts "FOOBATT"
|
||||||
@@queue.add_hub_notification(APP_CONFIG[:pubsub_server], User.owner.url + self.class.to_s.pluralize.underscore + '.atom')
|
@@queue.add_hub_notification(APP_CONFIG[:pubsub_server], User.owner.url + self.class.to_s.pluralize.underscore + '.atom')
|
||||||
unless recipients.empty?
|
unless recipients.empty?
|
||||||
recipients.map!{|x| x = x.url + "receive/"}
|
recipients.map!{|x| x = x.url + "receive/"}
|
||||||
|
puts self.class
|
||||||
|
puts "made it in here!"
|
||||||
xml = self.class.build_xml_for(self)
|
xml = self.class.build_xml_for(self)
|
||||||
Rails.logger.info("Adding xml for #{self} to message queue to #{recipients}")
|
Rails.logger.info("Adding xml for #{self} to message queue to #{recipients}")
|
||||||
@@queue.add_post_request( recipients, xml )
|
@@queue.add_post_request( recipients, xml )
|
||||||
|
|
@ -54,6 +61,7 @@ module Diaspora
|
||||||
[*posts].each {|x| xml << x.to_diaspora_xml}
|
[*posts].each {|x| xml << x.to_diaspora_xml}
|
||||||
xml += "</posts>"
|
xml += "</posts>"
|
||||||
xml += "</XML>"
|
xml += "</XML>"
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class MessageHandler
|
||||||
case query.type
|
case query.type
|
||||||
when :post
|
when :post
|
||||||
http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body =>{:xml => query.body}
|
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
|
when :get
|
||||||
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
|
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
|
||||||
http.callback {send_to_seed(query, http.response); process}
|
http.callback {send_to_seed(query, http.response); process}
|
||||||
|
|
|
||||||
|
|
@ -59,26 +59,22 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to update their profile and send it to their friends' do
|
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)
|
||||||
|
p = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com"}}
|
||||||
@user = Factory.create(:user, :profile => Profile.new(profile))
|
|
||||||
profile = {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://awesome.com"}
|
|
||||||
|
|
||||||
|
|
||||||
@user.update_profile(profile)
|
@user.update_profile(p).should == true
|
||||||
|
|
||||||
@user.profile.image_url.should == "http://awesome.com"
|
@user.profile.image_url.should == "http://clown.com"
|
||||||
#puts @user.to_xml.to_s
|
|
||||||
|
Profile.should_receive(:build_xml_for)
|
||||||
|
|
||||||
|
n = Profile.send :class_variable_get, :@@queue
|
||||||
|
n.should_receive(:process)
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue