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.split(/(#!(?:.*:!#|{.*?}|[^\s#]+))/).each do |chunk|
|
||||
if @vore_stack.last == '_draft'
|
||||
if @vore_stack.last == '_draft' || (@chunks.present? && @chunks.first.include?('#!draft'))
|
||||
@chunks << chunk
|
||||
elsif chunk.starts_with?("#!")
|
||||
chunk.sub!(/(\\:)?+:+?!#\Z/, '\1')
|
||||
|
@ -396,7 +396,7 @@ class Bangtags
|
|||
end
|
||||
when 'draft'
|
||||
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
|
||||
@vore_stack.push('_draft')
|
||||
@component_stack.push(:var)
|
||||
|
|
|
@ -211,6 +211,10 @@ class Status < ApplicationRecord
|
|||
proper.text
|
||||
end
|
||||
|
||||
def draft?
|
||||
local? && text.present? && text.include?('#!draft')
|
||||
end
|
||||
|
||||
def target
|
||||
reblog
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ class ProcessMentionsService < BaseService
|
|||
# remote users
|
||||
# @param [Status] status
|
||||
def call(status)
|
||||
return unless status.local?
|
||||
return unless status.local? && !status.draft?
|
||||
|
||||
@status = status
|
||||
mentions = []
|
||||
|
|
Loading…
Reference in New Issue