RS, DG; unsocketing is back in
This commit is contained in:
parent
4b5071ec05
commit
d8959326d5
4 changed files with 10 additions and 9 deletions
|
|
@ -58,7 +58,7 @@ class Person
|
||||||
model_class = class_name.to_s.camelize.constantize
|
model_class = class_name.to_s.camelize.constantize
|
||||||
post = model_class.instantiate(options)
|
post = model_class.instantiate(options)
|
||||||
post.notify_people
|
post.notify_people
|
||||||
post.socket_to_uid person.owner.id if person.owner_id
|
post.socket_to_uid owner.id if owner_id
|
||||||
post
|
post
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -68,7 +68,7 @@ class Person
|
||||||
c = Comment.new(:person_id => self.id, :text => text, :post => options[:on])
|
c = Comment.new(:person_id => self.id, :text => text, :post => options[:on])
|
||||||
if c.save
|
if c.save
|
||||||
send_comment c
|
send_comment c
|
||||||
c.socket_to_uid person.owner.id if person.owner_id
|
c.socket_to_uid owner.id if owner_id
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
Rails.logger.warn "this failed to save: #{c.inspect}"
|
Rails.logger.warn "this failed to save: #{c.inspect}"
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class Post
|
||||||
timestamps!
|
timestamps!
|
||||||
|
|
||||||
before_destroy :propagate_retraction
|
before_destroy :propagate_retraction
|
||||||
after_destroy :destroy_comments, :remove_from_view
|
after_destroy :destroy_comments
|
||||||
|
|
||||||
def self.instantiate params
|
def self.instantiate params
|
||||||
self.create params
|
self.create params
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,14 @@ class Retraction
|
||||||
attr_accessor :person_id
|
attr_accessor :person_id
|
||||||
attr_accessor :type
|
attr_accessor :type
|
||||||
|
|
||||||
def perform
|
def perform receiving_user_id
|
||||||
Rails.logger.debug "Performing retraction for #{object.post_id}"
|
Rails.logger.debug "Performing retraction for #{post_id}"
|
||||||
begin
|
begin
|
||||||
return unless signature_valid?
|
return unless signature_valid?
|
||||||
Rails.logger.debug("Retracting #{self.type} id: #{self.post_id}")
|
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
|
rescue NameError
|
||||||
Rails.logger.info("Retraction for unknown type recieved.")
|
Rails.logger.info("Retraction for unknown type recieved.")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -124,8 +124,7 @@ class User
|
||||||
Rails.logger.debug("Receiving object:\n#{object.inspect}")
|
Rails.logger.debug("Receiving object:\n#{object.inspect}")
|
||||||
|
|
||||||
if object.is_a? Retraction
|
if object.is_a? Retraction
|
||||||
object.post.unsocket_from_uid self.id
|
object.perform self.id
|
||||||
object.perform
|
|
||||||
|
|
||||||
elsif object.is_a? Request
|
elsif object.is_a? Request
|
||||||
person = Diaspora::Parser.get_or_create_person_object_from_xml( xml )
|
person = Diaspora::Parser.get_or_create_person_object_from_xml( xml )
|
||||||
|
|
@ -141,7 +140,7 @@ class User
|
||||||
person.save
|
person.save
|
||||||
else
|
else
|
||||||
Rails.logger.debug("Saving object with success: #{object.save}")
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue