Browse Source

attach_media should be in transaction of creation status (#2426)

master
Keiji, Yoshimi 7 years ago
committed by Eugen Rochko
parent
commit
8fe36654ef
1 changed files with 11 additions and 9 deletions
  1. +11
    -9
      app/services/post_status_service.rb

+ 11
- 9
app/services/post_status_service.rb View File

@ -20,15 +20,17 @@ class PostStatusService < BaseService
end
media = validate_media!(options[:media_ids])
status = account.statuses.create!(text: text,
thread: in_reply_to,
sensitive: options[:sensitive],
spoiler_text: options[:spoiler_text] || '',
visibility: options[:visibility],
language: detect_language_for(text, account),
application: options[:application])
attach_media(status, media)
status = nil
ApplicationRecord.transaction do
status = account.statuses.create!(text: text,
thread: in_reply_to,
sensitive: options[:sensitive],
spoiler_text: options[:spoiler_text] || '',
visibility: options[:visibility],
language: detect_language_for(text, account),
application: options[:application])
attach_media(status, media)
end
process_mentions_service.call(status)
process_hashtags_service.call(status)

Loading…
Cancel
Save