[WIP] Enable custom emoji on account pages and in the sidebar (#6124)
Federate custom emojis with accounts
This commit is contained in:
parent
f464f98fd3
commit
123a343d11
10 changed files with 158 additions and 5 deletions
|
@ -22,6 +22,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
|
||||
create_account if @account.nil?
|
||||
update_account
|
||||
process_tags(@account)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -187,4 +188,31 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
def lock_options
|
||||
{ redis: Redis.current, key: "process_account:#{@uri}" }
|
||||
end
|
||||
|
||||
def process_tags(account)
|
||||
return if @json['tag'].blank?
|
||||
as_array(@json['tag']).each do |tag|
|
||||
case tag['type']
|
||||
when 'Emoji'
|
||||
process_emoji tag, account
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def process_emoji(tag, _account)
|
||||
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 unless emoji.nil? || emoji.updated_at >= updated
|
||||
|
||||
emoji ||= CustomEmoji.new(domain: @account.domain, shortcode: shortcode, uri: uri)
|
||||
emoji.image_remote_url = image_url
|
||||
emoji.save
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue