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:
parent
057db0ecd0
commit
3a3475450e
17 changed files with 132 additions and 48 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ class ActivityPub::TagManager
|
|||
when :note, :comment, :activity
|
||||
return activity_account_status_url(target.account, target) if target.reblog?
|
||||
account_status_url(target.account, target)
|
||||
when :emoji
|
||||
emoji_url(target)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue