Merge branch 'develop' into tests/mastodon_api_controller.ex
authorMaksim Pechnikov <parallel588@gmail.com>
Mon, 23 Sep 2019 18:41:57 +0000 (21:41 +0300)
committerMaksim Pechnikov <parallel588@gmail.com>
Mon, 23 Sep 2019 18:41:57 +0000 (21:41 +0300)
1  2 
lib/pleroma/activity.ex
lib/pleroma/object.ex
lib/pleroma/user.ex
lib/pleroma/web/mastodon_api/controllers/mastodon_api_controller.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index 56c51aef8653c86f0c13af24da04115468464917,ec558168ae05e43ad5e85f76c18b72623752c87d..b6e8e9e1dce4ffab3c5ea2779d9a3a30094a9e3d
@@@ -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
Simple merge
Simple merge