Skip to content

Commit

Permalink
Don't crash site
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed May 15, 2024
1 parent 691093f commit b65f1f6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def check_image
payload = { inputs: [ { data: { image: { url: image_url_cdn } } } ] }.to_json
res = JSON.parse(RestClient.post(url, payload, headers))
nsfw_percent = res.try(:[], 'outputs')&.first.try(:[], 'data').try(:[], 'concepts')&.second.try(:[], 'value')
if nsfw_percent >= ENV['CLARIFAI_THRESHOLD'].to_f
if nsfw_percent.present? && nsfw_percent >= ENV['CLARIFAI_THRESHOLD'].to_f
Sentry.set_user(id: user.id, email: user.email)
Sentry.set_tags(plan: user.plan)
Sentry.capture_message("Clarifai Flagged", level: :warning, extra: { entry_id: id, nsfw_pct: "#{(nsfw_percent*100).round(1)}%", image: image_url_cdn, clarifai: res })
Expand Down

0 comments on commit b65f1f6

Please sign in to comment.