mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-06-16 12:10:40 +00:00
changelog
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
f954f98fb7
commit
b53abd9d79
1
changelog.d/translate-posts.add
Normal file
1
changelog.d/translate-posts.add
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Support translation providers (DeepL, LibreTranslate)
|
|
@ -24,7 +24,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceController do
|
||||||
@doc "GET /api/v1/instance/peers"
|
@doc "GET /api/v1/instance/peers"
|
||||||
def peers(conn, _params) do
|
def peers(conn, _params) do
|
||||||
json(conn, Pleroma.Stats.get_peers())
|
json(conn, Pleroma.Stats.get_peers())
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "GET /api/v1/instance/translation_languages"
|
@doc "GET /api/v1/instance/translation_languages"
|
||||||
def translation_languages(conn, _params) do
|
def translation_languages(conn, _params) do
|
||||||
|
|
|
@ -558,7 +558,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "POST /api/v1/statuses/:id/translate"
|
@doc "POST /api/v1/statuses/:id/translate"
|
||||||
def translate(%{body_params: params, assigns: %{user: user}} = conn, %{id: status_id}) do
|
def translate(
|
||||||
|
%{
|
||||||
|
assigns: %{user: user},
|
||||||
|
private: %{open_api_spex: %{body_params: params, params: %{id: status_id}}}
|
||||||
|
} = conn,
|
||||||
|
_
|
||||||
|
) do
|
||||||
with %Activity{object: object} <- Activity.get_by_id_with_object(status_id),
|
with %Activity{object: object} <- Activity.get_by_id_with_object(status_id),
|
||||||
{:visibility, visibility} when visibility in ["public", "unlisted"] <-
|
{:visibility, visibility} when visibility in ["public", "unlisted"] <-
|
||||||
{:visibility, Visibility.get_visibility(object)},
|
{:visibility, Visibility.get_visibility(object)},
|
||||||
|
|
|
@ -75,15 +75,6 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
defp common_information(instance) do
|
|
||||||
%{
|
|
||||||
title: Keyword.get(instance, :name),
|
|
||||||
version: "#{@mastodon_api_level} (compatible; #{Pleroma.Application.named_version()})",
|
|
||||||
languages: Keyword.get(instance, :languages, ["en"]),
|
|
||||||
rules: []
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def render("translation_languages.json", _) do
|
def render("translation_languages.json", _) do
|
||||||
with true <- Pleroma.Language.Translation.configured?(),
|
with true <- Pleroma.Language.Translation.configured?(),
|
||||||
{:ok, languages} <- Pleroma.Language.Translation.languages_matrix() do
|
{:ok, languages} <- Pleroma.Language.Translation.languages_matrix() do
|
||||||
|
@ -93,6 +84,15 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp common_information(instance) do
|
||||||
|
%{
|
||||||
|
title: Keyword.get(instance, :name),
|
||||||
|
version: "#{@mastodon_api_level} (compatible; #{Pleroma.Application.named_version()})",
|
||||||
|
languages: Keyword.get(instance, :languages, ["en"]),
|
||||||
|
rules: []
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def features do
|
def features do
|
||||||
[
|
[
|
||||||
"pleroma_api",
|
"pleroma_api",
|
||||||
|
|
|
@ -2556,7 +2556,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
|
|
||||||
test "it translates a status to user language" do
|
test "it translates a status to user language" do
|
||||||
user = insert(:user, language: "fr")
|
user = insert(:user, language: "fr")
|
||||||
%{conn: conn, user: user} = oauth_access(["read:statuses"], user: user)
|
%{conn: conn} = oauth_access(["read:statuses"], user: user)
|
||||||
another_user = insert(:user)
|
another_user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
|
@ -2579,7 +2579,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns an error if no target language provided" do
|
test "it returns an error if no target language provided" do
|
||||||
%{conn: conn, user: user} = oauth_access(["read:statuses"])
|
%{conn: conn} = oauth_access(["read:statuses"])
|
||||||
another_user = insert(:user)
|
another_user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
|
@ -2588,10 +2588,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
language: "pl"
|
language: "pl"
|
||||||
})
|
})
|
||||||
|
|
||||||
response =
|
assert conn
|
||||||
conn
|
|> post("/api/v1/statuses/#{activity.id}/translate")
|
||||||
|> post("/api/v1/statuses/#{activity.id}/translate")
|
|> json_response_and_validate_schema(400)
|
||||||
|> json_response_and_validate_schema(400)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it doesn't translate non-public statuses" do
|
test "it doesn't translate non-public statuses" do
|
||||||
|
@ -2604,10 +2603,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
language: "pl"
|
language: "pl"
|
||||||
})
|
})
|
||||||
|
|
||||||
response =
|
assert conn
|
||||||
conn
|
|> post("/api/v1/statuses/#{activity.id}/translate")
|
||||||
|> post("/api/v1/statuses/#{activity.id}/translate")
|
|> json_response_and_validate_schema(404)
|
||||||
|> json_response_and_validate_schema(404)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue