Class: DiasporaFederation::Entities::Participation

Inherits:
DiasporaFederation::Entity show all
Includes:
Relayable
Defined in:
lib/diaspora_federation/entities/participation.rb

Overview

Participation is sent to subscribe a user on updates for some post.

See Also:

  • Validators::Participation

Defined Under Namespace

Classes: ParentNotLocal

Constant Summary collapse

LEGACY_SIGNATURE_ORDER =
Deprecated.

Old signature order

%i(guid parent_type parent_guid author).freeze

Constants included from Relayable

Relayable::DIGEST

Constants inherited from DiasporaFederation::Entity

DiasporaFederation::Entity::INVALID_XML_REGEX

Instance Attribute Summary collapse

Attributes included from Relayable

#additional_xml_elements, #author, #author_signature, #guid, #parent, #parent_author_signature, #parent_guid, #xml_order

Instance Method Summary collapse

Methods included from Relayable

included, #initialize, #to_s, #verify_signatures

Methods included from Logging

included

Methods inherited from DiasporaFederation::Entity

entity_class, entity_name, from_xml, #initialize, #to_h, #to_s, #to_xml

Methods included from PropertiesDSL

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

Instance Attribute Details

#parent_typeString (readonly)

A string describing a type of the target to subscribe on Currently only “Post” is supported.

Returns:

  • (String)

    parent type



17
# File 'lib/diaspora_federation/entities/participation.rb', line 17

property :parent_type, xml_name: :target_type

Instance Method Details

#sender_valid?(sender) ⇒ Boolean

Deprecated.

remove after DiasporaFederation::Entities::Participation doesn’t include Relayable anymore

It is only valid to receive a DiasporaFederation::Entities::Participation from the author themself.

Returns:

  • (Boolean)


21
22
23
# File 'lib/diaspora_federation/entities/participation.rb', line 21

def sender_valid?(sender)
  sender == author
end

#validate_parentObject

Validates that the parent exists and the parent author is local

Raises:



26
27
28
29
# File 'lib/diaspora_federation/entities/participation.rb', line 26

def validate_parent
  parent = DiasporaFederation.callbacks.trigger(:fetch_related_entity, parent_type, parent_guid)
  raise ParentNotLocal, "obj=#{self}" unless parent && parent.local
end