add monitor scanned at to bsky monitor

This commit is contained in:
Dylan Knutson
2025-08-14 17:16:21 +00:00
parent 1d248c1f23
commit cfffe50541
8 changed files with 153 additions and 2 deletions

View File

@@ -61,7 +61,7 @@ module Domain::DescriptionsHelper
ALLOWED_INFERRED_URL_DOMAINS =
T.let(
%w[furaffinity.net inkbunny.net e621.net]
%w[furaffinity.net inkbunny.net e621.net bsky.app]
.flat_map { |domain| [domain, "www.#{domain}"] }
.freeze,
T::Array[String],

View File

@@ -96,6 +96,7 @@ module Tasks::Bluesky
post.posted_at = msg.time.in_time_zone("UTC")
post.creator = creator_for(msg)
post.post_raw = op.raw_record
post.monitor_scanned_at = Time.current
end
process_media(post, embed_data, msg.did)

View File

@@ -8,6 +8,10 @@
class: "text-blue-600 hover:underline",
target: "_blank",
title: scanned_hle.requested_at.strftime("%Y-%m-%d %H:%M:%S") %>
<% elsif post.is_a?(Domain::Post::BlueskyPost) && (sa = post.monitor_scanned_at)%>
<span title="<%= sa.strftime("%Y-%m-%d %H:%M:%S") %>">
Scanned via monitor <%= time_ago_in_words(sa) %> ago
</span>
<% else %>
Unknown when post scanned
<% end %>

View File

@@ -0,0 +1,7 @@
# typed: strict
class AddMonitorScannedAtToBskyAux < ActiveRecord::Migration[7.2]
sig { void }
def change
add_column :domain_posts_bluesky_aux, :monitor_scanned_at, :datetime
end
end

View File

@@ -1425,7 +1425,8 @@ CREATE TABLE public.domain_posts_bluesky_aux (
quote_uri character varying,
post_raw jsonb DEFAULT '{}'::jsonb,
first_seen_entry_id bigint,
scan_error character varying
scan_error character varying,
monitor_scanned_at timestamp(6) without time zone
);
@@ -6113,6 +6114,7 @@ ALTER TABLE ONLY public.domain_twitter_tweets
SET search_path TO "$user", public;
INSERT INTO "schema_migrations" (version) VALUES
('20250814170820'),
('20250814165718'),
('20250814152837'),
('20250813190947'),

View File

@@ -1435,6 +1435,61 @@ class Domain::Post::BlueskyPost
sig { void }
def mentions_will_change!; end
sig { returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at; end
sig { params(value: T.nilable(::ActiveSupport::TimeWithZone)).returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at=(value); end
sig { returns(T::Boolean) }
def monitor_scanned_at?; end
sig { returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at_before_last_save; end
sig { returns(T.untyped) }
def monitor_scanned_at_before_type_cast; end
sig { returns(T::Boolean) }
def monitor_scanned_at_came_from_user?; end
sig { returns(T.nilable([T.nilable(::ActiveSupport::TimeWithZone), T.nilable(::ActiveSupport::TimeWithZone)])) }
def monitor_scanned_at_change; end
sig { returns(T.nilable([T.nilable(::ActiveSupport::TimeWithZone), T.nilable(::ActiveSupport::TimeWithZone)])) }
def monitor_scanned_at_change_to_be_saved; end
sig do
params(
from: T.nilable(::ActiveSupport::TimeWithZone),
to: T.nilable(::ActiveSupport::TimeWithZone)
).returns(T::Boolean)
end
def monitor_scanned_at_changed?(from: T.unsafe(nil), to: T.unsafe(nil)); end
sig { returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at_in_database; end
sig { returns(T.nilable([T.nilable(::ActiveSupport::TimeWithZone), T.nilable(::ActiveSupport::TimeWithZone)])) }
def monitor_scanned_at_previous_change; end
sig do
params(
from: T.nilable(::ActiveSupport::TimeWithZone),
to: T.nilable(::ActiveSupport::TimeWithZone)
).returns(T::Boolean)
end
def monitor_scanned_at_previously_changed?(from: T.unsafe(nil), to: T.unsafe(nil)); end
sig { returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at_previously_was; end
sig { returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at_was; end
sig { void }
def monitor_scanned_at_will_change!; end
sig { returns(T.untyped) }
def post_raw; end
@@ -1796,6 +1851,9 @@ class Domain::Post::BlueskyPost
sig { void }
def restore_mentions!; end
sig { void }
def restore_monitor_scanned_at!; end
sig { void }
def restore_post_raw!; end
@@ -1952,6 +2010,12 @@ class Domain::Post::BlueskyPost
sig { returns(T::Boolean) }
def saved_change_to_mentions?; end
sig { returns(T.nilable([T.nilable(::ActiveSupport::TimeWithZone), T.nilable(::ActiveSupport::TimeWithZone)])) }
def saved_change_to_monitor_scanned_at; end
sig { returns(T::Boolean) }
def saved_change_to_monitor_scanned_at?; end
sig { returns(T.nilable([T.untyped, T.untyped])) }
def saved_change_to_post_raw; end
@@ -2301,6 +2365,9 @@ class Domain::Post::BlueskyPost
sig { returns(T::Boolean) }
def will_save_change_to_mentions?; end
sig { returns(T::Boolean) }
def will_save_change_to_monitor_scanned_at?; end
sig { returns(T::Boolean) }
def will_save_change_to_post_raw?; end

View File

@@ -1048,6 +1048,61 @@ class DomainPostsBlueskyAux
sig { void }
def mentions_will_change!; end
sig { returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at; end
sig { params(value: T.nilable(::ActiveSupport::TimeWithZone)).returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at=(value); end
sig { returns(T::Boolean) }
def monitor_scanned_at?; end
sig { returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at_before_last_save; end
sig { returns(T.untyped) }
def monitor_scanned_at_before_type_cast; end
sig { returns(T::Boolean) }
def monitor_scanned_at_came_from_user?; end
sig { returns(T.nilable([T.nilable(::ActiveSupport::TimeWithZone), T.nilable(::ActiveSupport::TimeWithZone)])) }
def monitor_scanned_at_change; end
sig { returns(T.nilable([T.nilable(::ActiveSupport::TimeWithZone), T.nilable(::ActiveSupport::TimeWithZone)])) }
def monitor_scanned_at_change_to_be_saved; end
sig do
params(
from: T.nilable(::ActiveSupport::TimeWithZone),
to: T.nilable(::ActiveSupport::TimeWithZone)
).returns(T::Boolean)
end
def monitor_scanned_at_changed?(from: T.unsafe(nil), to: T.unsafe(nil)); end
sig { returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at_in_database; end
sig { returns(T.nilable([T.nilable(::ActiveSupport::TimeWithZone), T.nilable(::ActiveSupport::TimeWithZone)])) }
def monitor_scanned_at_previous_change; end
sig do
params(
from: T.nilable(::ActiveSupport::TimeWithZone),
to: T.nilable(::ActiveSupport::TimeWithZone)
).returns(T::Boolean)
end
def monitor_scanned_at_previously_changed?(from: T.unsafe(nil), to: T.unsafe(nil)); end
sig { returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at_previously_was; end
sig { returns(T.nilable(::ActiveSupport::TimeWithZone)) }
def monitor_scanned_at_was; end
sig { void }
def monitor_scanned_at_will_change!; end
sig { returns(T.untyped) }
def post_raw; end
@@ -1345,6 +1400,9 @@ class DomainPostsBlueskyAux
sig { void }
def restore_mentions!; end
sig { void }
def restore_monitor_scanned_at!; end
sig { void }
def restore_post_raw!; end
@@ -1474,6 +1532,12 @@ class DomainPostsBlueskyAux
sig { returns(T::Boolean) }
def saved_change_to_mentions?; end
sig { returns(T.nilable([T.nilable(::ActiveSupport::TimeWithZone), T.nilable(::ActiveSupport::TimeWithZone)])) }
def saved_change_to_monitor_scanned_at; end
sig { returns(T::Boolean) }
def saved_change_to_monitor_scanned_at?; end
sig { returns(T.nilable([T.untyped, T.untyped])) }
def saved_change_to_post_raw; end
@@ -1706,6 +1770,9 @@ class DomainPostsBlueskyAux
sig { returns(T::Boolean) }
def will_save_change_to_mentions?; end
sig { returns(T::Boolean) }
def will_save_change_to_monitor_scanned_at?; end
sig { returns(T::Boolean) }
def will_save_change_to_post_raw?; end

View File

@@ -103,6 +103,9 @@ RSpec.describe Tasks::Bluesky::Monitor do
expect(post.text).to eq("Check out this image!")
expect(post.rkey).to eq("test123")
expect(post.posted_at).to eq(base_time)
expect(post.monitor_scanned_at).to be_within(10.seconds).of(
Time.current,
)
files = post.files.order(:file_order)
expect(files.count).to eq(2)