mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-10-06 02:02:06 +00:00
Make status.language == nil for 'und' value
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
04c8f6b4d1
commit
366559c5a3
2 changed files with 16 additions and 2 deletions
|
@ -200,7 +200,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||||
mentions: mentions,
|
mentions: mentions,
|
||||||
tags: reblogged[:tags] || [],
|
tags: reblogged[:tags] || [],
|
||||||
application: build_application(object.data["generator"]),
|
application: build_application(object.data["generator"]),
|
||||||
language: object.data["language"],
|
language: get_language(object),
|
||||||
emojis: [],
|
emojis: [],
|
||||||
pleroma: %{
|
pleroma: %{
|
||||||
local: activity.local,
|
local: activity.local,
|
||||||
|
@ -391,7 +391,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||||
mentions: mentions,
|
mentions: mentions,
|
||||||
tags: build_tags(tags),
|
tags: build_tags(tags),
|
||||||
application: build_application(object.data["generator"]),
|
application: build_application(object.data["generator"]),
|
||||||
language: object.data["language"],
|
language: get_language(object),
|
||||||
emojis: build_emojis(object.data["emoji"]),
|
emojis: build_emojis(object.data["emoji"]),
|
||||||
pleroma: %{
|
pleroma: %{
|
||||||
local: activity.local,
|
local: activity.local,
|
||||||
|
@ -756,4 +756,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||||
defp get_source_content_type(_source) do
|
defp get_source_content_type(_source) do
|
||||||
Utils.get_content_type(nil)
|
Utils.get_content_type(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp get_language(%{data: %{"language" => "und"}}), do: nil
|
||||||
|
|
||||||
|
defp get_language(object), do: object.data["language"]
|
||||||
end
|
end
|
||||||
|
|
|
@ -780,6 +780,16 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
||||||
assert status.language == "pl"
|
assert status.language == "pl"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "doesn't show post language if it's 'und'" do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, post} = CommonAPI.post(user, %{status: "sdifjogijodfg", language: "und"})
|
||||||
|
|
||||||
|
status = StatusView.render("show.json", activity: post)
|
||||||
|
|
||||||
|
assert status.language == nil
|
||||||
|
end
|
||||||
|
|
||||||
test "with a source object" do
|
test "with a source object" do
|
||||||
note =
|
note =
|
||||||
insert(:note,
|
insert(:note,
|
||||||
|
|
Loading…
Reference in a new issue