0
0
Fork 0

revisted fix for #462

Moved validation to services/post_status_service.rb
This commit is contained in:
Rakib Hasan 2017-02-02 23:10:17 -05:00
parent 6d2301988f
commit 6f9ecd899e
4 changed files with 18 additions and 15 deletions

View file

@ -35,8 +35,14 @@ class PostStatusService < BaseService
def attach_media(status, media_ids)
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))
if media.length > 1
media.each do |m|
if m.video?
raise Mastodon::NotPermitted, 'Cannot attach a video to a toot that already contains images'
end
end
end
media.update(status_id: status.id)
end