Make status.language == nil for 'und' value
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
adb84b1df9
commit
edec300ddb
2 changed files with 16 additions and 2 deletions
|
@ -225,7 +225,7 @@ def render(
|
||||||
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,
|
||||||
|
@ -434,7 +434,7 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
|
||||||
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,
|
||||||
|
@ -917,4 +917,8 @@ def build_source_location(%{"location_id" => location_id}) when is_binary(locati
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_source_location(_), do: nil
|
def build_source_location(_), do: nil
|
||||||
|
|
||||||
|
defp get_language(%{data: %{"language" => "und"}}), do: nil
|
||||||
|
|
||||||
|
defp get_language(object), do: object.data["language"]
|
||||||
end
|
end
|
||||||
|
|
|
@ -916,6 +916,16 @@ test "it shows post language" 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