Class: Retraction
- Inherits:
-
Object
- Object
- Retraction
- Includes:
- Diaspora::Federated::Base, Diaspora::Logging
- Defined in:
- lib/diaspora/federated/retraction.rb
Overview
Copyright © 2010-2011, Diaspora Inc. This file is
licensed under the Affero General Public License version 3 or later. See
the COPYRIGHT file.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#subscribers ⇒ Object
readonly
Returns the value of attribute subscribers.
Class Method Summary collapse
Instance Method Summary collapse
- #defer_dispatch(user, include_target_author = true) ⇒ Object
-
#initialize(data, subscribers, target = nil) ⇒ Retraction
constructor
A new instance of Retraction.
- #perform ⇒ Object
- #public? ⇒ Boolean
Methods included from Diaspora::Federated::Base
Constructor Details
#initialize(data, subscribers, target = nil) ⇒ Retraction
Returns a new instance of Retraction.
13 14 15 16 17 |
# File 'lib/diaspora/federated/retraction.rb', line 13 def initialize(data, subscribers, target=nil) @data = data @subscribers = subscribers @target = target end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/diaspora/federated/retraction.rb', line 11 def data @data end |
#subscribers ⇒ Object (readonly)
Returns the value of attribute subscribers.
11 12 13 |
# File 'lib/diaspora/federated/retraction.rb', line 11 def subscribers @subscribers end |
Class Method Details
.entity_class ⇒ Object
19 20 21 |
# File 'lib/diaspora/federated/retraction.rb', line 19 def self.entity_class DiasporaFederation::Entities::Retraction end |
.for(target) ⇒ Object
32 33 34 35 |
# File 'lib/diaspora/federated/retraction.rb', line 32 def self.for(target) federation_retraction_data = retraction_data_for(target) new(federation_retraction_data, target.subscribers.select(&:remote?), target) end |
.retraction_data_for(target) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/diaspora/federated/retraction.rb', line 23 def self.retraction_data_for(target) DiasporaFederation::Entities::Retraction.new( target_guid: target.guid, target: Diaspora::Federation::Entities.(target), target_type: Diaspora::Federation::Mappings.entity_name_for(target), author: target.diaspora_handle ).to_h end |
Instance Method Details
#defer_dispatch(user, include_target_author = true) ⇒ Object
37 38 39 40 41 |
# File 'lib/diaspora/federated/retraction.rb', line 37 def defer_dispatch(user, =true) subscribers = dispatch_subscribers() Workers::DeferredRetraction.perform_async(user.id, self.class.to_s, data.deep_stringify_keys, subscribers.map(&:id), service_opts(user).deep_stringify_keys) end |
#perform ⇒ Object
43 44 45 46 47 |
# File 'lib/diaspora/federated/retraction.rb', line 43 def perform logger.debug "Performing retraction for #{target.class.base_class}:#{target.guid}" target.destroy! logger.info "event=retraction status=complete target=#{data[:target_type]}:#{data[:target_guid]}" end |
#public? ⇒ Boolean
49 50 51 |
# File 'lib/diaspora/federated/retraction.rb', line 49 def public? data[:target][:public] end |