about summary refs log tree commit diff
path: root/app/lib/activitypub/parser/custom_emoji_parser.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/activitypub/parser/custom_emoji_parser.rb')
-rw-r--r--app/lib/activitypub/parser/custom_emoji_parser.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/lib/activitypub/parser/custom_emoji_parser.rb b/app/lib/activitypub/parser/custom_emoji_parser.rb
new file mode 100644
index 000000000..724c60215
--- /dev/null
+++ b/app/lib/activitypub/parser/custom_emoji_parser.rb
@@ -0,0 +1,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