Skip to content

Commit

Permalink
Move media annotation when blocking user to the background
Browse files Browse the repository at this point in the history
  • Loading branch information
jayjay-w committed Mar 4, 2024
1 parent 5dff767 commit 8006cc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/smooch_blocking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def block_user(uid)
block.save!
Rails.logger.info("[Smooch Bot] Blocked user #{uid}")
Rails.cache.write("smooch:banned:#{uid}", Time.now.to_i)
apply_content_warning_to_user_content(uid)
self.delay.apply_content_warning_to_user_content(uid)
rescue ActiveRecord::RecordNotUnique
# User already blocked
Rails.logger.info("[Smooch Bot] User #{uid} already blocked")
Expand Down Expand Up @@ -57,7 +57,7 @@ def apply_content_warning_to_user_content(uid)
'racy': 0,
'spam': 1
}
Dynamic.delay.create!(annotation_type: 'flag', annotated: pm, annotator: current_user, skip_check_ability: true, set_fields: { show_cover: true, flags: flags }.to_json)
Dynamic.create!(annotation_type: 'flag', annotated: pm, annotator: User.current, skip_check_ability: true, set_fields: { show_cover: true, flags: flags }.to_json)
end
RequestStore.store[:skip_rules] = false
end
Expand Down
6 changes: 4 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@
t.index ["field_type"], name: "index_dynamic_annotation_fields_on_field_type"
t.index ["value"], name: "fetch_unique_id", unique: true, where: "(((field_name)::text = 'external_id'::text) AND (value <> ''::text) AND (value <> '\"\"'::text))"
t.index ["value"], name: "index_status", where: "((field_name)::text = 'verification_status_status'::text)"
t.index ["value"], name: "smooch_request_message_id_unique_id", unique: true, where: "(((field_name)::text = 'smooch_message_id'::text) AND (value <> ''::text) AND (value <> '\"\"'::text))"
t.index ["value"], name: "smooch_user_unique_id", unique: true, where: "(((field_name)::text = 'smooch_user_id'::text) AND (value <> ''::text) AND (value <> '\"\"'::text))"
t.index ["value"], name: "translation_request_id", unique: true, where: "((field_name)::text = 'translation_request_id'::text)"
t.index ["value_json"], name: "index_dynamic_annotation_fields_on_value_json", using: :gin
Expand Down Expand Up @@ -468,7 +469,7 @@
t.index ["user_id"], name: "index_project_media_users_on_user_id"
end

create_table "project_medias", force: :cascade do |t|
create_table "project_medias", id: :serial, force: :cascade do |t|
t.integer "project_id"
t.integer "media_id"
t.integer "user_id"
Expand Down Expand Up @@ -860,7 +861,8 @@
end

create_table "versions", id: :serial, force: :cascade do |t|
t.string "item_type", null: false
t.string "item_type"
t.string "{:null=>false}"
t.string "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
Expand Down

0 comments on commit 8006cc4

Please sign in to comment.