diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/api/salmon_controller.rb | 2 | ||||
-rw-r--r-- | app/models/media_attachment.rb | 2 | ||||
-rw-r--r-- | app/models/status.rb | 1 | ||||
-rw-r--r-- | app/services/process_feed_service.rb | 5 | ||||
-rw-r--r-- | app/views/oauth/authorizations/new.html.haml | 2 | ||||
-rw-r--r-- | app/workers/salmon_worker.rb | 9 |
6 files changed, 16 insertions, 5 deletions
diff --git a/app/controllers/api/salmon_controller.rb b/app/controllers/api/salmon_controller.rb index 01862a900..a7872d542 100644 --- a/app/controllers/api/salmon_controller.rb +++ b/app/controllers/api/salmon_controller.rb @@ -10,7 +10,7 @@ class Api::SalmonController < ApiController if body.nil? head 200 else - ProcessInteractionService.new.call(body, @account) + SalmonWorker.perform_async(@account.id, body.force_encoding('UTF-8')) head 201 end end diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index d3e3d73be..bfbf00d76 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -22,8 +22,6 @@ class MediaAttachment < ApplicationRecord def file_remote_url=(url) self.file = URI.parse(url) - rescue OpenURI::HTTPError => e - Rails.logger.debug "Error fetching remote attachment: #{e}" end def image? diff --git a/app/models/status.rb b/app/models/status.rb index 56f52975d..a5c3e19ba 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -19,6 +19,7 @@ class Status < ApplicationRecord validates :account, presence: true validates :uri, uniqueness: true, unless: 'local?' validates :text, presence: true, length: { maximum: 500 }, if: proc { |s| s.local? && !s.reblog? } + validates :text, presence: true, if: proc { |s| !s.local? && !s.reblog? } validates :reblog, uniqueness: { scope: :account, message: 'of status already exists' }, if: 'reblog?' default_scope { order('id desc') } diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index 561feb032..8daea1675 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -36,6 +36,9 @@ class ProcessFeedService < BaseService when :delete return delete_status end + rescue ActiveRecord::RecordInvalid => e + Rails.logger.debug "Nothing was saved for #{id} because: #{e}" + nil end private @@ -173,7 +176,7 @@ class ProcessFeedService < BaseService begin media.file_remote_url = link['href'] media.save - rescue Paperclip::Errors::NotIdentifiedByImageMagickError + rescue OpenURI::HTTPError, Paperclip::Errors::NotIdentifiedByImageMagickError next end end diff --git a/app/views/oauth/authorizations/new.html.haml b/app/views/oauth/authorizations/new.html.haml index cd6e93e08..f058e2cce 100644 --- a/app/views/oauth/authorizations/new.html.haml +++ b/app/views/oauth/authorizations/new.html.haml @@ -2,7 +2,7 @@ = t('doorkeeper.authorizations.new.title') .oauth-prompt - %h2= t('doorkeeper.authorizations.new.prompt', name: @pre_auth.client.name) + %h2= t('doorkeeper.authorizations.new.prompt', client_name: @pre_auth.client.name) %p = t('doorkeeper.authorizations.new.able_to') diff --git a/app/workers/salmon_worker.rb b/app/workers/salmon_worker.rb new file mode 100644 index 000000000..12b46e92f --- /dev/null +++ b/app/workers/salmon_worker.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class SalmonWorker + include Sidekiq::Worker + + def perform(account_id, body) + ProcessInteractionService.new.call(body, Account.find(account_id)) + end +end |