diff options
-rw-r--r-- | app/controllers/api/v1/statuses_controller.rb | 6 | ||||
-rw-r--r-- | app/lib/bangtags.rb | 12 | ||||
-rw-r--r-- | app/services/post_status_service.rb | 5 |
3 files changed, 17 insertions, 6 deletions
diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 52d0fb9bc..a9728f997 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -58,7 +58,11 @@ class Api::V1::StatusesController < Api::BaseController content_type: status_params[:content_type], 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 def destroy diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb index 40714097b..536606065 100644 --- a/app/lib/bangtags.rb +++ b/app/lib/bangtags.rb @@ -730,10 +730,14 @@ class Bangtags account.user.save - status.text = @chunks.join - status.save - - postprocess_after_save + text = @chunks.join + if text.blank? + RemoveStatusService.new.call(@status) + else + status.text = text + status.save + postprocess_after_save + end end private diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 6f4be1cfe..ea7a2c2c3 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -52,7 +52,7 @@ class PostStatusService < BaseService if scheduled? schedule_status! else - process_status! + return unless process_status! postprocess_status! bump_potential_friendship! end @@ -148,8 +148,11 @@ class PostStatusService < BaseService @status = @account.statuses.create!(status_attributes) end + return false if @status.destroyed? + process_hashtags_service.call(@status, @tags, @preloaded_tags) process_mentions_service.call(@status) + return true end def schedule_status! |