Class: DiasporaFederation::Entities::Retraction

Inherits:
DiasporaFederation::Entity show all
Defined in:
lib/diaspora_federation/entities/retraction.rb

Overview

This entity represents a claim of deletion of a previously federated entity.

Defined Under Namespace

Classes: TargetNotFound

Constant Summary

Constants inherited from DiasporaFederation::Entity

DiasporaFederation::Entity::ENTITY_NAME_REGEX, DiasporaFederation::Entity::INVALID_XML_REGEX

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DiasporaFederation::Entity

class_name, entity_class, entity_name, from_json, from_xml, #initialize, #to_h, #to_json, #to_xml

Methods included from PropertiesDSL

#class_props, #default_values, #entity, #find_property_for_xml_name, #missing_props, #optional_props, #property, #resolv_aliases, #xml_names

Methods included from Logging

included

Constructor Details

This class inherits a constructor from DiasporaFederation::Entity

Instance Attribute Details

#authorString (readonly)

The diaspora* ID of the person who deletes the entity

Returns:

  • (String)

    diaspora* ID

See Also:



11
# File 'lib/diaspora_federation/entities/retraction.rb', line 11

property :author, :string, xml_name: :diaspora_handle

#targetRelatedEntity (readonly)

Target entity

Returns:



26
# File 'lib/diaspora_federation/entities/retraction.rb', line 26

entity :target, Entities::RelatedEntity

#target_guidString (readonly)

Guid of the entity to be deleted

Returns:

  • (String)

    target guid



16
# File 'lib/diaspora_federation/entities/retraction.rb', line 16

property :target_guid, :string, xml_name: :post_guid

#target_typeString (readonly)

A string describing the type of the target

Returns:

  • (String)

    target type



21
# File 'lib/diaspora_federation/entities/retraction.rb', line 21

property :target_type, :string, xml_name: :type

Class Method Details

.from_hash(hash) ⇒ Retraction

Returns instance

Returns:

See Also:



44
45
46
47
# File 'lib/diaspora_federation/entities/retraction.rb', line 44

def self.from_hash(hash)
  hash[:target] = fetch_target(hash[:target_type], hash[:target_guid])
  new(hash)
end

Instance Method Details

#sender_valid?(sender) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
# File 'lib/diaspora_federation/entities/retraction.rb', line 28

def sender_valid?(sender)
  case target_type
  when "Comment", "Like", "PollParticipation"
    sender == target.author || sender == target.root.author
  else
    sender == target.author
  end
end

#to_sString

Returns string representation of this object

Returns:

  • (String)

    string representation of this object



38
39
40
# File 'lib/diaspora_federation/entities/retraction.rb', line 38

def to_s
  "Retraction:#{target_type}:#{target_guid}"
end