Activity: create_activity_by_object_id_query/1 → create_by_object_ap_id/1 when is_list

This commit is contained in:
Haelwenn (lanodan) Monnier 2019-01-21 07:07:54 +01:00
parent f8ab1b7427
commit 2fdbd4d137
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
2 changed files with 3 additions and 3 deletions

View file

@ -63,7 +63,7 @@ defmodule Pleroma.Activity do
) )
end end
def create_activity_by_object_id_query(ap_ids) do def create_by_object_ap_id(ap_ids) when is_list(ap_ids) do
from( from(
activity in Activity, activity in Activity,
where: where:
@ -82,7 +82,7 @@ defmodule Pleroma.Activity do
end end
def get_create_activity_by_object_ap_id(ap_id) when is_binary(ap_id) do def get_create_activity_by_object_ap_id(ap_id) when is_binary(ap_id) do
create_activity_by_object_id_query([ap_id]) create_by_object_ap_id(ap_id)
|> Repo.one() |> Repo.one()
end end

View file

@ -25,7 +25,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
nil nil
end) end)
|> Enum.filter(& &1) |> Enum.filter(& &1)
|> Activity.create_activity_by_object_id_query() |> Activity.create_by_object_ap_id()
|> Repo.all() |> Repo.all()
|> Enum.reduce(%{}, fn activity, acc -> |> Enum.reduce(%{}, fn activity, acc ->
Map.put(acc, activity.data["object"]["id"], activity) Map.put(acc, activity.data["object"]["id"], activity)