Fix custom emojis not detected when used in content warning (#5049)
This commit is contained in:
		
							parent
							
								
									846cd4e838
								
							
						
					
					
						commit
						9c8e602163
					
				
					 4 changed files with 9 additions and 3 deletions
				
			
		|  | @ -63,6 +63,12 @@ class Formatter | |||
|     Sanitize.fragment(html, config) | ||||
|   end | ||||
| 
 | ||||
|   def format_spoiler(status) | ||||
|     html = encode(status.spoiler_text) | ||||
|     html = encode_custom_emojis(html, status.emojis) | ||||
|     html.html_safe # rubocop:disable Rails/OutputSafety | ||||
|   end | ||||
| 
 | ||||
|   private | ||||
| 
 | ||||
|   def encode(html) | ||||
|  |  | |||
|  | @ -132,7 +132,7 @@ class Status < ApplicationRecord | |||
|   end | ||||
| 
 | ||||
|   def emojis | ||||
|     CustomEmoji.from_text(text, account.domain) | ||||
|     CustomEmoji.from_text([spoiler_text, text].join(' '), account.domain) | ||||
|   end | ||||
| 
 | ||||
|   after_create :store_uri, if: :local? | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ | |||
|   .status__content.p-name.emojify< | ||||
|     - if status.spoiler_text? | ||||
|       %p{ style: 'margin-bottom: 0' }< | ||||
|         %span.p-summary> #{status.spoiler_text}  | ||||
|         %span.p-summary> #{Formatter.instance.format_spoiler(status)}  | ||||
|         %a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more') | ||||
|     .e-content{ lang: status.language, style: "display: #{status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl_status?(status) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status, custom_emojify: true) | ||||
| 
 | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ | |||
|   .status__content.p-name.emojify< | ||||
|     - if status.spoiler_text? | ||||
|       %p{ style: 'margin-bottom: 0' }< | ||||
|         %span.p-summary> #{status.spoiler_text}  | ||||
|         %span.p-summary> #{Formatter.instance.format_spoiler(status)}  | ||||
|         %a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more') | ||||
|     .e-content{ lang: status.language, style: "display: #{status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl_status?(status) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status, custom_emojify: true) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue