Merge branch 'friend-refactor' of github.com:diaspora/diaspora_rails into selector

This commit is contained in:
ilya 2010-08-16 14:43:13 -07:00
commit 6a3eb97fd4
10 changed files with 32 additions and 36 deletions

View file

@ -20,7 +20,7 @@ class ApplicationController < ActionController::Base
@groups = current_user.groups
@friends = current_user.friends
@latest_status_message = StatusMessage.newest_for(current_user.person)
@group = params[:group] ? current_user.groups.first(:id => params[:group]) : current_user.groups.first
@group = params[:group] ? current_user.group_by_id(params[:group]) : current_user.groups.first
end
end

View file

@ -39,7 +39,7 @@ def warzombie
def zombiefriendaccept
render :nothing => true
Request.all.each{|r|
current_user.accept_friend_request(r.id, current_user.groups.first.id)
current_user.accept_and_respond(r.id, current_user.groups.first.id)
}
end

View file

@ -15,7 +15,7 @@ class PeopleController < ApplicationController
end
def destroy
current_user.unfriend(current_user.friends.first(params[:id]))
current_user.unfriend(current_user.friend_by_id(params[:id]))
flash[:notice] = "unfriended person."
redirect_to people_url
end

View file

@ -8,7 +8,7 @@ class RequestsController < ApplicationController
def destroy
if params[:accept]
@friend = current_user.accept_friend_request( params[:id], current_user.groups.first.id)
@friend = current_user.accept_and_respond( params[:id], current_user.groups.first.id)
flash[:notice] = "you are now friends"
redirect_to root_url

View file

@ -1,9 +1,3 @@
module CommentsHelper
def target
end
def text
params[:comment][:text]
end
end

View file

@ -29,7 +29,7 @@ module RequestsHelper
puts request.host
if identifier.include?(request.host)
person = Person.by_webfinger identifier
action = :friend
action = (person == current_user.person ? :none : :friend)
url = person.owner.receive_url
else
f = Redfinger.finger(identifier)

View file

@ -22,10 +22,12 @@ class Comment
validates_presence_of :text
def push_upstream
Rails.logger.info("GOIN UPSTREAM")
push_to([post.person])
end
def push_downstream
Rails.logger.info("SWIMMIN DOWNSTREAM")
push_to(post.people_with_permissions)
end

View file

@ -66,7 +66,7 @@ class Person
raise "must comment on something!" unless options[:on]
c = Comment.new(:person_id => self.id, :text => text, :post => options[:on])
if c.save
send_comment c
dispatch_comment c
c.socket_to_uid owner.id if owner_id
true
else
@ -75,24 +75,12 @@ class Person
false
end
def send_comment( c )
if self.owner.nil?
if c.post.person.owner.nil?
#puts "The commenter is not here, and neither is the poster"
elsif c.post.person.owner
#puts "The commenter is not here, and the poster is"
c.push_downstream
end
else
if owns? c.post
#puts "The commenter is here, and is the poster"
c.push_downstream
else
#puts "The commenter is here, and is not the poster"
c.push_upstream
end
end
def dispatch_comment( c )
if owns? c.post
push_downstream
elsif owns? c
c.push_upstream
end
end
##profile
def update_profile(params)
@ -115,6 +103,10 @@ class Person
def self.by_webfinger( identifier )
Person.first(:email => identifier.gsub('acct:', ''))
end
def remote?
owner.nil?
end
protected
def clean_url

View file

@ -63,10 +63,16 @@ class User
activate_friend(request.person, group_by_id(group_id))
request.reverse self
request
end
def dispatch_friend_acceptance(request)
request.push_to_url(request.callback_url)
request.destroy
request.destroy unless request.callback_url.include? url
end
def accept_and_respond(friend_request_id, group_id)
dispatch_friend_acceptance(accept_friend_request(friend_request_id, group_id))
end
def ignore_friend_request(friend_request_id)
@ -167,7 +173,8 @@ class User
elsif object.verify_creator_signature == true
Rails.logger.debug("Saving object: #{object}")
object.save
object.socket_to_uid( id) if object.respond_to? :socket_to_uid
object.socket_to_uid( id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
object.person.dispatch_comment object if object.is_a?(Comment)
end
end

View file

@ -22,4 +22,5 @@ user2.person.save
# friending users
group = user.group(:name => "other dudes")
request = user.send_friend_request_to(user2.receive_url, group.id)
user2.accept_friend_request request.id, user2.group(:name => "presidents").id
reversed_request = user2.accept_friend_request( request.id, user2.group(:name => "presidents").id )
user.receive reversed_request.to_diaspora_xml