From bdd752f07b43dd316b9c87d7d454538ebe69ea00 Mon Sep 17 00:00:00 2001 From: Thomas Krehbiel Date: Mon, 20 Sep 2010 21:49:14 -0400 Subject: [PATCH 1/3] Fix for 'Local variable hides method' --- app/models/person.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 72f4c46b9..8a6b85175 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -104,8 +104,8 @@ class Person return nil unless public_key_entry - public_key = public_key_entry.first.href - new_person.exported_key = Base64.decode64 public_key + pubkey = public_key_entry.first.href + new_person.exported_key = Base64.decode64 pubkey guid = profile.links.select{|x| x.rel == 'http://joindiaspora.com/guid'}.first.href new_person.id = guid From de9092363115adca04879f06961d9bd5d7fd8d63 Mon Sep 17 00:00:00 2001 From: Thomas Krehbiel Date: Wed, 22 Sep 2010 18:05:11 -0400 Subject: [PATCH 2/3] Fix for sending unlimited duplicate friend requests --- lib/diaspora/user/friending.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index a4dcdd38d..f3b30f9b3 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -8,6 +8,9 @@ module Diaspora module UserModules module Friending def send_friend_request_to(desired_friend, aspect) + # should have different exception types for these? + raise "You have already sent a friend request to that person!" if self.pending_requests.detect{ + |x| x.destination_url == desired_friend.receive_url } raise "You are already friends with that person!" if self.friends.detect{ |x| x.receive_url == desired_friend.receive_url} request = Request.instantiate( From 10e6ff9df8e3168545d4ba8d074d22e78132d37e Mon Sep 17 00:00:00 2001 From: Thomas Krehbiel Date: Wed, 22 Sep 2010 18:05:11 -0400 Subject: [PATCH 3/3] Fix for sending unlimited duplicate friend requests --- app/controllers/requests_controller.rb | 4 ++-- lib/diaspora/user/friending.rb | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 6087ebe85..2a8090c9e 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -47,8 +47,8 @@ class RequestsController < ApplicationController begin @request = current_user.send_friend_request_to(rel_hash[:friend], aspect) rescue Exception => e - raise e unless e.message.include? "already friends" - flash[:notice] = "You are already friends with #{params[:request][:destination_url]}!" + raise e unless e.message.include? "already" + flash[:notice] = "#{e.message} #{params[:request][:destination_url]}" respond_with :location => aspect return end diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index a4dcdd38d..f3b30f9b3 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -8,6 +8,9 @@ module Diaspora module UserModules module Friending def send_friend_request_to(desired_friend, aspect) + # should have different exception types for these? + raise "You have already sent a friend request to that person!" if self.pending_requests.detect{ + |x| x.destination_url == desired_friend.receive_url } raise "You are already friends with that person!" if self.friends.detect{ |x| x.receive_url == desired_friend.receive_url} request = Request.instantiate(