Class: ActivityPub::CommentSerializer
Constant Summary
BaseSerializer::CONTEXT
Instance Attribute Summary
#options
Instance Method Summary
collapse
#as_json, #initialize, #to_json
Instance Method Details
#attributed_to ⇒ Object
22
23
24
25
26
|
# File 'app/serializers/activitypub/comment_serializer.rb', line 22
def attributed_to
[
{ type: 'Person', id: account_url(object.account.username) }
]
end
|
#data ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'app/serializers/activitypub/comment_serializer.rb', line 3
def data
{
id: ActivityPub::TagManager.instance.uri_for(object),
type: object.object_type.to_s.capitalize,
published: object.created_at.iso8601,
url: url,
votes: object.votes_count,
attributedTo: attributed_to,
to: [ActivityPub::TagManager::COLLECTIONS[:public]],
inReplyTo: in_reply_to,
content: object.body_html,
source: source,
}
end
|
#in_reply_to ⇒ Object
28
29
30
31
32
33
34
|
# File 'app/serializers/activitypub/comment_serializer.rb', line 28
def in_reply_to
if object.parent_id.present?
ActivityPub::TagManager.instance.uri_for(object.parent)
else
ActivityPub::TagManager.instance.uri_for(object.story)
end
end
|
#source ⇒ Object
36
37
38
39
40
41
|
# File 'app/serializers/activitypub/comment_serializer.rb', line 36
def source
{
content: object.body,
mediaType: 'text/markdown'
}
end
|
#url ⇒ Object
18
19
20
|
# File 'app/serializers/activitypub/comment_serializer.rb', line 18
def url
{ type: 'Link', mediaType: 'text/html', href: (object) }
end
|