Merge branch 'fix-searching-following' into 'develop'
search: fix 'following' query parameter See merge request pleroma/pleroma!2943
This commit is contained in:
commit
96de4bfbca
3 changed files with 18 additions and 13 deletions
|
@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
|
## unreleased-patch - ???
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Mastodon API: Search parameter `following` now correctly returns the followings rather than the followers
|
||||||
|
|
||||||
## [2.1.0] - 2020-08-28
|
## [2.1.0] - 2020-08-28
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -116,7 +116,7 @@ defp trigram_rank(query, query_string) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp base_query(_user, false), do: User
|
defp base_query(_user, false), do: User
|
||||||
defp base_query(user, true), do: User.get_followers_query(user)
|
defp base_query(user, true), do: User.get_friends_query(user)
|
||||||
|
|
||||||
defp filter_invisible_users(query) do
|
defp filter_invisible_users(query) do
|
||||||
from(q in query, where: q.invisible == false)
|
from(q in query, where: q.invisible == false)
|
||||||
|
|
|
@ -109,22 +109,22 @@ test "finds users, boosting ranks of friends and followers" do
|
||||||
Enum.map(User.search("doe", resolve: false, for_user: u1), & &1.id) == []
|
Enum.map(User.search("doe", resolve: false, for_user: u1), & &1.id) == []
|
||||||
end
|
end
|
||||||
|
|
||||||
test "finds followers of user by partial name" do
|
test "finds followings of user by partial name" do
|
||||||
u1 = insert(:user)
|
lizz = insert(:user, %{name: "Lizz"})
|
||||||
u2 = insert(:user, %{name: "Jimi"})
|
jimi = insert(:user, %{name: "Jimi"})
|
||||||
follower_jimi = insert(:user, %{name: "Jimi Hendrix"})
|
following_lizz = insert(:user, %{name: "Jimi Hendrix"})
|
||||||
follower_lizz = insert(:user, %{name: "Lizz Wright"})
|
following_jimi = insert(:user, %{name: "Lizz Wright"})
|
||||||
friend = insert(:user, %{name: "Jimi"})
|
follower_lizz = insert(:user, %{name: "Jimi"})
|
||||||
|
|
||||||
{:ok, follower_jimi} = User.follow(follower_jimi, u1)
|
{:ok, lizz} = User.follow(lizz, following_lizz)
|
||||||
{:ok, _follower_lizz} = User.follow(follower_lizz, u2)
|
{:ok, _jimi} = User.follow(jimi, following_jimi)
|
||||||
{:ok, u1} = User.follow(u1, friend)
|
{:ok, _follower_lizz} = User.follow(follower_lizz, lizz)
|
||||||
|
|
||||||
assert Enum.map(User.search("jimi", following: true, for_user: u1), & &1.id) == [
|
assert Enum.map(User.search("jimi", following: true, for_user: lizz), & &1.id) == [
|
||||||
follower_jimi.id
|
following_lizz.id
|
||||||
]
|
]
|
||||||
|
|
||||||
assert User.search("lizz", following: true, for_user: u1) == []
|
assert User.search("lizz", following: true, for_user: lizz) == []
|
||||||
end
|
end
|
||||||
|
|
||||||
test "find local and remote users for authenticated users" do
|
test "find local and remote users for authenticated users" do
|
||||||
|
|
Loading…
Reference in a new issue