forked from AkkomaGang/akkoma
Fix conversations.
This commit is contained in:
parent
deaad6d97a
commit
010f818a29
2 changed files with 10 additions and 5 deletions
|
@ -129,12 +129,17 @@ def delete(%Object{data: %{"id" => id, "actor" => actor}} = object, local \\ tru
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_activities_for_context(context, opts \\ %{}) do
|
def fetch_activities_for_context(context, opts \\ %{}) do
|
||||||
query = from activity in Activity,
|
public = ["https://www.w3.org/ns/activitystreams#Public"]
|
||||||
where: fragment("?->>'type' = ? and ?->>'context' = ?", activity.data, "Create", activity.data, ^context),
|
recipients = if opts["user"], do: [opts["user"].ap_id | opts["user"].following] ++ public, else: public
|
||||||
order_by: [desc: :id]
|
|
||||||
|
query = from activity in Activity
|
||||||
query = query
|
query = query
|
||||||
|> restrict_blocked(opts)
|
|> restrict_blocked(opts)
|
||||||
|> restrict_recipients(["https://www.w3.org/ns/activitystreams#Public"], opts["user"])
|
|> restrict_recipients(recipients, opts["user"])
|
||||||
|
|
||||||
|
query = from activity in query,
|
||||||
|
where: fragment("?->>'type' = ? and ?->>'context' = ?", activity.data, "Create", activity.data, ^context),
|
||||||
|
order_by: [desc: :id]
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ def fetch_mentions(user, opts \\ %{}) do
|
||||||
|
|
||||||
def fetch_conversation(user, id) do
|
def fetch_conversation(user, id) do
|
||||||
with context when is_binary(context) <- conversation_id_to_context(id),
|
with context when is_binary(context) <- conversation_id_to_context(id),
|
||||||
activities <- ActivityPub.fetch_activities_for_context(context, %{"blocking_user" => user}),
|
activities <- ActivityPub.fetch_activities_for_context(context, %{"blocking_user" => user, "user" => user}),
|
||||||
statuses <- activities |> activities_to_statuses(%{for: user})
|
statuses <- activities |> activities_to_statuses(%{for: user})
|
||||||
do
|
do
|
||||||
statuses
|
statuses
|
||||||
|
|
Loading…
Reference in a new issue