better handling of bangtag-only posts that produce no output
parent
b28fae301a
commit
7f19514527
|
@ -58,7 +58,11 @@ class Api::V1::StatusesController < Api::BaseController
|
||||||
content_type: status_params[:content_type],
|
content_type: status_params[:content_type],
|
||||||
idempotency: request.headers['Idempotency-Key'])
|
idempotency: request.headers['Idempotency-Key'])
|
||||||
|
|
||||||
render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer
|
if @status.nil?
|
||||||
|
raise Mastodon::ValidationError, 'Bangtags processed. No output.'
|
||||||
|
else
|
||||||
|
render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
@ -730,10 +730,14 @@ class Bangtags
|
||||||
|
|
||||||
account.user.save
|
account.user.save
|
||||||
|
|
||||||
status.text = @chunks.join
|
text = @chunks.join
|
||||||
status.save
|
if text.blank?
|
||||||
|
RemoveStatusService.new.call(@status)
|
||||||
postprocess_after_save
|
else
|
||||||
|
status.text = text
|
||||||
|
status.save
|
||||||
|
postprocess_after_save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -52,7 +52,7 @@ class PostStatusService < BaseService
|
||||||
if scheduled?
|
if scheduled?
|
||||||
schedule_status!
|
schedule_status!
|
||||||
else
|
else
|
||||||
process_status!
|
return unless process_status!
|
||||||
postprocess_status!
|
postprocess_status!
|
||||||
bump_potential_friendship!
|
bump_potential_friendship!
|
||||||
end
|
end
|
||||||
|
@ -148,8 +148,11 @@ class PostStatusService < BaseService
|
||||||
@status = @account.statuses.create!(status_attributes)
|
@status = @account.statuses.create!(status_attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return false if @status.destroyed?
|
||||||
|
|
||||||
process_hashtags_service.call(@status, @tags, @preloaded_tags)
|
process_hashtags_service.call(@status, @tags, @preloaded_tags)
|
||||||
process_mentions_service.call(@status)
|
process_mentions_service.call(@status)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
def schedule_status!
|
def schedule_status!
|
||||||
|
|
Loading…
Reference in New Issue