From 5104f65b69cb00155c3e0f3ea2c6dca5bb8c10b7 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 10 Jul 2019 16:25:58 +0700 Subject: [PATCH] Wrap error messages into gettext helpers --- lib/pleroma/captcha/captcha.ex | 9 +- lib/pleroma/captcha/kocaptcha.ex | 5 +- .../plugs/ensure_authenticated_plug.ex | 4 +- .../ensure_public_or_authenticated_plug.ex | 4 +- lib/pleroma/plugs/oauth_scopes_plug.ex | 8 +- lib/pleroma/plugs/rate_limiter.ex | 10 +- lib/pleroma/plugs/uploaded_media.ex | 8 +- lib/pleroma/plugs/user_is_admin_plug.ex | 4 +- lib/pleroma/uploaders/uploader.ex | 4 +- .../activity_pub/activity_pub_controller.ex | 37 +- .../web/admin_api/admin_api_controller.ex | 26 +- lib/pleroma/web/admin_api/config.ex | 7 +- lib/pleroma/web/common_api/common_api.ex | 58 ++- lib/pleroma/web/common_api/utils.ex | 13 +- .../mastodon_api/mastodon_api_controller.ex | 156 +++----- .../mastodon_api/subscription_controller.ex | 8 +- .../web/mongooseim/mongoose_im_controller.ex | 2 +- .../web/nodeinfo/nodeinfo_controller.ex | 4 +- lib/pleroma/web/oauth/fallback_controller.ex | 9 +- lib/pleroma/web/oauth/oauth_controller.ex | 52 ++- lib/pleroma/web/ostatus/ostatus_controller.ex | 8 +- lib/pleroma/web/uploader_controller.ex | 4 +- priv/gettext/en/LC_MESSAGES/errors.po | 372 +++++++++++++++++ priv/gettext/errors.pot | 373 +++++++++++++++++- 24 files changed, 948 insertions(+), 237 deletions(-) diff --git a/lib/pleroma/captcha/captcha.ex b/lib/pleroma/captcha/captcha.ex index f105cbb25..a73b87251 100644 --- a/lib/pleroma/captcha/captcha.ex +++ b/lib/pleroma/captcha/captcha.ex @@ -3,6 +3,8 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Captcha do + import Pleroma.Web.Gettext + alias Calendar.DateTime alias Plug.Crypto.KeyGenerator alias Plug.Crypto.MessageEncryptor @@ -83,10 +85,11 @@ def handle_call({:validate, token, captcha, answer_data}, _from, state) do with {:ok, data} <- MessageEncryptor.decrypt(answer_data, secret, sign_secret), %{at: at, answer_data: answer_md5} <- :erlang.binary_to_term(data) do try do - if DateTime.before?(at, valid_if_after), do: throw({:error, "CAPTCHA expired"}) + if DateTime.before?(at, valid_if_after), + do: throw({:error, dgettext("errors", "CAPTCHA expired")}) if not is_nil(Cachex.get!(:used_captcha_cache, token)), - do: throw({:error, "CAPTCHA already used"}) + do: throw({:error, dgettext("errors", "CAPTCHA already used")}) res = method().validate(token, captcha, answer_md5) # Throw if an error occurs @@ -101,7 +104,7 @@ def handle_call({:validate, token, captcha, answer_data}, _from, state) do :throw, e -> e end else - _ -> {:error, "Invalid answer data"} + _ -> {:error, dgettext("errors", "Invalid answer data")} end {:reply, result, state} diff --git a/lib/pleroma/captcha/kocaptcha.ex b/lib/pleroma/captcha/kocaptcha.ex index 18931d5a0..4e1a07c59 100644 --- a/lib/pleroma/captcha/kocaptcha.ex +++ b/lib/pleroma/captcha/kocaptcha.ex @@ -3,6 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Captcha.Kocaptcha do + import Pleroma.Web.Gettext alias Pleroma.Captcha.Service @behaviour Service @@ -12,7 +13,7 @@ def new do case Tesla.get(endpoint <> "/new") do {:error, _} -> - %{error: "Kocaptcha service unavailable"} + %{error: dgettext("errors", "Kocaptcha service unavailable")} {:ok, res} -> json_resp = Jason.decode!(res.body) @@ -32,6 +33,6 @@ def validate(_token, captcha, answer_data) do if not is_nil(captcha) and :crypto.hash(:md5, captcha) |> Base.encode16() == String.upcase(answer_data), do: :ok, - else: {:error, "Invalid CAPTCHA"} + else: {:error, dgettext("errors", "Invalid CAPTCHA")} end end diff --git a/lib/pleroma/plugs/ensure_authenticated_plug.ex b/lib/pleroma/plugs/ensure_authenticated_plug.ex index 11c4342c4..27cd41aec 100644 --- a/lib/pleroma/plugs/ensure_authenticated_plug.ex +++ b/lib/pleroma/plugs/ensure_authenticated_plug.ex @@ -4,6 +4,7 @@ defmodule Pleroma.Plugs.EnsureAuthenticatedPlug do import Plug.Conn + import Pleroma.Web.TranslationHelpers alias Pleroma.User def init(options) do @@ -16,8 +17,7 @@ def call(%{assigns: %{user: %User{}}} = conn, _) do def call(conn, _) do conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{error: "Invalid credentials."})) + |> render_error(:forbidden, "Invalid credentials.") |> halt end end diff --git a/lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex b/lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex index 317fd5445..a16f61435 100644 --- a/lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex +++ b/lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex @@ -3,6 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug do + import Pleroma.Web.TranslationHelpers import Plug.Conn alias Pleroma.Config alias Pleroma.User @@ -23,8 +24,7 @@ def call(conn, _) do {false, _} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{error: "This resource requires authentication."})) + |> render_error(:forbidden, "This resource requires authentication.") |> halt end end diff --git a/lib/pleroma/plugs/oauth_scopes_plug.ex b/lib/pleroma/plugs/oauth_scopes_plug.ex index f2bfa2b1a..b508628a9 100644 --- a/lib/pleroma/plugs/oauth_scopes_plug.ex +++ b/lib/pleroma/plugs/oauth_scopes_plug.ex @@ -4,6 +4,7 @@ defmodule Pleroma.Plugs.OAuthScopesPlug do import Plug.Conn + import Pleroma.Web.Gettext @behaviour Plug @@ -30,11 +31,14 @@ def call(%Plug.Conn{assigns: assigns} = conn, %{scopes: scopes} = options) do true -> missing_scopes = scopes -- token.scopes - error_message = "Insufficient permissions: #{Enum.join(missing_scopes, " #{op} ")}." + permissions = Enum.join(missing_scopes, " #{op} ") + + error_message = + dgettext("errors", "Insufficient permissions: %{permissions}.", permissions: permissions) conn |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{error: error_message})) + |> send_resp(:forbidden, Jason.encode!(%{error: error_message})) |> halt() end end diff --git a/lib/pleroma/plugs/rate_limiter.ex b/lib/pleroma/plugs/rate_limiter.ex index 9ba5875fa..c5e0957e8 100644 --- a/lib/pleroma/plugs/rate_limiter.ex +++ b/lib/pleroma/plugs/rate_limiter.ex @@ -44,8 +44,7 @@ defmodule Pleroma.Plugs.RateLimiter do ... end """ - - import Phoenix.Controller, only: [json: 2] + import Pleroma.Web.TranslationHelpers import Plug.Conn alias Pleroma.User @@ -63,7 +62,7 @@ def call(conn, nil), do: conn def call(conn, opts) do case check_rate(conn, opts) do {:ok, _count} -> conn - {:error, _count} -> render_error(conn) + {:error, _count} -> render_throttled_error(conn) end end @@ -85,10 +84,9 @@ def ip(%{remote_ip: remote_ip}) do |> Enum.join(".") end - defp render_error(conn) do + defp render_throttled_error(conn) do conn - |> put_status(:too_many_requests) - |> json(%{error: "Throttled"}) + |> render_error(:too_many_requests, "Throttled") |> halt() end end diff --git a/lib/pleroma/plugs/uploaded_media.ex b/lib/pleroma/plugs/uploaded_media.ex index 8d0fac7ee..be2c17c5f 100644 --- a/lib/pleroma/plugs/uploaded_media.ex +++ b/lib/pleroma/plugs/uploaded_media.ex @@ -7,6 +7,8 @@ defmodule Pleroma.Plugs.UploadedMedia do """ import Plug.Conn + import Pleroma.Web.Gettext + import Pleroma.Web.TranslationHelpers require Logger @behaviour Plug @@ -45,7 +47,7 @@ def call(%{request_path: <<"/", @path, "/", file::binary>>} = conn, opts) do else _ -> conn - |> send_resp(500, "Failed") + |> send_resp(:internal_server_error, dgettext("errors", "Failed")) |> halt() end end @@ -64,7 +66,7 @@ defp get_media(conn, {:static_dir, directory}, _, opts) do conn else conn - |> send_resp(404, "Not found") + |> render_error(:not_found, "Not found") |> halt() end end @@ -84,7 +86,7 @@ defp get_media(conn, unknown, _, _) do Logger.error("#{__MODULE__}: Unknown get startegy: #{inspect(unknown)}") conn - |> send_resp(500, "Internal Error") + |> render_error(:internal_server_error, "Internal Error") |> halt() end end diff --git a/lib/pleroma/plugs/user_is_admin_plug.ex b/lib/pleroma/plugs/user_is_admin_plug.ex index 04329e919..4c4b3d610 100644 --- a/lib/pleroma/plugs/user_is_admin_plug.ex +++ b/lib/pleroma/plugs/user_is_admin_plug.ex @@ -3,6 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.UserIsAdminPlug do + import Pleroma.Web.TranslationHelpers import Plug.Conn alias Pleroma.User @@ -16,8 +17,7 @@ def call(%{assigns: %{user: %User{info: %{is_admin: true}}}} = conn, _) do def call(conn, _) do conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{error: "User is not admin."})) + |> render_error(:forbidden, "User is not admin.") |> halt end end diff --git a/lib/pleroma/uploaders/uploader.ex b/lib/pleroma/uploaders/uploader.ex index bf15389fc..0af76bc59 100644 --- a/lib/pleroma/uploaders/uploader.ex +++ b/lib/pleroma/uploaders/uploader.ex @@ -3,6 +3,8 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Uploaders.Uploader do + import Pleroma.Web.Gettext + @moduledoc """ Defines the contract to put and get an uploaded file to any backend. """ @@ -66,7 +68,7 @@ defp handle_callback(uploader, upload) do {:error, error} end after - 30_000 -> {:error, "Uploader callback timeout"} + 30_000 -> {:error, dgettext("errors", "Uploader callback timeout")} end end end diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index 0182bda46..cf5176201 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -31,9 +31,8 @@ def relay_active?(conn, _) do conn else conn - |> put_status(404) - |> json(%{error: "not found"}) - |> halt + |> render_error(:not_found, "not found") + |> halt() end end @@ -190,7 +189,7 @@ def inbox(conn, params) do Logger.info(inspect(conn.req_headers)) end - json(conn, "error") + json(conn, dgettext("errors", "error")) end def relay(conn, _params) do @@ -218,9 +217,15 @@ def read_inbox(%{assigns: %{user: user}} = conn, %{"nickname" => nickname} = par |> put_resp_header("content-type", "application/activity+json") |> json(UserView.render("inbox.json", %{user: user, max_id: params["max_id"]})) else + err = + dgettext("errors", "can't read inbox of %{nickname} as %{as_nickname}", + nickname: nickname, + as_nickname: user.nickname + ) + conn |> put_status(:forbidden) - |> json("can't read inbox of #{nickname} as #{user.nickname}") + |> json(err) end end @@ -246,7 +251,7 @@ def handle_user_activity(user, %{"type" => "Delete"} = params) do {:ok, delete} <- ActivityPub.delete(object) do {:ok, delete} else - _ -> {:error, "Can't delete object"} + _ -> {:error, dgettext("errors", "Can't delete object")} end end @@ -255,12 +260,12 @@ def handle_user_activity(user, %{"type" => "Like"} = params) do {:ok, activity, _object} <- ActivityPub.like(user, object) do {:ok, activity} else - _ -> {:error, "Can't like object"} + _ -> {:error, dgettext("errors", "Can't like object")} end end def handle_user_activity(_, _) do - {:error, "Unhandled activity type"} + {:error, dgettext("errors", "Unhandled activity type")} end def update_outbox( @@ -288,22 +293,28 @@ def update_outbox( |> json(message) end else + err = + dgettext("errors", "can't update outbox of %{nickname} as %{as_nickname}", + nickname: nickname, + as_nickname: user.nickname + ) + conn |> put_status(:forbidden) - |> json("can't update outbox of #{nickname} as #{user.nickname}") + |> json(err) end end def errors(conn, {:error, :not_found}) do conn - |> put_status(404) - |> json("Not found") + |> put_status(:not_found) + |> json(dgettext("errors", "Not found")) end def errors(conn, _e) do conn - |> put_status(500) - |> json("error") + |> put_status(:internal_server_error) + |> json(dgettext("errors", "error")) end defp set_requester_reachable(%Plug.Conn{} = conn, _) do diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index 0a2482a8c..8b3c3c91f 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -160,9 +160,7 @@ def right_add(conn, %{"permission_group" => permission_group, "nickname" => nick end def right_add(conn, _) do - conn - |> put_status(404) - |> json(%{error: "No such permission_group"}) + render_error(conn, :not_found, "No such permission_group") end def right_get(conn, %{"nickname" => nickname}) do @@ -184,9 +182,7 @@ def right_delete( ) when permission_group in ["moderator", "admin"] do if admin_nickname == nickname do - conn - |> put_status(403) - |> json(%{error: "You can't revoke your own admin status."}) + render_error(conn, :forbidden, "You can't revoke your own admin status.") else user = User.get_cached_by_nickname(nickname) @@ -207,9 +203,7 @@ def right_delete( end def right_delete(conn, _) do - conn - |> put_status(404) - |> json(%{error: "No such permission_group"}) + render_error(conn, :not_found, "No such permission_group") end def set_activation_status(conn, %{"nickname" => nickname, "status" => status}) do @@ -401,26 +395,26 @@ def config_update(conn, %{"configs" => configs}) do def errors(conn, {:error, :not_found}) do conn - |> put_status(404) - |> json("Not found") + |> put_status(:not_found) + |> json(dgettext("errors", "Not found")) end def errors(conn, {:error, reason}) do conn - |> put_status(400) + |> put_status(:bad_request) |> json(reason) end def errors(conn, {:param_cast, _}) do conn - |> put_status(400) - |> json("Invalid parameters") + |> put_status(:bad_request) + |> json(dgettext("errors", "Invalid parameters")) end def errors(conn, _) do conn - |> put_status(500) - |> json("Something went wrong") + |> put_status(:internal_server_error) + |> json(dgettext("errors", "Something went wrong")) end defp page_params(params) do diff --git a/lib/pleroma/web/admin_api/config.ex b/lib/pleroma/web/admin_api/config.ex index 8b9b658a9..24674abc5 100644 --- a/lib/pleroma/web/admin_api/config.ex +++ b/lib/pleroma/web/admin_api/config.ex @@ -5,6 +5,7 @@ defmodule Pleroma.Web.AdminAPI.Config do use Ecto.Schema import Ecto.Changeset + import Pleroma.Web.Gettext alias __MODULE__ alias Pleroma.Repo @@ -57,7 +58,11 @@ def delete(params) do with %Config{} = config <- Config.get_by_params(params) do Repo.delete(config) else - nil -> {:error, "Config with params #{inspect(params)} not found"} + nil -> + err = + dgettext("errors", "Config with params %{params} not found", params: inspect(params)) + + {:error, err} end end diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index f71c67a3d..f1450b113 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -13,6 +13,7 @@ defmodule Pleroma.Web.CommonAPI do alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Web.ActivityPub.Visibility + import Pleroma.Web.Gettext import Pleroma.Web.CommonAPI.Utils def follow(follower, followed) do @@ -74,7 +75,7 @@ def delete(activity_id, user) do {:ok, delete} else _ -> - {:error, "Could not delete"} + {:error, dgettext("errors", "Could not delete")} end end @@ -85,7 +86,7 @@ def repeat(id_or_ap_id, user) do ActivityPub.announce(user, object) else _ -> - {:error, "Could not repeat"} + {:error, dgettext("errors", "Could not repeat")} end end @@ -95,7 +96,7 @@ def unrepeat(id_or_ap_id, user) do ActivityPub.unannounce(user, object) else _ -> - {:error, "Could not unrepeat"} + {:error, dgettext("errors", "Could not unrepeat")} end end @@ -106,7 +107,7 @@ def favorite(id_or_ap_id, user) do ActivityPub.like(user, object) else _ -> - {:error, "Could not favorite"} + {:error, dgettext("errors", "Could not favorite")} end end @@ -116,7 +117,7 @@ def unfavorite(id_or_ap_id, user) do ActivityPub.unlike(user, object) else _ -> - {:error, "Could not unfavorite"} + {:error, dgettext("errors", "Could not unfavorite")} end end @@ -148,10 +149,10 @@ def vote(user, object, choices) do object = Object.get_cached_by_ap_id(object.data["id"]) {:ok, answer_activities, object} else - {:author, _} -> {:error, "Poll's author can't vote"} - {:existing_votes, _} -> {:error, "Already voted"} - {:choice_check, {_, false}} -> {:error, "Invalid indices"} - {:count_check, false} -> {:error, "Too many choices"} + {:author, _} -> {:error, dgettext("errors", "Poll's author can't vote")} + {:existing_votes, _} -> {:error, dgettext("errors", "Already voted")} + {:choice_check, {_, false}} -> {:error, dgettext("errors", "Invalid indices")} + {:count_check, false} -> {:error, dgettext("errors", "Too many choices")} end end @@ -248,9 +249,14 @@ def post(user, %{"status" => status} = data) do res else - {:private_to_public, true} -> {:error, "The message visibility must be direct"} - {:error, _} = e -> e - e -> {:error, e} + {:private_to_public, true} -> + {:error, dgettext("errors", "The message visibility must be direct")} + + {:error, _} = e -> + e + + e -> + {:error, e} end end @@ -301,7 +307,7 @@ def pin(id_or_ap_id, %{ap_id: user_ap_id} = user) do {:error, err} _ -> - {:error, "Could not pin"} + {:error, dgettext("errors", "Could not pin")} end end @@ -318,7 +324,7 @@ def unpin(id_or_ap_id, user) do {:error, err} _ -> - {:error, "Could not unpin"} + {:error, dgettext("errors", "Could not unpin")} end end @@ -326,7 +332,7 @@ def add_mute(user, activity) do with {:ok, _} <- ThreadMute.add_mute(user.id, activity.data["context"]) do {:ok, activity} else - {:error, _} -> {:error, "conversation is already muted"} + {:error, _} -> {:error, dgettext("errors", "conversation is already muted")} end end @@ -371,8 +377,8 @@ def report(user, data) do {:ok, activity} else {:error, err} -> {:error, err} - {:account_id, %{}} -> {:error, "Valid `account_id` required"} - {:account, nil} -> {:error, "Account not found"} + {:account_id, %{}} -> {:error, dgettext("errors", "Valid `account_id` required")} + {:account, nil} -> {:error, dgettext("errors", "Account not found")} end end @@ -381,14 +387,9 @@ def update_report_state(activity_id, state) do {:ok, activity} <- Utils.update_report_state(activity, state) do {:ok, activity} else - nil -> - {:error, :not_found} - - {:error, reason} -> - {:error, reason} - - _ -> - {:error, "Could not update state"} + nil -> {:error, :not_found} + {:error, reason} -> {:error, reason} + _ -> {:error, dgettext("errors", "Could not update state")} end end @@ -398,11 +399,8 @@ def update_activity_scope(activity_id, opts \\ %{}) do {:ok, activity} <- set_visibility(activity, opts) do {:ok, activity} else - nil -> - {:error, :not_found} - - {:error, reason} -> - {:error, reason} + nil -> {:error, :not_found} + {:error, reason} -> {:error, reason} end end diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 8b9477927..8e482eef7 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -3,6 +3,8 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.CommonAPI.Utils do + import Pleroma.Web.Gettext + alias Calendar.Strftime alias Comeonin.Pbkdf2 alias Pleroma.Activity @@ -372,7 +374,7 @@ def confirm_current_password(user, password) do true <- Pbkdf2.checkpw(password, db_user.password_hash) do {:ok, db_user} else - _ -> {:error, "Invalid password."} + _ -> {:error, dgettext("errors", "Invalid password.")} end end @@ -455,7 +457,8 @@ def make_report_content_html(comment) do if String.length(comment) <= max_size do {:ok, format_input(comment, "text/plain")} else - {:error, "Comment must be up to #{max_size} characters"} + {:error, + dgettext("errors", "Comment must be up to %{max_size} characters", max_size: max_size)} end end @@ -490,7 +493,7 @@ def conversation_id_to_context(id) do context else _e -> - {:error, "No such conversation"} + {:error, dgettext("errors", "No such conversation")} end end @@ -512,10 +515,10 @@ def validate_character_limit(full_payload, attachments, limit) do if length > 0 or Enum.count(attachments) > 0 do :ok else - {:error, "Cannot post an empty status without attachments"} + {:error, dgettext("errors", "Cannot post an empty status without attachments")} end else - {:error, "The status is over the character limit"} + {:error, dgettext("errors", "The status is over the character limit")} end end end diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 0d3a878bb..82f180635 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -160,10 +160,7 @@ def update_credentials(%{assigns: %{user: user}} = conn, params) do AccountView.render("account.json", %{user: user, for: user, with_pleroma_settings: true}) ) else - _e -> - conn - |> put_status(403) - |> json(%{error: "Invalid request"}) + _e -> render_error(conn, :forbidden, "Invalid request") end end @@ -258,10 +255,7 @@ def user(%{assigns: %{user: for_user}} = conn, %{"id" => nickname_or_id}) do account = AccountView.render("account.json", %{user: user, for: for_user}) json(conn, account) else - _e -> - conn - |> put_status(404) - |> json(%{error: "Can't find user"}) + _e -> render_error(conn, :not_found, "Can't find user") end end @@ -509,15 +503,8 @@ def get_poll(%{assigns: %{user: user}} = conn, %{"id" => id}) do |> put_view(StatusView) |> try_render("poll.json", %{object: object, for: user}) else - nil -> - conn - |> put_status(404) - |> json(%{error: "Record not found"}) - - false -> - conn - |> put_status(404) - |> json(%{error: "Record not found"}) + nil -> render_error(conn, :not_found, "Record not found") + false -> render_error(conn, :not_found, "Record not found") end end @@ -546,18 +533,14 @@ def poll_vote(%{assigns: %{user: user}} = conn, %{"id" => id, "choices" => choic |> try_render("poll.json", %{object: object, for: user}) else nil -> - conn - |> put_status(404) - |> json(%{error: "Record not found"}) + render_error(conn, :not_found, "Record not found") false -> - conn - |> put_status(404) - |> json(%{error: "Record not found"}) + render_error(conn, :not_found, "Record not found") {:error, message} -> conn - |> put_status(422) + |> put_status(:unprocessable_entity) |> json(%{error: message}) end end @@ -646,10 +629,7 @@ def delete_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do with {:ok, %Activity{}} <- CommonAPI.delete(id, user) do json(conn, %{}) else - _e -> - conn - |> put_status(403) - |> json(%{error: "Can't delete this post"}) + _e -> render_error(conn, :forbidden, "Can't delete this post") end end @@ -697,8 +677,8 @@ def pin_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do else {:error, reason} -> conn - |> put_resp_content_type("application/json") - |> send_resp(:bad_request, Jason.encode!(%{"error" => reason})) + |> put_status(:bad_request) + |> json(%{"error" => reason}) end end @@ -774,8 +754,8 @@ def get_notification(%{assigns: %{user: user}} = conn, %{"id" => id} = _params) else {:error, reason} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => reason})) + |> put_status(:forbidden) + |> json(%{"error" => reason}) end end @@ -790,8 +770,8 @@ def dismiss_notification(%{assigns: %{user: user}} = conn, %{"id" => id} = _para else {:error, reason} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => reason})) + |> put_status(:forbidden) + |> json(%{"error" => reason}) end end @@ -869,9 +849,7 @@ def set_mascot(%{assigns: %{user: user}} = conn, %{"file" => file}) do conn |> json(rendered) else - conn - |> put_resp_content_type("application/json") - |> send_resp(415, Jason.encode!(%{"error" => "mascots can only be images"})) + render_error(conn, :unsupported_media_type, "mascots can only be images") end end end @@ -1000,8 +978,8 @@ def authorize_follow_request(%{assigns: %{user: followed}} = conn, %{"id" => id} else {:error, message} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => message})) + |> put_status(:forbidden) + |> json(%{error: message}) end end @@ -1014,8 +992,8 @@ def reject_follow_request(%{assigns: %{user: followed}} = conn, %{"id" => id}) d else {:error, message} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => message})) + |> put_status(:forbidden) + |> json(%{error: message}) end end @@ -1032,8 +1010,8 @@ def follow(%{assigns: %{user: follower}} = conn, %{"id" => id}) do {:error, message} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => message})) + |> put_status(:forbidden) + |> json(%{error: message}) end end @@ -1050,8 +1028,8 @@ def follow(%{assigns: %{user: follower}} = conn, %{"uri" => uri}) do {:error, message} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => message})) + |> put_status(:forbidden) + |> json(%{error: message}) end end @@ -1080,8 +1058,8 @@ def mute(%{assigns: %{user: muter}} = conn, %{"id" => id}) do else {:error, message} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => message})) + |> put_status(:forbidden) + |> json(%{error: message}) end end @@ -1094,8 +1072,8 @@ def unmute(%{assigns: %{user: muter}} = conn, %{"id" => id}) do else {:error, message} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => message})) + |> put_status(:forbidden) + |> json(%{error: message}) end end @@ -1116,8 +1094,8 @@ def block(%{assigns: %{user: blocker}} = conn, %{"id" => id}) do else {:error, message} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => message})) + |> put_status(:forbidden) + |> json(%{error: message}) end end @@ -1131,8 +1109,8 @@ def unblock(%{assigns: %{user: blocker}} = conn, %{"id" => id}) do else {:error, message} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => message})) + |> put_status(:forbidden) + |> json(%{error: message}) end end @@ -1166,8 +1144,8 @@ def subscribe(%{assigns: %{user: user}} = conn, %{"id" => id}) do else {:error, message} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => message})) + |> put_status(:forbidden) + |> json(%{error: message}) end end @@ -1180,8 +1158,8 @@ def unsubscribe(%{assigns: %{user: user}} = conn, %{"id" => id}) do else {:error, message} -> conn - |> put_resp_content_type("application/json") - |> send_resp(403, Jason.encode!(%{"error" => message})) + |> put_status(:forbidden) + |> json(%{error: message}) end end @@ -1229,13 +1207,8 @@ def user_favourites(%{assigns: %{user: for_user}} = conn, %{"id" => id} = params |> put_view(StatusView) |> render("index.json", %{activities: activities, for: for_user, as: :activity}) else - nil -> - {:error, :not_found} - - true -> - conn - |> put_status(403) - |> json(%{error: "Can't get favorites"}) + nil -> {:error, :not_found} + true -> render_error(conn, :forbidden, "Can't get favorites") end end @@ -1267,10 +1240,7 @@ def get_list(%{assigns: %{user: user}} = conn, %{"id" => id}) do res = ListView.render("list.json", list: list) json(conn, res) else - _e -> - conn - |> put_status(404) - |> json(%{error: "Record not found"}) + _e -> render_error(conn, :not_found, "Record not found") end end @@ -1286,7 +1256,7 @@ def delete_list(%{assigns: %{user: user}} = conn, %{"id" => id}) do json(conn, %{}) else _e -> - json(conn, "error") + json(conn, dgettext("errors", "error")) end end @@ -1337,7 +1307,7 @@ def rename_list(%{assigns: %{user: user}} = conn, %{"id" => id, "title" => title json(conn, res) else _e -> - json(conn, "error") + json(conn, dgettext("errors", "error")) end end @@ -1361,10 +1331,7 @@ def list_timeline(%{assigns: %{user: user}} = conn, %{"list_id" => id} = params) |> put_view(StatusView) |> render("index.json", %{activities: activities, for: user, as: :activity}) else - _e -> - conn - |> put_status(403) - |> json(%{error: "Error."}) + _e -> render_error(conn, :forbidden, "Error.") end end @@ -1483,8 +1450,8 @@ def put_settings(%{assigns: %{user: user}} = conn, %{"data" => settings} = _para else e -> conn - |> put_resp_content_type("application/json") - |> send_resp(500, Jason.encode!(%{"error" => inspect(e)})) + |> put_status(:internal_server_error) + |> json(%{error: inspect(e)}) end end @@ -1652,20 +1619,18 @@ def errors(conn, {:error, %Changeset{} = changeset}) do |> Enum.map_join(", ", fn {_k, v} -> v end) conn - |> put_status(422) + |> put_status(:unprocessable_entity) |> json(%{error: error_message}) end def errors(conn, {:error, :not_found}) do - conn - |> put_status(404) - |> json(%{error: "Record not found"}) + render_error(conn, :not_found, "Record not found") end def errors(conn, _) do conn - |> put_status(500) - |> json("Something went wrong") + |> put_status(:internal_server_error) + |> json(dgettext("errors", "Something went wrong")) end def suggestions(%{assigns: %{user: user}} = conn, _) do @@ -1785,21 +1750,17 @@ def account_register( else {:error, errors} -> conn - |> put_status(400) - |> json(Jason.encode!(errors)) + |> put_status(:bad_request) + |> json(errors) end end def account_register(%{assigns: %{app: _app}} = conn, _params) do - conn - |> put_status(400) - |> json(%{error: "Missing parameters"}) + render_error(conn, :bad_request, "Missing parameters") end def account_register(conn, _) do - conn - |> put_status(403) - |> json(%{error: "Invalid credentials"}) + render_error(conn, :forbidden, "Invalid credentials") end def conversations(%{assigns: %{user: user}} = conn, params) do @@ -1829,21 +1790,14 @@ def conversation_read(%{assigns: %{user: user}} = conn, %{"id" => participation_ def try_render(conn, target, params) when is_binary(target) do - res = render(conn, target, params) - - if res == nil do - conn - |> put_status(501) - |> json(%{error: "Can't display this activity"}) - else - res + case render(conn, target, params) do + nil -> render_error(conn, :not_implemented, "Can't display this activity") + res -> res end end def try_render(conn, _, _) do - conn - |> put_status(501) - |> json(%{error: "Can't display this activity"}) + render_error(conn, :not_implemented, "Can't display this activity") end defp present?(nil), do: false diff --git a/lib/pleroma/web/mastodon_api/subscription_controller.ex b/lib/pleroma/web/mastodon_api/subscription_controller.ex index b6c8ff808..255ee2f18 100644 --- a/lib/pleroma/web/mastodon_api/subscription_controller.ex +++ b/lib/pleroma/web/mastodon_api/subscription_controller.ex @@ -59,13 +59,13 @@ def delete(%{assigns: %{user: user, token: token}} = conn, _params) do # def errors(conn, {:error, :not_found}) do conn - |> put_status(404) - |> json("Not found") + |> put_status(:not_found) + |> json(dgettext("errors", "Not found")) end def errors(conn, _) do conn - |> put_status(500) - |> json("Something went wrong") + |> put_status(:internal_server_error) + |> json(dgettext("errors", "Something went wrong")) end end diff --git a/lib/pleroma/web/mongooseim/mongoose_im_controller.ex b/lib/pleroma/web/mongooseim/mongoose_im_controller.ex index 489d5d3a5..b786a521b 100644 --- a/lib/pleroma/web/mongooseim/mongoose_im_controller.ex +++ b/lib/pleroma/web/mongooseim/mongoose_im_controller.ex @@ -29,7 +29,7 @@ def check_password(conn, %{"user" => username, "pass" => password}) do else false -> conn - |> put_status(403) + |> put_status(:forbidden) |> json(false) _ -> diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex index 869dda5c5..cd9a4f4a8 100644 --- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex +++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex @@ -201,8 +201,6 @@ def nodeinfo(conn, %{"version" => "2.1"}) do end def nodeinfo(conn, _) do - conn - |> put_status(404) - |> json(%{error: "Nodeinfo schema version not handled"}) + render_error(conn, :not_found, "Nodeinfo schema version not handled") end end diff --git a/lib/pleroma/web/oauth/fallback_controller.ex b/lib/pleroma/web/oauth/fallback_controller.ex index e3984f009..dd7f08bf1 100644 --- a/lib/pleroma/web/oauth/fallback_controller.ex +++ b/lib/pleroma/web/oauth/fallback_controller.ex @@ -9,21 +9,24 @@ defmodule Pleroma.Web.OAuth.FallbackController do def call(conn, {:register, :generic_error}) do conn |> put_status(:internal_server_error) - |> put_flash(:error, "Unknown error, please check the details and try again.") + |> put_flash( + :error, + dgettext("errors", "Unknown error, please check the details and try again.") + ) |> OAuthController.registration_details(conn.params) end def call(conn, {:register, _error}) do conn |> put_status(:unauthorized) - |> put_flash(:error, "Invalid Username/Password") + |> put_flash(:error, dgettext("errors", "Invalid Username/Password")) |> OAuthController.registration_details(conn.params) end def call(conn, _error) do conn |> put_status(:unauthorized) - |> put_flash(:error, "Invalid Username/Password") + |> put_flash(:error, dgettext("errors", "Invalid Username/Password")) |> OAuthController.authorize(conn.params) end end diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex index 3f8e3b074..ef53b7ae3 100644 --- a/lib/pleroma/web/oauth/oauth_controller.ex +++ b/lib/pleroma/web/oauth/oauth_controller.ex @@ -90,7 +90,7 @@ defp handle_existing_authorization( redirect(conn, external: url) else conn - |> put_flash(:error, "Unlisted redirect_uri.") + |> put_flash(:error, dgettext("errors", "Unlisted redirect_uri.")) |> redirect(external: redirect_uri(conn, redirect_uri)) end end @@ -128,7 +128,7 @@ def after_create_authorization(%Plug.Conn{} = conn, %Authorization{} = auth, %{ redirect(conn, external: url) else conn - |> put_flash(:error, "Unlisted redirect_uri.") + |> put_flash(:error, dgettext("errors", "Unlisted redirect_uri.")) |> redirect(external: redirect_uri(conn, redirect_uri)) end end @@ -142,7 +142,7 @@ defp handle_create_authorization_error( # Per https://github.com/tootsuite/mastodon/blob/ # 51e154f5e87968d6bb115e053689767ab33e80cd/app/controllers/api/base_controller.rb#L39 conn - |> put_flash(:error, "This action is outside the authorized scopes") + |> put_flash(:error, dgettext("errors", "This action is outside the authorized scopes")) |> put_status(:unauthorized) |> authorize(params) end @@ -155,7 +155,7 @@ defp handle_create_authorization_error( # Per https://github.com/tootsuite/mastodon/blob/ # 51e154f5e87968d6bb115e053689767ab33e80cd/app/controllers/api/base_controller.rb#L76 conn - |> put_flash(:error, "Your login is missing a confirmed e-mail address") + |> put_flash(:error, dgettext("errors", "Your login is missing a confirmed e-mail address")) |> put_status(:forbidden) |> authorize(params) end @@ -176,9 +176,7 @@ def token_exchange( json(conn, Token.Response.build(user, token, response_attrs)) else - _error -> - put_status(conn, 400) - |> json(%{error: "Invalid credentials"}) + _error -> render_invalid_credentials_error(conn) end end @@ -192,9 +190,7 @@ def token_exchange(%Plug.Conn{} = conn, %{"grant_type" => "authorization_code"} json(conn, Token.Response.build(user, token, response_attrs)) else - _error -> - put_status(conn, 400) - |> json(%{error: "Invalid credentials"}) + _error -> render_invalid_credentials_error(conn) end end @@ -214,18 +210,13 @@ def token_exchange( {:auth_active, false} -> # Per https://github.com/tootsuite/mastodon/blob/ # 51e154f5e87968d6bb115e053689767ab33e80cd/app/controllers/api/base_controller.rb#L76 - conn - |> put_status(:forbidden) - |> json(%{error: "Your login is missing a confirmed e-mail address"}) + render_error(conn, :forbidden, "Your login is missing a confirmed e-mail address") {:user_active, false} -> - conn - |> put_status(:forbidden) - |> json(%{error: "Your account is currently disabled"}) + render_error(conn, :forbidden, "Your account is currently disabled") _error -> - put_status(conn, 400) - |> json(%{error: "Invalid credentials"}) + render_invalid_credentials_error(conn) end end @@ -247,9 +238,7 @@ def token_exchange(%Plug.Conn{} = conn, %{"grant_type" => "client_credentials"} {:ok, token} <- Token.exchange_token(app, auth) do json(conn, Token.Response.build_for_client_credentials(token)) else - _error -> - put_status(conn, 400) - |> json(%{error: "Invalid credentials"}) + _error -> render_invalid_credentials_error(conn) end end @@ -271,9 +260,7 @@ def token_revoke(%Plug.Conn{} = conn, params), do: bad_request(conn, params) # Response for bad request defp bad_request(%Plug.Conn{} = conn, _) do - conn - |> put_status(500) - |> json(%{error: "Bad request"}) + render_error(conn, :internal_server_error, "Bad request") end @doc "Prepares OAuth request to provider for Ueberauth" @@ -304,9 +291,11 @@ def prepare_request(%Plug.Conn{} = conn, %{ def request(%Plug.Conn{} = conn, params) do message = if params["provider"] do - "Unsupported OAuth provider: #{params["provider"]}." + dgettext("errors", "Unsupported OAuth provider: %{provider}.", + provider: params["provider"] + ) else - "Bad OAuth request." + dgettext("errors", "Bad OAuth request.") end conn @@ -320,7 +309,10 @@ def callback(%Plug.Conn{assigns: %{ueberauth_failure: failure}} = conn, params) message = Enum.join(messages, "; ") conn - |> put_flash(:error, "Failed to authenticate: #{message}.") + |> put_flash( + :error, + dgettext("errors", "Failed to authenticate: %{message}.", message: message) + ) |> redirect(external: redirect_uri(conn, params["redirect_uri"])) end @@ -350,7 +342,7 @@ def callback(%Plug.Conn{} = conn, params) do Logger.debug(inspect(["OAUTH_ERROR", error, conn.assigns])) conn - |> put_flash(:error, "Failed to set up user account.") + |> put_flash(:error, dgettext("errors", "Failed to set up user account.")) |> redirect(external: redirect_uri(conn, params["redirect_uri"])) end end @@ -468,4 +460,8 @@ def default_redirect_uri(%App{} = app) do |> String.split() |> Enum.at(0) end + + defp render_invalid_credentials_error(conn) do + render_error(conn, :bad_request, "Invalid credentials") + end end diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index 2fb6ce41b..372d52899 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -245,14 +245,10 @@ defp represent_activity(conn, _, activity, user) do end def errors(conn, {:error, :not_found}) do - conn - |> put_status(404) - |> text("Not found") + render_error(conn, :not_found, "Not found") end def errors(conn, _) do - conn - |> put_status(500) - |> text("Something went wrong") + render_error(conn, :internal_server_error, "Something went wrong") end end diff --git a/lib/pleroma/web/uploader_controller.ex b/lib/pleroma/web/uploader_controller.ex index d11e8e63e..bf09775e6 100644 --- a/lib/pleroma/web/uploader_controller.ex +++ b/lib/pleroma/web/uploader_controller.ex @@ -12,7 +12,7 @@ def callback(conn, %{"upload_path" => upload_path} = params) do end def callbacks(conn, _) do - send_resp(conn, 400, "bad request") + render_error(conn, :bad_request, "bad request") end defp process_callback(conn, pid, params) when is_pid(pid) do @@ -24,6 +24,6 @@ defp process_callback(conn, pid, params) when is_pid(pid) do end defp process_callback(conn, _, _) do - send_resp(conn, 400, "bad request") + render_error(conn, :bad_request, "bad request") end end diff --git a/priv/gettext/en/LC_MESSAGES/errors.po b/priv/gettext/en/LC_MESSAGES/errors.po index 2211c98e3..25a2f73e4 100644 --- a/priv/gettext/en/LC_MESSAGES/errors.po +++ b/priv/gettext/en/LC_MESSAGES/errors.po @@ -91,3 +91,375 @@ msgstr "" msgid "must be equal to %{number}" msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:381 +msgid "Account not found" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:153 +msgid "Already voted" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:263 +msgid "Bad request" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:254 +msgid "Can't delete object" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:569 +msgid "Can't delete this post" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1731 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1737 +msgid "Can't display this activity" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:195 +msgid "Can't find user" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1148 +msgid "Can't get favorites" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:263 +msgid "Can't like object" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/utils.ex:518 +msgid "Cannot post an empty status without attachments" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/utils.ex:461 +msgid "Comment must be up to %{max_size} characters" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/admin_api/config.ex:63 +msgid "Config with params %{params} not found" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:78 +msgid "Could not delete" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:110 +msgid "Could not favorite" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:310 +msgid "Could not pin" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:89 +msgid "Could not repeat" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:120 +msgid "Could not unfavorite" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:327 +msgid "Could not unpin" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:99 +msgid "Could not unrepeat" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:392 +msgid "Could not update state" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1271 +msgid "Error." +msgstr "" + +#, elixir-format +#: lib/pleroma/captcha/kocaptcha.ex:36 +msgid "Invalid CAPTCHA" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1700 +#: lib/pleroma/web/oauth/oauth_controller.ex:465 +msgid "Invalid credentials" +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/ensure_authenticated_plug.ex:20 +msgid "Invalid credentials." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:154 +msgid "Invalid indices" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/admin_api/admin_api_controller.ex:411 +msgid "Invalid parameters" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/utils.ex:377 +msgid "Invalid password." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:163 +msgid "Invalid request" +msgstr "" + +#, elixir-format +#: lib/pleroma/captcha/kocaptcha.ex:16 +msgid "Kocaptcha service unavailable" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1696 +msgid "Missing parameters" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/utils.ex:496 +msgid "No such conversation" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/admin_api/admin_api_controller.ex:163 +#: lib/pleroma/web/admin_api/admin_api_controller.ex:206 +msgid "No such permission_group" +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/uploaded_media.ex:69 +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:311 +#: lib/pleroma/web/admin_api/admin_api_controller.ex:399 +#: lib/pleroma/web/mastodon_api/subscription_controller.ex:63 +#: lib/pleroma/web/ostatus/ostatus_controller.ex:248 +msgid "Not found" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:152 +msgid "Poll's author can't vote" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:443 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:444 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:473 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:476 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1180 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1564 +msgid "Record not found" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/admin_api/admin_api_controller.ex:417 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1570 +#: lib/pleroma/web/mastodon_api/subscription_controller.ex:69 +#: lib/pleroma/web/ostatus/ostatus_controller.ex:252 +msgid "Something went wrong" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:253 +msgid "The message visibility must be direct" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/utils.ex:521 +msgid "The status is over the character limit" +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex:27 +msgid "This resource requires authentication." +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/rate_limiter.ex:89 +msgid "Throttled" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:155 +msgid "Too many choices" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:268 +msgid "Unhandled activity type" +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/user_is_admin_plug.ex:20 +msgid "User is not admin." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:380 +msgid "Valid `account_id` required" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/admin_api/admin_api_controller.ex:185 +msgid "You can't revoke your own admin status." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:216 +msgid "Your account is currently disabled" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:158 +#: lib/pleroma/web/oauth/oauth_controller.ex:213 +msgid "Your login is missing a confirmed e-mail address" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:221 +msgid "can't read inbox of %{nickname} as %{as_nickname}" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:297 +msgid "can't update outbox of %{nickname} as %{as_nickname}" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:335 +msgid "conversation is already muted" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:192 +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:317 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1196 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1247 +msgid "error" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:789 +msgid "mascots can only be images" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:34 +msgid "not found" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:298 +msgid "Bad OAuth request." +msgstr "" + +#, elixir-format +#: lib/pleroma/captcha/captcha.ex:92 +msgid "CAPTCHA already used" +msgstr "" + +#, elixir-format +#: lib/pleroma/captcha/captcha.ex:89 +msgid "CAPTCHA expired" +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/uploaded_media.ex:50 +msgid "Failed" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:314 +msgid "Failed to authenticate: %{message}." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:345 +msgid "Failed to set up user account." +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/oauth_scopes_plug.ex:37 +msgid "Insufficient permissions: %{permissions}." +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/uploaded_media.ex:89 +msgid "Internal Error" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/fallback_controller.ex:22 +#: lib/pleroma/web/oauth/fallback_controller.ex:29 +msgid "Invalid Username/Password" +msgstr "" + +#, elixir-format +#: lib/pleroma/captcha/captcha.ex:107 +msgid "Invalid answer data" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/nodeinfo/nodeinfo_controller.ex:204 +msgid "Nodeinfo schema version not handled" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:145 +msgid "This action is outside the authorized scopes" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/fallback_controller.ex:14 +msgid "Unknown error, please check the details and try again." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:93 +#: lib/pleroma/web/oauth/oauth_controller.ex:131 +msgid "Unlisted redirect_uri." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:294 +msgid "Unsupported OAuth provider: %{provider}." +msgstr "" + +#, elixir-format +#: lib/pleroma/uploaders/uploader.ex:71 +msgid "Uploader callback timeout" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/uploader_controller.ex:11 +#: lib/pleroma/web/uploader_controller.ex:23 +msgid "bad request" +msgstr "" diff --git a/priv/gettext/errors.pot b/priv/gettext/errors.pot index a964f84ec..2fd9c42e3 100644 --- a/priv/gettext/errors.pot +++ b/priv/gettext/errors.pot @@ -7,7 +7,6 @@ ## Run `mix gettext.extract` to bring this file up to ## date. Leave `msgstr`s empty as changing them here as no ## effect: edit them in PO (`.po`) files instead. - ## From Ecto.Changeset.cast/4 msgid "can't be blank" msgstr "" @@ -89,3 +88,375 @@ msgstr "" msgid "must be equal to %{number}" msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:381 +msgid "Account not found" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:153 +msgid "Already voted" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:263 +msgid "Bad request" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:254 +msgid "Can't delete object" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:569 +msgid "Can't delete this post" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1731 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1737 +msgid "Can't display this activity" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:195 +msgid "Can't find user" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1148 +msgid "Can't get favorites" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:263 +msgid "Can't like object" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/utils.ex:518 +msgid "Cannot post an empty status without attachments" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/utils.ex:461 +msgid "Comment must be up to %{max_size} characters" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/admin_api/config.ex:63 +msgid "Config with params %{params} not found" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:78 +msgid "Could not delete" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:110 +msgid "Could not favorite" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:310 +msgid "Could not pin" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:89 +msgid "Could not repeat" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:120 +msgid "Could not unfavorite" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:327 +msgid "Could not unpin" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:99 +msgid "Could not unrepeat" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:392 +msgid "Could not update state" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1271 +msgid "Error." +msgstr "" + +#, elixir-format +#: lib/pleroma/captcha/kocaptcha.ex:36 +msgid "Invalid CAPTCHA" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1700 +#: lib/pleroma/web/oauth/oauth_controller.ex:465 +msgid "Invalid credentials" +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/ensure_authenticated_plug.ex:20 +msgid "Invalid credentials." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:154 +msgid "Invalid indices" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/admin_api/admin_api_controller.ex:411 +msgid "Invalid parameters" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/utils.ex:377 +msgid "Invalid password." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:163 +msgid "Invalid request" +msgstr "" + +#, elixir-format +#: lib/pleroma/captcha/kocaptcha.ex:16 +msgid "Kocaptcha service unavailable" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1696 +msgid "Missing parameters" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/utils.ex:496 +msgid "No such conversation" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/admin_api/admin_api_controller.ex:163 +#: lib/pleroma/web/admin_api/admin_api_controller.ex:206 +msgid "No such permission_group" +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/uploaded_media.ex:69 +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:311 +#: lib/pleroma/web/admin_api/admin_api_controller.ex:399 +#: lib/pleroma/web/mastodon_api/subscription_controller.ex:63 +#: lib/pleroma/web/ostatus/ostatus_controller.ex:248 +msgid "Not found" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:152 +msgid "Poll's author can't vote" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:443 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:444 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:473 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:476 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1180 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1564 +msgid "Record not found" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/admin_api/admin_api_controller.ex:417 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1570 +#: lib/pleroma/web/mastodon_api/subscription_controller.ex:69 +#: lib/pleroma/web/ostatus/ostatus_controller.ex:252 +msgid "Something went wrong" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:253 +msgid "The message visibility must be direct" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/utils.ex:521 +msgid "The status is over the character limit" +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex:27 +msgid "This resource requires authentication." +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/rate_limiter.ex:89 +msgid "Throttled" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:155 +msgid "Too many choices" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:268 +msgid "Unhandled activity type" +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/user_is_admin_plug.ex:20 +msgid "User is not admin." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:380 +msgid "Valid `account_id` required" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/admin_api/admin_api_controller.ex:185 +msgid "You can't revoke your own admin status." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:216 +msgid "Your account is currently disabled" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:158 +#: lib/pleroma/web/oauth/oauth_controller.ex:213 +msgid "Your login is missing a confirmed e-mail address" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:221 +msgid "can't read inbox of %{nickname} as %{as_nickname}" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:297 +msgid "can't update outbox of %{nickname} as %{as_nickname}" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/common_api/common_api.ex:335 +msgid "conversation is already muted" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:192 +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:317 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1196 +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1247 +msgid "error" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:789 +msgid "mascots can only be images" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:34 +msgid "not found" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:298 +msgid "Bad OAuth request." +msgstr "" + +#, elixir-format +#: lib/pleroma/captcha/captcha.ex:92 +msgid "CAPTCHA already used" +msgstr "" + +#, elixir-format +#: lib/pleroma/captcha/captcha.ex:89 +msgid "CAPTCHA expired" +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/uploaded_media.ex:50 +msgid "Failed" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:314 +msgid "Failed to authenticate: %{message}." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:345 +msgid "Failed to set up user account." +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/oauth_scopes_plug.ex:37 +msgid "Insufficient permissions: %{permissions}." +msgstr "" + +#, elixir-format +#: lib/pleroma/plugs/uploaded_media.ex:89 +msgid "Internal Error" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/fallback_controller.ex:22 +#: lib/pleroma/web/oauth/fallback_controller.ex:29 +msgid "Invalid Username/Password" +msgstr "" + +#, elixir-format +#: lib/pleroma/captcha/captcha.ex:107 +msgid "Invalid answer data" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/nodeinfo/nodeinfo_controller.ex:204 +msgid "Nodeinfo schema version not handled" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:145 +msgid "This action is outside the authorized scopes" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/fallback_controller.ex:14 +msgid "Unknown error, please check the details and try again." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:93 +#: lib/pleroma/web/oauth/oauth_controller.ex:131 +msgid "Unlisted redirect_uri." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/oauth/oauth_controller.ex:294 +msgid "Unsupported OAuth provider: %{provider}." +msgstr "" + +#, elixir-format +#: lib/pleroma/uploaders/uploader.ex:71 +msgid "Uploader callback timeout" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/uploader_controller.ex:11 +#: lib/pleroma/web/uploader_controller.ex:23 +msgid "bad request" +msgstr ""