handle 400 response for users from bsky
This commit is contained in:
@@ -114,6 +114,15 @@ class Domain::Bluesky::Job::ScanPostsJob < Domain::Bluesky::Job::Base
|
||||
posts_scan.update!(log_entry: response.log_entry) if num_pages == 0
|
||||
|
||||
num_pages += 1
|
||||
if response.status_code == 400
|
||||
error = JSON.parse(response.body)["error"]
|
||||
if error == "InvalidRequest"
|
||||
logger.error(format_tags("account is disabled / does not exist"))
|
||||
user.state = "account_disabled"
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if response.status_code != 200
|
||||
fatal_error(
|
||||
format_tags(
|
||||
|
||||
@@ -8,6 +8,11 @@ class Domain::Bluesky::Job::ScanUserJob < Domain::Bluesky::Job::Base
|
||||
logger.push_tags(make_arg_tag(user))
|
||||
logger.info(format_tags("starting profile scan"))
|
||||
|
||||
if user.state_account_disabled? && !force_scan?
|
||||
logger.info(format_tags("account is disabled, skipping profile scan"))
|
||||
return
|
||||
end
|
||||
|
||||
if !user.profile_scan.due? && !force_scan?
|
||||
logger.info(
|
||||
format_tags(
|
||||
@@ -19,6 +24,7 @@ class Domain::Bluesky::Job::ScanUserJob < Domain::Bluesky::Job::Base
|
||||
end
|
||||
|
||||
scan_user_profile(user)
|
||||
user.scanned_profile_at = Time.zone.now
|
||||
logger.info(format_tags("completed profile scan"))
|
||||
ensure
|
||||
user.save! if user
|
||||
@@ -39,6 +45,15 @@ class Domain::Bluesky::Job::ScanUserJob < Domain::Bluesky::Job::Base
|
||||
user.last_scan_log_entry = response.log_entry
|
||||
profile_scan.update!(log_entry: response.log_entry)
|
||||
|
||||
if response.status_code == 400
|
||||
error = JSON.parse(response.body)["error"]
|
||||
if error == "InvalidRequest"
|
||||
logger.error(format_tags("account is disabled / does not exist"))
|
||||
user.state = "account_disabled"
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if response.status_code != 200
|
||||
fatal_error(
|
||||
format_tags(
|
||||
@@ -90,8 +105,6 @@ class Domain::Bluesky::Job::ScanUserJob < Domain::Bluesky::Job::Base
|
||||
# Process avatar if present
|
||||
process_user_avatar_url(user, record["avatar"]) if record["avatar"]
|
||||
end
|
||||
|
||||
user.scanned_profile_at = Time.zone.now
|
||||
end
|
||||
|
||||
sig do
|
||||
|
||||
Reference in New Issue
Block a user