allow external emoji
This commit is contained in:
parent
5e128a6be3
commit
48cd336a72
3 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
||||||
firefox, /emoji/Firefox.gif, Gif,Fun
|
firefox, /emoji/Firefox.gif, Gif,Fun
|
||||||
blank, /emoji/blank.png, Fun
|
blank, /emoji/blank.png, Fun
|
||||||
dinosaur, /emoji/dino walking.gif, Gif
|
dinosaur, /emoji/dino walking.gif, Gif
|
||||||
|
external_emoji, https://example.com/emoji.png
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
defmodule Pleroma.Emoji.Formatter do
|
defmodule Pleroma.Emoji.Formatter do
|
||||||
alias Pleroma.Emoji
|
alias Pleroma.Emoji
|
||||||
alias Pleroma.HTML
|
alias Pleroma.HTML
|
||||||
|
alias Pleroma.Web
|
||||||
alias Pleroma.Web.MediaProxy
|
alias Pleroma.Web.MediaProxy
|
||||||
|
|
||||||
def emojify(text) do
|
def emojify(text) do
|
||||||
|
@ -43,7 +44,7 @@ def get_emoji_map(text) when is_binary(text) do
|
||||||
Emoji.get_all()
|
Emoji.get_all()
|
||||||
|> Enum.filter(fn {emoji, %Emoji{}} -> String.contains?(text, ":#{emoji}:") end)
|
|> Enum.filter(fn {emoji, %Emoji{}} -> String.contains?(text, ":#{emoji}:") end)
|
||||||
|> Enum.reduce(%{}, fn {name, %Emoji{file: file}}, acc ->
|
|> Enum.reduce(%{}, fn {name, %Emoji{file: file}}, acc ->
|
||||||
Map.put(acc, name, "#{Pleroma.Web.Endpoint.static_url()}#{file}")
|
Map.put(acc, name, to_string(URI.merge(Web.base_url(), file)))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -504,6 +504,19 @@ test "it adds emoji in the object" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "posting" do
|
describe "posting" do
|
||||||
|
test "it adds an emoji on an external site" do
|
||||||
|
user = insert(:user)
|
||||||
|
{:ok, activity} = CommonAPI.post(user, %{status: "hey :external_emoji:"})
|
||||||
|
|
||||||
|
assert %{"external_emoji" => url} = Object.normalize(activity).data["emoji"]
|
||||||
|
assert url == "https://example.com/emoji.png"
|
||||||
|
|
||||||
|
{: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"
|
||||||
|
end
|
||||||
|
|
||||||
test "deactivated users can't post" do
|
test "deactivated users can't post" do
|
||||||
user = insert(:user, deactivated: true)
|
user = insert(:user, deactivated: true)
|
||||||
assert {:error, _} = CommonAPI.post(user, %{status: "ye"})
|
assert {:error, _} = CommonAPI.post(user, %{status: "ye"})
|
||||||
|
|
Loading…
Reference in a new issue