forked from AkkomaGang/akkoma
Fix posts being streamed to non-local websocket channels.
This commit is contained in:
parent
edc3e5bc30
commit
bd921ca5d7
2 changed files with 4 additions and 3 deletions
|
@ -286,12 +286,12 @@ def get_notified_from_activity(%Activity{data: %{"to" => to}}) do
|
||||||
|
|
||||||
def get_recipients_from_activity(%Activity{data: %{"to" => to}}) do
|
def get_recipients_from_activity(%Activity{data: %{"to" => to}}) do
|
||||||
query = from u in User,
|
query = from u in User,
|
||||||
where: u.local == true
|
|
||||||
|
|
||||||
query = from u in query,
|
|
||||||
where: u.ap_id in ^to,
|
where: u.ap_id in ^to,
|
||||||
or_where: fragment("? \\\?| ?", u.following, ^to)
|
or_where: fragment("? \\\?| ?", u.following, ^to)
|
||||||
|
|
||||||
|
query = from u in query,
|
||||||
|
where: u.local == true
|
||||||
|
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -318,6 +318,7 @@ test "get recipients from activity" do
|
||||||
assert [addressed] == User.get_recipients_from_activity(activity)
|
assert [addressed] == User.get_recipients_from_activity(activity)
|
||||||
|
|
||||||
{:ok, user} = User.follow(user, actor)
|
{:ok, user} = User.follow(user, actor)
|
||||||
|
{:ok, user_two} = User.follow(user_two, actor)
|
||||||
recipients = User.get_recipients_from_activity(activity)
|
recipients = User.get_recipients_from_activity(activity)
|
||||||
assert length(recipients) == 2
|
assert length(recipients) == 2
|
||||||
assert user in recipients
|
assert user in recipients
|
||||||
|
|
Loading…
Reference in a new issue