Merge branch 'fix/user-search-null-name' into 'develop'

fix user search results for users with unset display name

Closes #499

See merge request pleroma/pleroma!625
This commit is contained in:
kaniini 2019-01-05 22:34:47 +00:00
commit 8d047c7a72
2 changed files with 11 additions and 1 deletions

View file

@ -610,7 +610,7 @@ def search(query, resolve \\ false) do
select_merge: %{
search_distance:
fragment(
"? <-> (? || ?)",
"? <-> (? || coalesce(?, ''))",
^query,
u.nickname,
u.name

View file

@ -756,5 +756,15 @@ test "finds a user, ranking by similarity" do
assert user_four ==
User.search("lain@ple") |> List.first() |> Map.put(:search_distance, nil)
end
test "finds a user whose name is nil" do
_user = insert(:user, %{name: "notamatch", nickname: "testuser@pleroma.amplifie.red"})
user_two = insert(:user, %{name: nil, nickname: "lain@pleroma.soykaf.com"})
assert user_two ==
User.search("lain@pleroma.soykaf.com")
|> List.first()
|> Map.put(:search_distance, nil)
end
end
end