show reply / quotes for bsky posts

This commit is contained in:
Dylan Knutson
2025-08-12 18:31:17 +00:00
parent 127dd9be51
commit d08c896d97
5 changed files with 164 additions and 0 deletions

View File

@@ -4,6 +4,32 @@ class Domain::Post::BlueskyPost < Domain::Post
belongs_to :first_seen_entry, class_name: "::HttpLogEntry", optional: true
belongs_to :quoted_post,
class_name: "Domain::Post::BlueskyPost",
optional: true,
foreign_key: :quote_uri,
primary_key: :at_uri,
inverse_of: :quoting_posts
has_many :quoting_posts,
class_name: "Domain::Post::BlueskyPost",
foreign_key: :quote_uri,
primary_key: :at_uri,
inverse_of: :quoted_post
belongs_to :replying_to_post,
class_name: "Domain::Post::BlueskyPost",
optional: true,
foreign_key: :reply_to_uri,
primary_key: :at_uri,
inverse_of: :replying_posts
has_many :replying_posts,
class_name: "Domain::Post::BlueskyPost",
foreign_key: :reply_to_uri,
primary_key: :at_uri,
inverse_of: :replying_to_post
has_multiple_files! Domain::PostFile::BlueskyPostFile
has_single_creator! Domain::User::BlueskyUser
has_faving_users! Domain::User::BlueskyUser
@@ -56,6 +82,11 @@ class Domain::Post::BlueskyPost < Domain::Post
self.rkey
end
sig { override.returns(T.nilable(String)) }
def primary_creator_name_fallback_for_view
self.creator&.handle
end
sig { override.returns(T.nilable(Addressable::URI)) }
def external_url_for_view
handle = self.creator&.handle

View File

@@ -0,0 +1,27 @@
<% post = T.cast(post, Domain::Post::BlueskyPost) %>
<% if (quoted_post = post.quoted_post) %>
<span class="flex items-center">
<i class="fa-solid fa-quote-left mr-1"></i>
<%= render(
"domain/has_description_html/inline_link_domain_post",
post: quoted_post,
visual_style: "sky-link",
domain_icon: false,
link_text: "Quoted by #{post.primary_creator_name_fallback_for_view}"
)
%>
</span>
<% end %>
<% if (replying_to_post = post.replying_to_post) %>
<span class="flex items-center">
<i class="fa-solid fa-reply mr-1"></i>
<%= render(
"domain/has_description_html/inline_link_domain_post",
post: replying_to_post,
visual_style: "sky-link",
domain_icon: false,
link_text: "Replied to #{post.primary_creator_name_fallback_for_view}"
)
%>
</span>
<% end %>

View File

@@ -0,0 +1,9 @@
# typed: true
# frozen_string_literal: true
class AddIndexesToQuoteAndReplyBskyPosts < ActiveRecord::Migration[7.2]
sig { void }
def change
add_index :domain_posts_bluesky_aux, :quote_uri
add_index :domain_posts_bluesky_aux, :reply_to_uri
end
end

View File

@@ -4394,6 +4394,20 @@ CREATE INDEX index_domain_posts_bluesky_aux_on_base_table_id ON public.domain_po
CREATE INDEX index_domain_posts_bluesky_aux_on_first_seen_entry_id ON public.domain_posts_bluesky_aux USING btree (first_seen_entry_id);
--
-- Name: index_domain_posts_bluesky_aux_on_quote_uri; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_domain_posts_bluesky_aux_on_quote_uri ON public.domain_posts_bluesky_aux USING btree (quote_uri);
--
-- Name: index_domain_posts_bluesky_aux_on_reply_to_uri; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_domain_posts_bluesky_aux_on_reply_to_uri ON public.domain_posts_bluesky_aux USING btree (reply_to_uri);
--
-- Name: index_domain_posts_e621_aux_on_base_table_id; Type: INDEX; Schema: public; Owner: -
--
@@ -5852,6 +5866,7 @@ ALTER TABLE ONLY public.domain_twitter_tweets
SET search_path TO "$user", public;
INSERT INTO "schema_migrations" (version) VALUES
('20250812182033'),
('20250811172839'),
('20250808004604'),
('20250805200056'),

View File

