Merge remote-tracking branch 'origin/develop' into spc2

This commit is contained in:
Moon Man 2024-03-23 11:49:56 -05:00
commit b3c46387fa
3 changed files with 25 additions and 14 deletions

View File

View File

@ -13,10 +13,8 @@ def render("show.json", %{folder: %BookmarkFolder{} = folder}) do
%{
id: folder.id |> to_string(),
name: folder.name,
emoji: get_emoji(folder.emoji),
source: %{
emoji: folder.emoji
}
emoji: folder.emoji,
emoji_url: get_emoji_url(folder.emoji)
}
end
@ -24,18 +22,18 @@ def render("index.json", %{folders: folders} = opts) do
render_many(folders, __MODULE__, "show.json", Map.delete(opts, :folders))
end
defp get_emoji(nil) do
defp get_emoji_url(nil) do
nil
end
defp get_emoji(emoji) do
defp get_emoji_url(emoji) do
if Emoji.unicode?(emoji) do
emoji
nil
else
emoji = Emoji.get(emoji)
if emoji != nil do
Endpoint.url() |> URI.merge(emoji.relative_url) |> to_string()
Endpoint.url() |> URI.merge(emoji.file) |> to_string()
else
nil
end

View File

@ -33,9 +33,7 @@ test "it lists bookmark folders", %{conn: conn, user: user} do
"id" => ^folder_id,
"name" => "Bookmark folder",
"emoji" => nil,
"source" => %{
"emoji" => nil
}
"emoji_url" => nil
}
] = result
end
@ -57,9 +55,24 @@ test "it creates a bookmark folder", %{conn: conn} do
assert %{
"name" => "Bookmark folder",
"emoji" => "📁",
"source" => %{
"emoji" => "📁"
}
"emoji_url" => nil
} = result
end
test "it creates a bookmark folder with custom emoji", %{conn: conn} do
result =
conn
|> put_req_header("content-type", "application/json")
|> post("/api/v1/pleroma/bookmark_folders", %{
name: "Bookmark folder",
emoji: ":firefox:"
})
|> json_response_and_validate_schema(200)
assert %{
"name" => "Bookmark folder",
"emoji" => ":firefox:",
"emoji_url" => "http://localhost:4001/emoji/Firefox.gif"
} = result
end