bsky page scanning auditing

This commit is contained in:
Dylan Knutson
2025-08-12 21:56:05 +00:00
parent 2de7f85a99
commit 420a44a27d
18 changed files with 436 additions and 5 deletions

View File

@@ -203,6 +203,27 @@ module Domain::UsersHelper
due_for_scan ? "fa-hourglass-half" : "fa-check"
end
if user.is_a?(Domain::User::BlueskyUser) && can_view_timestamps
rows << StatRow.new(
name: "Page scanned",
value: user.profile_scan,
link_to:
user.last_scan_log_entry && log_entry_path(user.last_scan_log_entry),
fa_icon_class: icon_for.call(user.profile_scan.due?),
hover_title: user.profile_scan.interval.inspect,
)
rows << StatRow.new(
name: "Posts scanned",
value: user.posts_scan,
link_to:
user.last_posts_scan_log_entry &&
log_entry_path(user.last_posts_scan_log_entry),
fa_icon_class: icon_for.call(user.posts_scan.due?),
hover_title: user.posts_scan.interval.inspect,
)
end
if user.is_a?(Domain::User::FaUser) && can_view_timestamps
if can_view_log_entries && hle = user.guess_last_user_page_log_entry
rows << StatRow.new(

View File

@@ -29,6 +29,7 @@ class Domain::Bluesky::Job::ScanPostsJob < Domain::Bluesky::Job::Base
end
scan_user_posts(user)
user.last_posts_scan_log_entry = first_log_entry
logger.info(format_tags("completed posts scan"))
ensure
user.save! if user
@@ -109,6 +110,7 @@ class Domain::Bluesky::Job::ScanPostsJob < Domain::Bluesky::Job::Base
url = cursor ? "#{posts_url}&cursor=#{cursor}" : posts_url
response = http_client.get(url)
num_pages += 1
if response.status_code != 200
fatal_error(

View File

@@ -38,6 +38,7 @@ class Domain::Bluesky::Job::ScanUserJob < Domain::Bluesky::Job::Base
"https://bsky.social/xrpc/com.atproto.repo.getRecord?repo=#{user.did}&collection=app.bsky.actor.profile&rkey=self"
response = http_client.get(profile_url)
user.last_scan_log_entry = response.log_entry
if response.status_code != 200
fatal_error(

View File

@@ -6,7 +6,13 @@ class Domain::User::BlueskyUser < Domain::User
due_timestamp :scanned_posts_at, 3.years
has_created_posts! Domain::Post::BlueskyPost
has_faved_posts! Domain::Post::BlueskyPost
# TODO - when we scrape liked posts, add this back in
# has_faved_posts! Domain::Post::BlueskyPost
belongs_to :last_scan_log_entry, class_name: "HttpLogEntry", optional: true
belongs_to :last_posts_scan_log_entry,
class_name: "HttpLogEntry",
optional: true
enum :state,
{ ok: "ok", account_disabled: "account_disabled", error: "error" },

View File

@@ -0,0 +1,6 @@
<% cache [user, "overview_details"] do %>
<div class="flex flex-col">
<span class="font-medium italic text-slate-500">State</span>
<span class=""><%= user.account_state_for_view %></span>
</div>
<% end %>

View File

@@ -0,0 +1,34 @@
<section class="sky-section animated-shadow-sky divide-y">
<h2 class="section-header">User Stats</h2>
<% stat_rows_for_user(user).each do |stat_row| %>
<% label = stat_row.name %>
<% value = stat_row.value %>
<% fa_icon_class = stat_row.fa_icon_class %>
<div class="flex items-center px-4 py-2 gap-2">
<span class="grow text-slate-900 truncate"><%= label %></span>
<span class="text-slate-500 relative group">
<% value_str = case value %>
<% when Integer %>
<% number_with_delimiter(value, delimiter: ",") %>
<% when HasTimestampsWithDueAt::TimestampScanInfo %>
<% value.ago_in_words %>
<% else %>
<% value %>
<% end %>
<% if stat_row.link_to %>
<%= link_to value_str, stat_row.link_to, class: "blue-link" %>
<% else %>
<%= value_str %>
<% end %>
<% if fa_icon_class %>
<i class="fa-solid <%= fa_icon_class %>"></i>
<% end %>
<% if stat_row.hover_title %>
<div class="absolute hidden group-hover:block bg-slate-800 text-white text-sm rounded px-2 py-1 top-1/2 -translate-y-1/2 right-full mr-2 whitespace-nowrap">
<%= stat_row.hover_title %>
</div>
<% end %>
</span>
</div>
<% end %>
</section>