From: Alex Gleason Date: Mon, 31 May 2021 21:49:46 +0000 (-0500) Subject: Merge remote-tracking branch 'pleroma/develop' into cycles-base-url X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=f2134e605b44c300505f81adab01354a1652b2e5;p=akkoma Merge remote-tracking branch 'pleroma/develop' into cycles-base-url --- f2134e605b44c300505f81adab01354a1652b2e5 diff --cc lib/pleroma/user.ex index 4c697cb1b,b78777141..9365fae2b --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@@ -372,8 -373,10 +373,10 @@@ defmodule Pleroma.User d end # Should probably be renamed or removed + @spec ap_id(User.t()) :: String.t() - def ap_id(%User{nickname: nickname}), do: "#{Web.base_url()}/users/#{nickname}" + def ap_id(%User{nickname: nickname}), do: "#{Endpoint.url()}/users/#{nickname}" + @spec ap_followers(User.t()) :: String.t() def ap_followers(%User{follower_address: fa}) when is_binary(fa), do: fa def ap_followers(%User{} = user), do: "#{ap_id(user)}/followers" diff --cc lib/pleroma/web/mastodon_api/views/instance_view.ex index 510cac236,dac68d8e6..005705d97 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@@ -23,7 -23,8 +23,9 @@@ defmodule Pleroma.Web.MastodonAPI.Insta streaming_api: Pleroma.Web.Endpoint.websocket_url() }, stats: Pleroma.Stats.get_stats(), - thumbnail: Pleroma.Web.Endpoint.url() <> Keyword.get(instance, :instance_thumbnail), + thumbnail: - URI.merge(Pleroma.Web.base_url(), Keyword.get(instance, :instance_thumbnail)) |> to_string, ++ URI.merge(Pleroma.Web.Endpoint.url(), Keyword.get(instance, :instance_thumbnail)) ++ |> to_string, languages: ["en"], registrations: Keyword.get(instance, :registrations_open), approval_required: Keyword.get(instance, :account_approval_required), diff --cc lib/pleroma/web/media_proxy.ex index 7df591201,d0d4bb4b3..5c32078aa --- a/lib/pleroma/web/media_proxy.ex +++ b/lib/pleroma/web/media_proxy.ex @@@ -121,8 -121,13 +121,13 @@@ defmodule Pleroma.Web.MediaProxy d end end + def decode_url(encoded) do + [_, "proxy", sig, base64 | _] = URI.parse(encoded).path |> String.split("/") + decode_url(sig, base64) + end + defp signed_url(url) do - :crypto.hmac(:sha, Config.get([Web.Endpoint, :secret_key_base]), url) + :crypto.hmac(:sha, Config.get([Endpoint, :secret_key_base]), url) end def filename(url_or_path) do diff --cc test/pleroma/web/common_api_test.exs index 5ab3a48ad,be94c93c2..1af1b85a3 --- a/test/pleroma/web/common_api_test.exs +++ b/test/pleroma/web/common_api_test.exs @@@ -514,9 -519,30 +519,30 @@@ defmodule Pleroma.Web.CommonAPITest d {:ok, activity} = CommonAPI.post(user, %{status: "hey :blank:"}) assert %{"blank" => url} = Object.normalize(activity).data["emoji"] - assert url == "#{Pleroma.Web.base_url()}/emoji/blank.png" + assert url == "#{Pleroma.Web.Endpoint.url()}/emoji/blank.png" end + test "it copies emoji from the subject of the parent post" do + %Object{} = + object = + Object.normalize("https://patch.cx/objects/a399c28e-c821-4820-bc3e-4afeb044c16f", + fetch: true + ) + + activity = Activity.get_create_by_object_ap_id(object.data["id"]) + user = insert(:user) + + {:ok, reply_activity} = + CommonAPI.post(user, %{ + in_reply_to_id: activity.id, + status: ":joker_disapprove:", + spoiler_text: ":joker_smile:" + }) + + assert Object.normalize(reply_activity).data["emoji"][":joker_smile:"] + refute Object.normalize(reply_activity).data["emoji"][":joker_disapprove:"] + end + test "deactivated users can't post" do user = insert(:user, is_active: false) assert {:error, _} = CommonAPI.post(user, %{status: "ye"})