I LOVE OBJECTS!! #517

Merged
floatingghost merged 2 commits from wowee into develop 2023-03-29 02:33:52 +00:00
3 changed files with 11 additions and 2 deletions

View file

@ -572,7 +572,8 @@
database_prune: 1 database_prune: 1
], ],
plugins: [ plugins: [
Oban.Plugins.Pruner Oban.Plugins.Pruner,
{Oban.Plugins.Reindexer, schedule: "@weekly"}
], ],
crontab: [ crontab: [
{"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker}, {"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker},

View file

@ -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_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 @spec create_by_id_with_object(String.t()) :: t() | nil
def create_by_id_with_object(id) do def create_by_id_with_object(id) do
get_by_id_with_opts(id, preload: [:object], filter: [type: "Create"]) get_by_id_with_opts(id, preload: [:object], filter: [type: "Create"])

View file

@ -36,7 +36,7 @@ def object(%{assigns: %{format: format}} = conn, _params)
def object(conn, _params) do def object(conn, _params) do
with id <- Endpoint.url() <> conn.request_path, with id <- Endpoint.url() <> conn.request_path,
{_, %Activity{} = activity} <- {_, %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)}, {_, true} <- {:public?, Visibility.is_public?(activity)},
{_, false} <- {:local_public?, Visibility.is_local_public?(activity)} do {_, false} <- {:local_public?, Visibility.is_local_public?(activity)} do
redirect(conn, to: "/notice/#{activity.id}") redirect(conn, to: "/notice/#{activity.id}")