about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-01-21 20:03:04 +0100
committerEugen Rochko <eugen@zeonfederated.com>2019-01-21 20:03:04 +0100
commit061feb63ed852acb5d70e2678c9e63425e6ca71b (patch)
tree8526667c66959311b262405619771cad328a3aa3 /app
parentdd8a00a3ccf4d73794ef110f8ca63955fa24c97a (diff)
Fix scheduled toot with media immediately creating a toot (#9894)
* Add test for not persisting status when attaching media to scheduled toot

* Prevent status used for validation from being persisted to the database

Fixes #9893

Thanks to tateisu for the help investigating this.
Diffstat (limited to 'app')
-rw-r--r--app/services/post_status_service.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
index cc3453f99..1f5a3f4cf 100644
--- a/app/services/post_status_service.rb
+++ b/app/services/post_status_service.rb
@@ -66,7 +66,10 @@ class PostStatusService < BaseService
   end
 
   def schedule_status!
-    if @account.statuses.build(status_attributes).valid?
+    status_for_validation = @account.statuses.build(status_attributes)
+    if status_for_validation.valid?
+      status_for_validation.destroy
+
       # The following transaction block is needed to wrap the UPDATEs to
       # the media attachments when the scheduled status is created