When processing custom emoji, ensure a non-animated version exists (#5230)
Use the non-animated version in web UI, but return both in APIlolsob-rspec
parent
a89d69a269
commit
f37350c08f
|
@ -52,7 +52,7 @@ export const buildCustomEmojis = customEmojis => {
|
||||||
|
|
||||||
customEmojis.forEach(emoji => {
|
customEmojis.forEach(emoji => {
|
||||||
const shortcode = emoji.get('shortcode');
|
const shortcode = emoji.get('shortcode');
|
||||||
const url = emoji.get('url');
|
const url = emoji.get('static_url');
|
||||||
const name = shortcode.replace(':', '');
|
const name = shortcode.replace(':', '');
|
||||||
|
|
||||||
emojis.push({
|
emojis.push({
|
||||||
|
|
|
@ -60,7 +60,7 @@ const normalizeStatus = (state, status) => {
|
||||||
|
|
||||||
const searchContent = [status.spoiler_text, status.content].join(' ').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
const searchContent = [status.spoiler_text, status.content].join(' ').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
||||||
const emojiMap = normalStatus.emojis.reduce((obj, emoji) => {
|
const emojiMap = normalStatus.emojis.reduce((obj, emoji) => {
|
||||||
obj[`:${emoji.shortcode}:`] = emoji.url;
|
obj[`:${emoji.shortcode}:`] = emoji.static_url;
|
||||||
return obj;
|
return obj;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ class Formatter
|
||||||
def encode_custom_emojis(html, emojis)
|
def encode_custom_emojis(html, emojis)
|
||||||
return html if emojis.empty?
|
return html if emojis.empty?
|
||||||
|
|
||||||
emoji_map = emojis.map { |e| [e.shortcode, full_asset_url(e.image.url)] }.to_h
|
emoji_map = emojis.map { |e| [e.shortcode, full_asset_url(e.image.url(:static))] }.to_h
|
||||||
|
|
||||||
i = -1
|
i = -1
|
||||||
inside_tag = false
|
inside_tag = false
|
||||||
|
|
|
@ -21,7 +21,7 @@ class CustomEmoji < ApplicationRecord
|
||||||
:(#{SHORTCODE_RE_FRAGMENT}):
|
:(#{SHORTCODE_RE_FRAGMENT}):
|
||||||
(?=[^[:alnum:]:]|$)/x
|
(?=[^[:alnum:]:]|$)/x
|
||||||
|
|
||||||
has_attached_file :image
|
has_attached_file :image, styles: { static: { format: 'png', convert_options: '-coalesce -strip' } }
|
||||||
|
|
||||||
validates_attachment :image, content_type: { content_type: 'image/png' }, presence: true, size: { in: 0..50.kilobytes }
|
validates_attachment :image, content_type: { content_type: 'image/png' }, presence: true, size: { in: 0..50.kilobytes }
|
||||||
validates :shortcode, uniqueness: { scope: :domain }, format: { with: /\A#{SHORTCODE_RE_FRAGMENT}\z/ }, length: { minimum: 2 }
|
validates :shortcode, uniqueness: { scope: :domain }, format: { with: /\A#{SHORTCODE_RE_FRAGMENT}\z/ }, length: { minimum: 2 }
|
||||||
|
|
|
@ -3,9 +3,13 @@
|
||||||
class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
attributes :shortcode, :url
|
attributes :shortcode, :url, :static_url
|
||||||
|
|
||||||
def url
|
def url
|
||||||
full_asset_url(object.image.url)
|
full_asset_url(object.image.url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def static_url
|
||||||
|
full_asset_url(object.image.url(:static))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue