Merge branch 'fix-recipients-from-activity' into 'develop'
Fix duplicate recipients from activity See merge request pleroma/pleroma!1921
This commit is contained in:
commit
1a60215076
|
@ -175,6 +175,7 @@ defp compose_query({:recipients_from_activity, to}, query) do
|
||||||
[u, following: f, relationships: r],
|
[u, following: f, relationships: r],
|
||||||
u.ap_id in ^to or (f.follower_address in ^to and r.state == "accept")
|
u.ap_id in ^to or (f.follower_address in ^to and r.state == "accept")
|
||||||
)
|
)
|
||||||
|
|> distinct(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp compose_query({:order_by, key}, query) do
|
defp compose_query({:order_by, key}, query) do
|
||||||
|
|
|
@ -878,7 +878,8 @@ test "it imports user blocks from list" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "get recipients from activity" do
|
describe "get_recipients_from_activity" do
|
||||||
|
test "get recipients" do
|
||||||
actor = insert(:user)
|
actor = insert(:user)
|
||||||
user = insert(:user, local: true)
|
user = insert(:user, local: true)
|
||||||
user_two = insert(:user, local: false)
|
user_two = insert(:user, local: false)
|
||||||
|
@ -901,6 +902,28 @@ test "get recipients from activity" do
|
||||||
assert addressed in recipients
|
assert addressed in recipients
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "has following" do
|
||||||
|
actor = insert(:user)
|
||||||
|
user = insert(:user)
|
||||||
|
user_two = insert(:user)
|
||||||
|
addressed = insert(:user, local: true)
|
||||||
|
|
||||||
|
{:ok, activity} =
|
||||||
|
CommonAPI.post(actor, %{
|
||||||
|
"status" => "hey @#{addressed.nickname}"
|
||||||
|
})
|
||||||
|
|
||||||
|
assert Enum.map([actor, addressed], & &1.ap_id) --
|
||||||
|
Enum.map(User.get_recipients_from_activity(activity), & &1.ap_id) == []
|
||||||
|
|
||||||
|
{:ok, _actor} = User.follow(actor, user)
|
||||||
|
{:ok, _actor} = User.follow(actor, user_two)
|
||||||
|
recipients = User.get_recipients_from_activity(activity)
|
||||||
|
assert length(recipients) == 2
|
||||||
|
assert addressed in recipients
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe ".deactivate" do
|
describe ".deactivate" do
|
||||||
test "can de-activate then re-activate a user" do
|
test "can de-activate then re-activate a user" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
Loading…
Reference in New Issue