@@ -487,6 +487,12 @@ class Domain::Post::BlueskyPost
sig { params(args: T.untyped, blk: T.untyped).returns(::Domain::UserPostCreation) }
def build_primary_user_post_creation(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(::Domain::Post::BlueskyPost) }
def build_quoted_post(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(::Domain::Post::BlueskyPost) }
def build_replying_to_post(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(::DomainPostsBlueskyAux) }
def create_bluesky_aux(*args, &blk); end
@@ -517,6 +523,18 @@ class Domain::Post::BlueskyPost
sig { params(args: T.untyped, blk: T.untyped).returns(::Domain::UserPostCreation) }
def create_primary_user_post_creation!(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(::Domain::Post::BlueskyPost) }
def create_quoted_post(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(::Domain::Post::BlueskyPost) }
def create_quoted_post!(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(::Domain::Post::BlueskyPost) }
def create_replying_to_post(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(::Domain::Post::BlueskyPost) }
def create_replying_to_post!(*args, &blk); end
sig { returns(T.nilable(::Domain::User::BlueskyUser)) }
def creator; end
@@ -575,6 +593,32 @@ class Domain::Post::BlueskyPost
sig { params(value: T.nilable(::Domain::UserPostCreation)).void }
def primary_user_post_creation=(value); end
sig { returns(T.nilable(::Domain::Post::BlueskyPost)) }
def quoted_post; end
sig { params(value: T.nilable(::Domain::Post::BlueskyPost)).void }
def quoted_post=(value); end
sig { returns(T::Boolean) }
def quoted_post_changed?; end
sig { returns(T::Boolean) }
def quoted_post_previously_changed?; end
sig { returns(T::Array[T.untyped]) }
def quoting_post_ids; end
sig { params(ids: T::Array[T.untyped]).returns(T::Array[T.untyped]) }
def quoting_post_ids=(ids); end
# This method is created by ActiveRecord on the `Domain::Post::BlueskyPost` class because it declared `has_many :quoting_posts`.
# 🔗 [Rails guide for `has_many` association](https://guides.rubyonrails.org/association_basics.html#the-has-many-association)
sig { returns(::Domain::Post::BlueskyPost::PrivateCollectionProxy) }
def quoting_posts; end
sig { params(value: T::Enumerable[::Domain::Post::BlueskyPost]).void }
def quoting_posts=(value); end
sig { returns(T.nilable(::DomainPostsBlueskyAux)) }
def reload_bluesky_aux; end
@@ -590,6 +634,38 @@ class Domain::Post::BlueskyPost
sig { returns(T.nilable(::Domain::UserPostCreation)) }
def reload_primary_user_post_creation; end
sig { returns(T.nilable(::Domain::Post::BlueskyPost)) }
def reload_quoted_post; end
sig { returns(T.nilable(::Domain::Post::BlueskyPost)) }
def reload_replying_to_post; end
sig { returns(T::Array[T.untyped]) }
def replying_post_ids; end
sig { params(ids: T::Array[T.untyped]).returns(T::Array[T.untyped]) }
def replying_post_ids=(ids); end
# This method is created by ActiveRecord on the `Domain::Post::BlueskyPost` class because it declared `has_many :replying_posts`.
# 🔗 [Rails guide for `has_many` association](https://guides.rubyonrails.org/association_basics.html#the-has-many-association)
sig { returns(::Domain::Post::BlueskyPost::PrivateCollectionProxy) }
def replying_posts; end
sig { params(value: T::Enumerable[::Domain::Post::BlueskyPost]).void }
def replying_posts=(value); end
sig { returns(T.nilable(::Domain::Post::BlueskyPost)) }
def replying_to_post; end
sig { params(value: T.nilable(::Domain::Post::BlueskyPost)).void }
def replying_to_post=(value); end
sig { returns(T::Boolean) }
def replying_to_post_changed?; end
sig { returns(T::Boolean) }
def replying_to_post_previously_changed?; end
sig { void }
def reset_bluesky_aux; end
@@ -605,6 +681,12 @@ class Domain::Post::BlueskyPost
sig { void }
def reset_primary_user_post_creation; end
sig { void }
def reset_quoted_post; end
sig { void }
def reset_replying_to_post; end
sig { returns(T::Array[T.untyped]) }
def user_post_creation_ids; end