From: Maksim Pechnikov Date: Mon, 23 Sep 2019 18:41:57 +0000 (+0300) Subject: Merge branch 'develop' into tests/mastodon_api_controller.ex X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=179fa32dd5d7b4cf1b338fc3df4840ae33525606;p=akkoma Merge branch 'develop' into tests/mastodon_api_controller.ex --- 179fa32dd5d7b4cf1b338fc3df4840ae33525606 diff --cc lib/pleroma/activity.ex index 56c51aef8,ec558168a..b6e8e9e1d --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@@ -133,35 -131,17 +131,24 @@@ defmodule Pleroma.Activity d end def get_by_ap_id_with_object(ap_id) do - Repo.one( - from( - activity in Activity, - where: fragment("(?)->>'id' = ?", activity.data, ^to_string(ap_id)), - left_join: o in Object, - on: - fragment( - "(?->>'id') = COALESCE(?->'object'->>'id', ?->>'object')", - o.data, - activity.data, - activity.data - ), - preload: [object: o] - ) - ) + ap_id + |> Queries.by_ap_id() + |> with_preloaded_object(:left) + |> Repo.one() end + @spec get_by_id(String.t()) :: Activity.t() | nil def get_by_id(id) do - Activity - |> where([a], a.id == ^id) - |> restrict_deactivated_users() - |> Repo.one() + case Pleroma.FlakeId.is_flake_id?(id) do + true -> + Activity + |> where([a], a.id == ^id) + |> restrict_deactivated_users() + |> Repo.one() + + _ -> + nil + end end def get_by_id_with_object(id) do