Do not translate non-public statuses
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
90f590788c
commit
aa429f6e6a
2 changed files with 26 additions and 1 deletions
|
|
@ -560,6 +560,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
@doc "POST /api/v1/statuses/:id/translate"
|
||||
def translate(%{body_params: params, assigns: %{user: user}} = conn, %{id: status_id}) 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)},
|
||||
{:language, language} when is_binary(language) <-
|
||||
{:language, Map.get(params, :target_language) || user.language},
|
||||
{:ok, result} <-
|
||||
|
|
@ -573,6 +575,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
{:language, nil} ->
|
||||
render_error(conn, :bad_request, "Language not specified")
|
||||
|
||||
{:visibility, _} ->
|
||||
render_error(conn, :not_found, "Record not found")
|
||||
|
||||
{:error, :not_found} ->
|
||||
render_error(conn, :not_found, "Translation service not configured")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue