forked from AkkomaGang/akkoma
Merge branch 'bugfix/actor-containment' into 'develop'
activitypub: correctly handle bare URIs in user lookup Closes #645 See merge request pleroma/pleroma!829
This commit is contained in:
commit
b63a5e309d
3 changed files with 12 additions and 4 deletions
|
@ -731,7 +731,7 @@ def search(query, resolve \\ false, for_user \\ nil) do
|
||||||
# Strip the beginning @ off if there is a query
|
# Strip the beginning @ off if there is a query
|
||||||
query = String.trim_leading(query, "@")
|
query = String.trim_leading(query, "@")
|
||||||
|
|
||||||
if resolve, do: User.get_or_fetch_by_nickname(query)
|
if resolve, do: get_or_fetch(query)
|
||||||
|
|
||||||
fts_results = do_search(fts_search_subquery(query), for_user)
|
fts_results = do_search(fts_search_subquery(query), for_user)
|
||||||
|
|
||||||
|
|
|
@ -818,8 +818,6 @@ def fetch_object_from_id(id) do
|
||||||
if object = Object.get_cached_by_ap_id(id) do
|
if object = Object.get_cached_by_ap_id(id) do
|
||||||
{:ok, object}
|
{:ok, object}
|
||||||
else
|
else
|
||||||
Logger.info("Fetching #{id} via AP")
|
|
||||||
|
|
||||||
with {:ok, data} <- fetch_and_contain_remote_object_from_id(id),
|
with {:ok, data} <- fetch_and_contain_remote_object_from_id(id),
|
||||||
nil <- Object.normalize(data),
|
nil <- Object.normalize(data),
|
||||||
params <- %{
|
params <- %{
|
||||||
|
@ -851,7 +849,7 @@ def fetch_object_from_id(id) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_and_contain_remote_object_from_id(id) do
|
def fetch_and_contain_remote_object_from_id(id) do
|
||||||
Logger.info("Fetching #{id} via AP")
|
Logger.info("Fetching object #{id} via AP")
|
||||||
|
|
||||||
with true <- String.starts_with?(id, "http"),
|
with true <- String.starts_with?(id, "http"),
|
||||||
{:ok, %{body: body, status: code}} when code in 200..299 <-
|
{:ok, %{body: body, status: code}} when code in 200..299 <-
|
||||||
|
|
|
@ -878,6 +878,16 @@ test "does not yield false-positive matches" do
|
||||||
assert [] == User.search(query)
|
assert [] == User.search(query)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "works with URIs" do
|
||||||
|
results = User.search("http://mastodon.example.org/users/admin", true)
|
||||||
|
result = results |> List.first()
|
||||||
|
|
||||||
|
user = User.get_by_ap_id("http://mastodon.example.org/users/admin")
|
||||||
|
|
||||||
|
assert length(results) == 1
|
||||||
|
assert user == result |> Map.put(:search_rank, nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "auth_active?/1 works correctly" do
|
test "auth_active?/1 works correctly" do
|
||||||
|
|
Loading…
Reference in a new issue