fix frozen string bug, add bsky username prefix to searched names
This commit is contained in:
@@ -539,7 +539,7 @@ module Domain::PostsHelper
|
|||||||
return nil if source.blank?
|
return nil if source.blank?
|
||||||
|
|
||||||
# normalize the source to a lowercase string with a protocol
|
# normalize the source to a lowercase string with a protocol
|
||||||
source.downcase!
|
source = source.downcase
|
||||||
source = "https://" + source unless source.include?("://")
|
source = "https://" + source unless source.include?("://")
|
||||||
begin
|
begin
|
||||||
uri = URI.parse(source)
|
uri = URI.parse(source)
|
||||||
|
|||||||
@@ -65,7 +65,12 @@ class Domain::User::BlueskyUser < Domain::User
|
|||||||
|
|
||||||
sig { override.returns(T::Array[String]) }
|
sig { override.returns(T::Array[String]) }
|
||||||
def names_for_search
|
def names_for_search
|
||||||
[display_name, handle].compact
|
names = [display_name, handle]
|
||||||
|
if (h = handle)&.ends_with?(".bsky.social")
|
||||||
|
names << h.split(".").first
|
||||||
|
end
|
||||||
|
names << did
|
||||||
|
names.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { override.returns(T.nilable(String)) }
|
sig { override.returns(T.nilable(String)) }
|
||||||
|
|||||||
@@ -19,6 +19,22 @@ RSpec.describe Domain::BlueskyPostHelper, type: :helper do
|
|||||||
"Hello @alice.bsky.social! Check out https://bsky.app/profile/bob.bsky.social/post/abc123 and #hashtag"
|
"Hello @alice.bsky.social! Check out https://bsky.app/profile/bob.bsky.social/post/abc123 and #hashtag"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Shared test data used across multiple contexts
|
||||||
|
let(:linked_user) do
|
||||||
|
create(
|
||||||
|
:domain_user_bluesky_user,
|
||||||
|
handle: "bob.bsky.social",
|
||||||
|
did: "did:plc:bob123",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
let(:linked_post) do
|
||||||
|
create(
|
||||||
|
:domain_post_bluesky_post,
|
||||||
|
rkey: "abc123",
|
||||||
|
at_uri: "at://did:plc:bob123/app.bsky.feed.post/abc123",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
context "when facets is nil" do
|
context "when facets is nil" do
|
||||||
it "returns the original text unchanged" do
|
it "returns the original text unchanged" do
|
||||||
result =
|
result =
|
||||||
@@ -241,13 +257,6 @@ RSpec.describe Domain::BlueskyPostHelper, type: :helper do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "with link facets" do
|
context "with link facets" do
|
||||||
let(:linked_post) do
|
|
||||||
create(
|
|
||||||
:domain_post_bluesky_post,
|
|
||||||
rkey: "abc123",
|
|
||||||
at_uri: "at://did:plc:bob123/app.bsky.feed.post/abc123",
|
|
||||||
)
|
|
||||||
end
|
|
||||||
let(:text) do
|
let(:text) do
|
||||||
"Check out https://bsky.app/profile/bob.bsky.social/post/abc123"
|
"Check out https://bsky.app/profile/bob.bsky.social/post/abc123"
|
||||||
end
|
end
|
||||||
@@ -270,7 +279,10 @@ RSpec.describe Domain::BlueskyPostHelper, type: :helper do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "when linked post exists in database" do
|
context "when linked post exists in database" do
|
||||||
before { linked_post } # Ensure post exists
|
before do
|
||||||
|
linked_user # Ensure user exists
|
||||||
|
linked_post # Ensure post exists
|
||||||
|
end
|
||||||
|
|
||||||
it "renders inline_link_domain_post partial" do
|
it "renders inline_link_domain_post partial" do
|
||||||
expect(helper).to receive(:render).with(
|
expect(helper).to receive(:render).with(
|
||||||
@@ -378,13 +390,6 @@ RSpec.describe Domain::BlueskyPostHelper, type: :helper do
|
|||||||
did: "did:plc:alice123",
|
did: "did:plc:alice123",
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let(:linked_post) do
|
|
||||||
create(
|
|
||||||
:domain_post_bluesky_post,
|
|
||||||
rkey: "abc123",
|
|
||||||
at_uri: "at://did:plc:bob123/app.bsky.feed.post/abc123",
|
|
||||||
)
|
|
||||||
end
|
|
||||||
let(:text) do
|
let(:text) do
|
||||||
"Hey @alice.bsky.social, check https://bsky.app/profile/bob.bsky.social/post/abc123 #cool"
|
"Hey @alice.bsky.social, check https://bsky.app/profile/bob.bsky.social/post/abc123 #cool"
|
||||||
end
|
end
|
||||||
@@ -431,6 +436,7 @@ RSpec.describe Domain::BlueskyPostHelper, type: :helper do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
mentioned_user
|
mentioned_user
|
||||||
|
linked_user
|
||||||
linked_post
|
linked_post
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user