Do not process mentions or bangtags in drafts. Add `draft?` method to `Status` model.
parent
3e8690f2c0
commit
46522d8c1b
|
@ -41,7 +41,7 @@ class Bangtags
|
||||||
status.text.gsub!('#!!', "#\u200c!")
|
status.text.gsub!('#!!', "#\u200c!")
|
||||||
|
|
||||||
status.text.split(/(#!(?:.*:!#|{.*?}|[^\s#]+))/).each do |chunk|
|
status.text.split(/(#!(?:.*:!#|{.*?}|[^\s#]+))/).each do |chunk|
|
||||||
if @vore_stack.last == '_draft'
|
if @vore_stack.last == '_draft' || (@chunks.present? && @chunks.first.include?('#!draft'))
|
||||||
@chunks << chunk
|
@chunks << chunk
|
||||||
elsif chunk.starts_with?("#!")
|
elsif chunk.starts_with?("#!")
|
||||||
chunk.sub!(/(\\:)?+:+?!#\Z/, '\1')
|
chunk.sub!(/(\\:)?+:+?!#\Z/, '\1')
|
||||||
|
@ -396,7 +396,7 @@ class Bangtags
|
||||||
end
|
end
|
||||||
when 'draft'
|
when 'draft'
|
||||||
chunk = nil
|
chunk = nil
|
||||||
@chunks.insert(0, "[center]`#!draft!#`[/center]\n") unless @chunks.first.include?('#!draft')
|
@chunks.insert(0, "[center]`#!draft!#`[/center]\n") unless @chunks.present? && @chunks.first.include?('#!draft')
|
||||||
status.visibility = :direct
|
status.visibility = :direct
|
||||||
@vore_stack.push('_draft')
|
@vore_stack.push('_draft')
|
||||||
@component_stack.push(:var)
|
@component_stack.push(:var)
|
||||||
|
|
|
@ -211,6 +211,10 @@ class Status < ApplicationRecord
|
||||||
proper.text
|
proper.text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def draft?
|
||||||
|
local? && text.present? && text.include?('#!draft')
|
||||||
|
end
|
||||||
|
|
||||||
def target
|
def target
|
||||||
reblog
|
reblog
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ProcessMentionsService < BaseService
|
||||||
# remote users
|
# remote users
|
||||||
# @param [Status] status
|
# @param [Status] status
|
||||||
def call(status)
|
def call(status)
|
||||||
return unless status.local?
|
return unless status.local? && !status.draft?
|
||||||
|
|
||||||
@status = status
|
@status = status
|
||||||
mentions = []
|
mentions = []
|
||||||
|
|
Loading…
Reference in New Issue