Encode custom emojis as resolveable objects in ActivityPub (#5243)

* Encode custom emojis as resolveable objects in ActivityPub

* Improve code style
This commit is contained in:
Eugen Rochko
2017-10-07 17:43:42 +02:00
committed by GitHub
parent 057db0ecd0
commit 3a3475450e
17 changed files with 132 additions and 48 deletions

View File

@ -86,15 +86,19 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
end
def process_emoji(tag, _status)
return if tag['name'].blank? || tag['href'].blank?
return if skip_download?
return if tag['name'].blank? || tag['icon'].blank? || tag['icon']['url'].blank?
shortcode = tag['name'].delete(':')
image_url = tag['icon']['url']
uri = tag['id']
updated = tag['updated']
emoji = CustomEmoji.find_by(shortcode: shortcode, domain: @account.domain)
return if !emoji.nil? || skip_download?
return unless emoji.nil? || emoji.updated_at >= updated
emoji = CustomEmoji.new(domain: @account.domain, shortcode: shortcode)
emoji.image_remote_url = tag['href']
emoji ||= CustomEmoji.new(domain: @account.domain, shortcode: shortcode, uri: uri)
emoji.image_remote_url = image_url
emoji.save
end