From d37461a43279ea0d3bfa76309a82213c5909d243 Mon Sep 17 00:00:00 2001
From: maxwell <maxwell@joindiaspora.com>
Date: Fri, 9 Jul 2010 19:27:39 -0700
Subject: [PATCH] ms dg post deletions now come thru the socket again

---
 app/controllers/people_controller.rb   |  2 +-
 app/controllers/requests_controller.rb |  6 ++++--
 app/controllers/sockets_controller.rb  |  5 +++++
 app/models/retraction.rb               | 16 ++++++++++++++--
 app/views/requests/_request.html.haml  |  2 +-
 5 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb
index 9c8d2f711a..44bdaf63ff 100644
--- a/app/controllers/people_controller.rb
+++ b/app/controllers/people_controller.rb
@@ -13,7 +13,7 @@ class PeopleController < ApplicationController
   
   def destroy
     current_user.unfriend(params[:id])
-    flash[:notice] = "Successfully destroyed person."
+    flash[:notice] = "unfriended person."
     redirect_to people_url
   end
   
diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb
index d96dc354c1..c37a86ca7e 100644
--- a/app/controllers/requests_controller.rb
+++ b/app/controllers/requests_controller.rb
@@ -8,13 +8,15 @@ class RequestsController < ApplicationController
   
   def destroy
     if params[:accept]
-      current_user.accept_friend_request params[:id]
+      @friend = current_user.accept_friend_request params[:id]
+      
       flash[:notice] = "you are now friends"
+      redirect_to root_url 
     else
       current_user.ignore_friend_request params[:id]
       flash[:notice] = "ignored friend request"
+      redirect_to requests_url
     end
-    redirect_to requests_url
 
   end
   
diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb
index daea6466a8..05150f785f 100644
--- a/app/controllers/sockets_controller.rb
+++ b/app/controllers/sockets_controller.rb
@@ -20,6 +20,11 @@ class SocketsController < ApplicationController
   
   def outgoing(object)
     @_request = ActionDispatch::Request.new({})
+    
+    puts action_hash(object)
+    
+    
+    
     WebSocket.push_to_clients(action_hash(object))
   end
   
diff --git a/app/models/retraction.rb b/app/models/retraction.rb
index 1ccfa33f9d..c799df5fd6 100644
--- a/app/models/retraction.rb
+++ b/app/models/retraction.rb
@@ -6,7 +6,7 @@ class Retraction
     retraction = self.new
     retraction.post_id= object.id
     retraction.person_id = person_id_from(object)
-    retraction.type = object.class
+    retraction.type = self.type_name(object)
     retraction
   end
 
@@ -19,7 +19,8 @@ class Retraction
   attr_accessor :type
 
   def perform
-    self.type.constantize.delete(self.post_id)
+    puts('GO GO GO')
+    self.type.constantize.destroy(self.post_id)
   end
 
   def self.person_id_from(object)
@@ -30,4 +31,15 @@ class Retraction
     end
   end
 
+
+  def self.type_name(object)
+    if object.is_a? Post
+      object.class
+    elsif object.is_a? User
+      'Person'
+    else
+      'Clowntown'
+    end
+  end
+
 end
diff --git a/app/views/requests/_request.html.haml b/app/views/requests/_request.html.haml
index 84284151af..39a4114b38 100644
--- a/app/views/requests/_request.html.haml
+++ b/app/views/requests/_request.html.haml
@@ -4,6 +4,6 @@
   = "#{request.destination_url}"
 
   .destroy_link
-    = link_to 'Accept', request_path(request, :accept => true), :confirm => 'Are you sure?', :method => :delete 
+    = link_to 'Accept', request_path(request, :accept => true), :method => :delete 
     |
     = link_to 'Ignore', request_path(request), :confirm => 'Are you sure?', :method => :delete
-- 
GitLab