forked from AkkomaGang/akkoma
Only even attempt to fetch local activities by object_id
TODO: PLEASE FOR THE LOVE OF KANATAN CACHE THIS
This commit is contained in:
parent
1d94f2a424
commit
3f340cbc43
2 changed files with 9 additions and 1 deletions
|
@ -277,6 +277,14 @@ def get_create_by_object_ap_id_with_object(ap_id) when is_binary(ap_id) do
|
|||
|
||||
def get_create_by_object_ap_id_with_object(_), do: nil
|
||||
|
||||
def get_local_create_by_object_ap_id_with_object(ap_id) when is_binary(ap_id) do
|
||||
ap_id
|
||||
|> create_by_object_ap_id_with_object()
|
||||
|> where(local: true)
|
||||
|> Repo.one()
|
||||
end
|
||||
|
||||
|
||||
@spec create_by_id_with_object(String.t()) :: t() | nil
|
||||
def create_by_id_with_object(id) do
|
||||
get_by_id_with_opts(id, preload: [:object], filter: [type: "Create"])
|
||||
|
|
|
@ -36,7 +36,7 @@ def object(%{assigns: %{format: format}} = conn, _params)
|
|||
def object(conn, _params) do
|
||||
with id <- Endpoint.url() <> conn.request_path,
|
||||
{_, %Activity{} = activity} <-
|
||||
{:activity, Activity.get_create_by_object_ap_id_with_object(id)},
|
||||
{:activity, Activity.get_local_create_by_object_ap_id_with_object(id)},
|
||||
{_, true} <- {:public?, Visibility.is_public?(activity)},
|
||||
{_, false} <- {:local_public?, Visibility.is_local_public?(activity)} do
|
||||
redirect(conn, to: "/notice/#{activity.id}")
|
||||
|
|
Loading…
Reference in a new issue