Module: Federails::DataTransformer::Note

Defined in:
lib/federails/data_transformer/note.rb

Class Method Summary collapse

Class Method Details

.to_federation(entity, content:, name: nil, custom: {}) ⇒ Hash

Renders a Note. The entity is used to determine actor and generic fields data

See:

- https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object
- https://www.w3.org/TR/activitystreams-vocabulary/#dfn-note

Examples:

Federails::DataTransformer::Note.to_federation(comment, content: comment.content, custom: { 'inReplyTo' => comment.parent.federated_url })


19
20
21
22
23
24
25
26
27
28
# File 'lib/federails/data_transformer/note.rb', line 19

def self.to_federation(entity, content:, name: nil, custom: {})
  custom.merge '@context'     => 'https://www.w3.org/ns/activitystreams',
               'id'           => entity.federated_url,
               'type'         => 'Note',
               'name'         => name,
               'content'      => content,
               'attributedTo' => entity.federails_actor.federated_url,
               'published'    => entity.created_at,
               'updated'      => entity.updated_at
end