about summary refs log tree commit diff
path: root/app/lib/activitypub/parser/custom_emoji_parser.rb
blob: 724c6021500e04b299f749cab92d65c7e4eee1e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

class ActivityPub::Parser::CustomEmojiParser
  include JsonLdHelper

  def initialize(json)
    @json = json
  end

  def uri
    @json['id']
  end

  def shortcode
    @json['name']&.delete(':')
  end

  def image_remote_url
    @json.dig('icon', 'url')
  end

  def updated_at
    @json['updated']&.to_datetime
  rescue ArgumentError
    nil
  end
end