Emoji, AccountView, UtilController: Handle encoding of emoji
This commit is contained in:
parent
ee19d14b06
commit
3ef98652f7
5 changed files with 52 additions and 2 deletions
|
|
@ -199,7 +199,8 @@ defmodule Pleroma.Emoji do
|
|||
end
|
||||
|
||||
def local_url("/" <> _ = path) do
|
||||
URIEncoding.encode_url(Endpoint.url() <> path, bypass_decode: true)
|
||||
path = URIEncoding.encode_url(path, bypass_parse: true, bypass_decode: true)
|
||||
Endpoint.url() <> path
|
||||
end
|
||||
|
||||
def local_url(path) when is_binary(path) do
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||
alias Pleroma.User
|
||||
alias Pleroma.UserNote
|
||||
alias Pleroma.UserRelationship
|
||||
alias Pleroma.Utils.URIEncoding
|
||||
alias Pleroma.Web.CommonAPI.Utils
|
||||
alias Pleroma.Web.MastodonAPI.AccountView
|
||||
alias Pleroma.Web.MediaProxy
|
||||
|
|
@ -238,7 +239,10 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||
|
||||
emojis =
|
||||
Enum.map(user.emoji, fn {shortcode, raw_url} ->
|
||||
url = MediaProxy.url(raw_url)
|
||||
url =
|
||||
raw_url
|
||||
|> encode_emoji_url()
|
||||
|> MediaProxy.url()
|
||||
|
||||
%{
|
||||
shortcode: shortcode,
|
||||
|
|
@ -511,4 +515,13 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||
# See https://git.pleroma.social/pleroma/pleroma-meta/-/issues/14
|
||||
user.actor_type == "Service" || user.actor_type == "Group"
|
||||
end
|
||||
|
||||
defp encode_emoji_url(nil), do: nil
|
||||
defp encode_emoji_url("http" <> _ = url), do: URIEncoding.encode_url(url)
|
||||
|
||||
defp encode_emoji_url("/" <> _ = path),
|
||||
do: URIEncoding.encode_url(path, bypass_parse: true, bypass_decode: true)
|
||||
|
||||
defp encode_emoji_url(path) when is_binary(path),
|
||||
do: URIEncoding.encode_url(path, bypass_parse: true, bypass_decode: true)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
|||
alias Pleroma.Config
|
||||
alias Pleroma.Emoji
|
||||
alias Pleroma.Healthcheck
|
||||
alias Pleroma.Utils.URIEncoding
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.Auth.WrapperAuthenticator, as: Authenticator
|
||||
|
|
@ -180,12 +181,22 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
|||
def emoji(conn, _params) do
|
||||
emoji =
|
||||
Enum.reduce(Emoji.get_all(), %{}, fn {code, %Emoji{file: file, tags: tags}}, acc ->
|
||||
file = encode_emoji_url(file)
|
||||
Map.put(acc, code, %{image_url: file, tags: tags})
|
||||
end)
|
||||
|
||||
json(conn, emoji)
|
||||
end
|
||||
|
||||
defp encode_emoji_url(nil), do: nil
|
||||
defp encode_emoji_url("http" <> _ = url), do: URIEncoding.encode_url(url)
|
||||
|
||||
defp encode_emoji_url("/" <> _ = path),
|
||||
do: URIEncoding.encode_url(path, bypass_parse: true, bypass_decode: true)
|
||||
|
||||
defp encode_emoji_url(path) when is_binary(path),
|
||||
do: URIEncoding.encode_url(path, bypass_parse: true, bypass_decode: true)
|
||||
|
||||
def update_notification_settings(%{assigns: %{user: user}} = conn, params) do
|
||||
with {:ok, _} <- User.update_notification_settings(user, params) do
|
||||
json(conn, %{status: "success"})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue