Add support for custom emojis in poll options (#10322)

* Backend changes for custom emoji support in poll options

* Serialize poll emojis in REST API

* Render custom emojis in poll options

* Render custom emoji in poll options on public pages
This commit is contained in:
ThibG 2019-03-20 17:29:12 +01:00 committed by Eugen Rochko
parent 66d9452092
commit 80f0910e21
9 changed files with 35 additions and 7 deletions

View file

@ -60,6 +60,10 @@ class Poll < ApplicationRecord
!local?
end
def emojis
@emojis ||= CustomEmoji.from_text(options.join(' '), account.domain)
end
class Option < ActiveModelSerializers::Model
attributes :id, :title, :votes_count, :poll

View file

@ -213,7 +213,11 @@ class Status < ApplicationRecord
end
def emojis
@emojis ||= CustomEmoji.from_text([spoiler_text, text].join(' '), account.domain)
return @emojis if defined?(@emojis)
fields = [spoiler_text, text]
fields += owned_poll.options unless owned_poll.nil?
@emojis = CustomEmoji.from_text(fields.join(' '), account.domain)
@emojis
end
def mark_for_mass_destruction!