mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2025-04-07 11:09:50 +00:00
changelog
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
f954f98fb7
commit
b53abd9d79
5 changed files with 26 additions and 21 deletions
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"
|
||||
def peers(conn, _params) do
|
||||
json(conn, Pleroma.Stats.get_peers())
|
||||
end
|
||||
end
|
||||
|
||||
@doc "GET /api/v1/instance/translation_languages"
|
||||
def translation_languages(conn, _params) do
|
||||
|
|
|
@ -558,7 +558,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
end
|
||||
|
||||
@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),
|
||||
{:visibility, visibility} when visibility in ["public", "unlisted"] <-
|
||||
{:visibility, Visibility.get_visibility(object)},
|
||||
|
|
|
@ -75,15 +75,6 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
|
|||
})
|
||||
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
|
||||
with true <- Pleroma.Language.Translation.configured?(),
|
||||
{:ok, languages} <- Pleroma.Language.Translation.languages_matrix() do
|
||||
|
@ -93,6 +84,15 @@ 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 features do
|
||||
[
|
||||
"pleroma_api",
|
||||
|
|
|
@ -2556,7 +2556,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
test "it translates a status to user language" do
|
||||
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)
|
||||
|
||||
{:ok, activity} =
|
||||
|
@ -2579,7 +2579,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
end
|
||||
|
||||
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)
|
||||
|
||||
{:ok, activity} =
|
||||
|
@ -2588,10 +2588,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
language: "pl"
|
||||
})
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/api/v1/statuses/#{activity.id}/translate")
|
||||
|> json_response_and_validate_schema(400)
|
||||
assert conn
|
||||
|> post("/api/v1/statuses/#{activity.id}/translate")
|
||||
|> json_response_and_validate_schema(400)
|
||||
end
|
||||
|
||||
test "it doesn't translate non-public statuses" do
|
||||
|
@ -2604,10 +2603,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
language: "pl"
|
||||
})
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/api/v1/statuses/#{activity.id}/translate")
|
||||
|> json_response_and_validate_schema(404)
|
||||
assert conn
|
||||
|> post("/api/v1/statuses/#{activity.id}/translate")
|
||||
|> json_response_and_validate_schema(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue