mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
previous commit was creating the status regardless
of mix of video and images in status, just wasn't rendering the show action. I moved the validation before the status creation
This commit is contained in:
parent
6f9ecd899e
commit
87a6bed9e9
@ -13,6 +13,7 @@ class PostStatusService < BaseService
|
|||||||
# @option [Doorkeeper::Application] :application
|
# @option [Doorkeeper::Application] :application
|
||||||
# @return [Status]
|
# @return [Status]
|
||||||
def call(account, text, in_reply_to = nil, options = {})
|
def call(account, text, in_reply_to = nil, options = {})
|
||||||
|
media = validate_media options[:media_ids]
|
||||||
status = account.statuses.create!(text: text,
|
status = account.statuses.create!(text: text,
|
||||||
thread: in_reply_to,
|
thread: in_reply_to,
|
||||||
sensitive: options[:sensitive],
|
sensitive: options[:sensitive],
|
||||||
@ -20,7 +21,7 @@ class PostStatusService < BaseService
|
|||||||
visibility: options[:visibility],
|
visibility: options[:visibility],
|
||||||
application: options[:application])
|
application: options[:application])
|
||||||
|
|
||||||
attach_media(status, options[:media_ids])
|
attach_media(status, media)
|
||||||
process_mentions_service.call(status)
|
process_mentions_service.call(status)
|
||||||
process_hashtags_service.call(status)
|
process_hashtags_service.call(status)
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ class PostStatusService < BaseService
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def attach_media(status, media_ids)
|
def validate_media(media_ids)
|
||||||
return if media_ids.nil? || !media_ids.is_a?(Enumerable)
|
return if media_ids.nil? || !media_ids.is_a?(Enumerable)
|
||||||
media = MediaAttachment.where(status_id: nil).where(id: media_ids.take(4).map(&:to_i))
|
media = MediaAttachment.where(status_id: nil).where(id: media_ids.take(4).map(&:to_i))
|
||||||
if media.length > 1
|
if media.length > 1
|
||||||
@ -43,6 +44,11 @@ class PostStatusService < BaseService
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return media
|
||||||
|
end
|
||||||
|
|
||||||
|
def attach_media(status, media)
|
||||||
|
return if media.nil?
|
||||||
media.update(status_id: status.id)
|
media.update(status_id: status.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user