diff options
author | Rakib Hasan <rmhasan@gmail.com> | 2017-02-02 23:10:17 -0500 |
---|---|---|
committer | Rakib Hasan <rmhasan@gmail.com> | 2017-02-19 08:28:33 +0000 |
commit | 6f9ecd899e9e7cb335940465c23dd53acc37269c (patch) | |
tree | d24913f5708b149797a4b94589c075635c9260ee /app/services | |
parent | 6d2301988fdc0118c5583f48ba6da4a3b8247ba4 (diff) |
revisted fix for #462
Moved validation to services/post_status_service.rb
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/post_status_service.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 979941c84..d70103547 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -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 |