RS, DG; unsocketing is back in

This commit is contained in:
Raphael 2010-08-11 16:24:05 -07:00
parent 4b5071ec05
commit d8959326d5
4 changed files with 10 additions and 9 deletions

View file

@ -58,7 +58,7 @@ class Person
model_class = class_name.to_s.camelize.constantize
post = model_class.instantiate(options)
post.notify_people
post.socket_to_uid person.owner.id if person.owner_id
post.socket_to_uid owner.id if owner_id
post
end
@ -68,7 +68,7 @@ class Person
c = Comment.new(:person_id => self.id, :text => text, :post => options[:on])
if c.save
send_comment c
c.socket_to_uid person.owner.id if person.owner_id
c.socket_to_uid owner.id if owner_id
true
else
Rails.logger.warn "this failed to save: #{c.inspect}"

View file

@ -22,7 +22,7 @@ class Post
timestamps!
before_destroy :propagate_retraction
after_destroy :destroy_comments, :remove_from_view
after_destroy :destroy_comments
def self.instantiate params
self.create params

View file

@ -24,12 +24,14 @@ class Retraction
attr_accessor :person_id
attr_accessor :type
def perform
Rails.logger.debug "Performing retraction for #{object.post_id}"
def perform receiving_user_id
Rails.logger.debug "Performing retraction for #{post_id}"
begin
return unless signature_valid?
Rails.logger.debug("Retracting #{self.type} id: #{self.post_id}")
self.type.constantize.destroy(self.post_id)
target = self.type.constantize.first(self.post_id)
target.unsocket_from_uid receiving_user_id if target.respond_to? :unsocket_from_uid
target.destroy
rescue NameError
Rails.logger.info("Retraction for unknown type recieved.")
end

View file

@ -124,8 +124,7 @@ class User
Rails.logger.debug("Receiving object:\n#{object.inspect}")
if object.is_a? Retraction
object.post.unsocket_from_uid self.id
object.perform
object.perform self.id
elsif object.is_a? Request
person = Diaspora::Parser.get_or_create_person_object_from_xml( xml )
@ -141,7 +140,7 @@ class User
person.save
else
Rails.logger.debug("Saving object with success: #{object.save}")
object.socket_to_uid id
object.socket_to_uid( id) if object.respond_to? :socket_to_uid
end
end