Welcome to mirror list, hosted at ThFree Co, Russian Federation.

process_photo.rb « workers « app - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9b12bd8f4ea7d5fb315f85b6438f57febee52c89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.


module Workers
  class ProcessPhoto < Base
    sidekiq_options queue: :low

    def perform(id)
      photo = Photo.find(id)
      unprocessed_image = photo.unprocessed_image

      return false if photo.processed? || unprocessed_image.path.try(:include?, ".gif")

      photo.processed_image.store!(unprocessed_image)
      photo.save!
    rescue ActiveRecord::RecordNotFound # Deleted before the job was run
      # Ignored
    end
  end
end