Class: RailsImagePostSolution::ImageModerationJob
- Inherits:
-
ApplicationJob
- Object
- ApplicationJob
- RailsImagePostSolution::ImageModerationJob
- Defined in:
- app/jobs/rails_image_post_solution/image_moderation_job.rb
Instance Method Summary collapse
-
#perform(attachment_id) ⇒ Object
Job to perform automatic image moderation Uses OpenAI Vision API to detect R18/R18G content.
Instance Method Details
#perform(attachment_id) ⇒ Object
Job to perform automatic image moderation Uses OpenAI Vision API to detect R18/R18G content
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/jobs/rails_image_post_solution/image_moderation_job.rb', line 9 def perform() = ActiveStorage::Attachment.find_by(id: ) return unless &.blob # Analyze image using OpenAI Vision Service result = OpenaiVisionService.new.moderate_image() # Process results if result[:flagged] # Create automatic report when inappropriate content is detected create_auto_report(, result) # Temporarily freeze post (if enabled in config) freeze_post(, result) if auto_freeze_enabled? end Rails.logger.info "Image moderation completed for attachment ##{attachment_id}: #{result[:flagged] ? 'FLAGGED' : 'OK'}" rescue StandardError => e Rails.logger.error "Image moderation failed for attachment ##{attachment_id}: #{e.message}" # Don't fail the job on error (leave for manual review) end |