Skip to content

Commit

Permalink
Handle exceptions when media flagging fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jayjay-w committed Mar 28, 2024
1 parent 0f0174b commit d3570fb
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions app/models/concerns/smooch_blocking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@ def apply_content_warning_to_user_content(uid)
RequestStore.store[:skip_rules] = true
ProjectMedia.joins(:tipline_requests)
.where(tipline_requests: { tipline_user_uid: uid }).find_each do |pm|
flags = { 'spam': 1, 'adult': 0, 'spoof': 0, 'medical': 0, 'violence': 0, 'racy': 0 }
# Add a flag
flag = Dynamic.new
flag.annotation_type = 'flag'
flag.annotated = pm
flag.skip_check_ability = true
flag.set_fields = { show_cover: true, flags: flags }.to_json
flag.save!
begin
flags = { 'spam': 1, 'adult': 0, 'spoof': 0, 'medical': 0, 'violence': 0, 'racy': 0 }
# Add a flag
flag = Dynamic.new
flag.annotation_type = 'flag'
flag.annotated = pm
flag.skip_check_ability = true
flag.set_fields = { show_cover: true, flags: flags }.to_json
flag.save!
rescue StandardError => e
Rails.logger.info "[Smooch Bot] Exception when flagging blocked user's media: #{e.message}"
end
end
RequestStore.store[:skip_rules] = false
end
Expand Down

0 comments on commit d3570fb

Please sign in to comment.