From 6de84a115f474d00c31ad73340184eada6a6d097 Mon Sep 17 00:00:00 2001 From: Dannek Rose Date: Mon, 29 May 2023 00:16:42 +0000 Subject: [PATCH 01/66] Translated using Weblate (Japanese) Currently translated at 46.5% (729 of 1566 strings) Translation: Mobilizon/Frontend Translate-URL: https://weblate.framasoft.org/projects/mobilizon/frontend/ja/ --- js/src/i18n/ja.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/js/src/i18n/ja.json b/js/src/i18n/ja.json index 2e53ab859..6bf2a9521 100644 --- a/js/src/i18n/ja.json +++ b/js/src/i18n/ja.json @@ -180,7 +180,7 @@ "Click to upload": "クリックしてアップロードする", "Close": "閉じる", "Close comments for all (except for admins)": "管理者以外のアカウントはコメントが不可にする", - "Closed": "閉じる", + "Closed": "停止", "Comment body": "", "Comment deleted": "コメントが削除されました。", "Comment text can't be empty": "コメントのテキストは空白にはできません", @@ -438,7 +438,7 @@ "Identity {displayName} created": "{displayName}のアイデンティティが作成されました", "Identity {displayName} deleted": "{displayName}のアイデンティティが削除されました", "Identity {displayName} updated": "{displayName}のアイデンティティが更新されました", - "If allowed by organizer": "", + "If allowed by organizer": "イベントの主催者が決める", "If an account with this email exists, we just sent another confirmation email to {email}": "", "If this identity is the only administrator of some groups, you need to delete them before being able to delete this identity.": "", "If you are being asked for your federated indentity, it's composed of your username and your instance. For instance, the federated identity for your first profile is:": "連合のアイデンティティー、また連合のアカウントの場合はあなたのユーバー名とインスタンスのドメインです。例えば、一番最初に作成したプロフィールの連合のアイデンティティーは:", @@ -629,7 +629,7 @@ "Notifications for manually approved participations to an event": "", "Notify participants": "", "Now, create your first profile:": "", - "Number of places": "行う場所の数", + "Number of places": "参加可能の人の数", "OK": "OK", "Old password": "古いパスワード", "On {date}": "{date} に行う", @@ -648,7 +648,7 @@ "Only group moderators can create, edit and delete events.": "グループのモデレーターのみがイベントを作成、編集、削除できます。", "Only group moderators can create, edit and delete posts.": "", "Only registered users may fetch remote events from their URL.": "", - "Open": "", + "Open": "可能", "Open a topic on our forum": "フォーラムでトピックを作成する", "Open an issue on our bug tracker (advanced users)": "(上級ユーザー向け)バグトラッカー上でissueを開く", "Opened reports": "", @@ -757,7 +757,7 @@ "Registration is allowed, anyone can register.": "制限なくアカウントの新規登録可能です。", "Registration is closed.": "アカウントの新規登録が停止されています。", "Registration is currently closed.": "アカウントの新規登録が停止中です。", - "Registrations": "", + "Registrations": "アカウントの新規登録", "Registrations are restricted by allowlisting.": "新規登録は管理者と事前連絡済みの方のみができます。", "Reject": "拒否する", "Reject member": "", @@ -956,8 +956,8 @@ "This week": "今週", "This weekend": "今週末", "This will delete / anonymize all content (events, comments, messages, participations…) created from this identity.": "", - "Time in your timezone ({timezone})": "", - "Times in your timezone ({timezone})": "", + "Time in your timezone ({timezone})": "あなたのタイムゾーン ({timezone})", + "Times in your timezone ({timezone})": "あなたのタイムゾーン ({timezone})", "Timezone": "タイムゾーン", "Timezone detected as {timezone}.": "", "Title": "タイトル", From 850b4e2a735e335c4737caa8b60e190613e778ef Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 26 May 2023 15:55:17 +0200 Subject: [PATCH 02/66] fix(rich media): fix error handling when resource preview URL leads to empty parsed data Closes #1279 Signed-off-by: Thomas Citharel --- lib/graphql/resolvers/resource.ex | 9 ++-- lib/service/rich_media/parser.ex | 42 ++++++++++--------- .../rich_media/parsers/oembed_parser.ex | 4 +- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/lib/graphql/resolvers/resource.ex b/lib/graphql/resolvers/resource.ex index 5df019448..d86fff8cf 100644 --- a/lib/graphql/resolvers/resource.ex +++ b/lib/graphql/resolvers/resource.ex @@ -80,6 +80,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Resource do } } = _resolution ) do + Logger.debug("Getting resource for group with username #{username}") + with {:group, %Actor{id: group_id}} <- {:group, Actors.get_actor_by_name(username, :Group)}, {:member, true} <- {:member, Actors.is_member?(actor_id, group_id)}, {:resource, %Resource{} = resource} <- @@ -222,13 +224,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Resource do {:ok, data} when is_map(data) -> {:ok, struct(Metadata, data)} - {:error, :invalid_parsed_data} -> + {:error, _error_type, _} -> {:error, dgettext("errors", "Unable to fetch resource details from this URL.")} - - {:error, err} -> - Logger.warn("Error while fetching preview from #{inspect(resource_url)}") - Logger.debug(inspect(err)) - {:error, :unknown_resource} end end diff --git a/lib/service/rich_media/parser.ex b/lib/service/rich_media/parser.ex index 1873ca832..2821f823d 100644 --- a/lib/service/rich_media/parser.ex +++ b/lib/service/rich_media/parser.ex @@ -29,19 +29,19 @@ defmodule Mobilizon.Service.RichMedia.Parser do def parse(nil), do: {:error, "No URL provided"} - @spec parse(String.t()) :: {:ok, map()} | {:error, any()} + @spec parse(String.t()) :: {:ok, map()} | {:error, :http | :parsing | :unknown, any()} def parse(url) do case Cachex.fetch(:rich_media_cache, url, fn _ -> case parse_url(url) do {:ok, data} -> {:commit, data} - {:error, err} -> {:ignore, err} + {:error, error_type, error} -> {:ignore, {error_type, error}} end end) do {status, value} when status in [:ok, :commit] -> {:ok, value} - {_, err} -> - {:error, err} + {_, {error_type, err}} -> + {:error, error_type, err} end rescue e -> @@ -56,7 +56,8 @@ defmodule Mobilizon.Service.RichMedia.Parser do get_filename_from_headers(response_headers) || get_filename_from_url(url) end - @spec parse_url(String.t(), Enum.t()) :: {:ok, map()} | {:error, any()} + @spec parse_url(String.t(), Enum.t()) :: + {:ok, map()} | {:error, :http | :parsing | :unknown, any()} defp parse_url(url, options \\ []) do user_agent = Keyword.get(options, :user_agent, default_user_agent(url)) headers = [{"User-Agent", user_agent}] @@ -64,13 +65,14 @@ defmodule Mobilizon.Service.RichMedia.Parser do try do with {:ok, _} <- prevent_local_address(url), - {:ok, %{body: body, status: code, headers: response_headers}} + {:fetch, {:ok, %{body: body, status: code, headers: response_headers}}} when code in 200..299 <- - RichMediaPreviewClient.get( - url, - headers: headers, - opts: @options - ), + {:fetch, + RichMediaPreviewClient.get( + url, + headers: headers, + opts: @options + )}, {:is_html, _response_headers, true} <- {:is_html, response_headers, is_html(response_headers)} do body @@ -87,17 +89,17 @@ defmodule Mobilizon.Service.RichMedia.Parser do {:ok, data} - {:ok, err} -> + {:fetch, {_, err}} -> Logger.debug("HTTP error: #{inspect(err)}") - {:error, "HTTP error: #{inspect(err)}"} + {:error, :http, err} {:error, err} -> - Logger.debug("HTTP error: #{inspect(err)}") - {:error, "HTTP error: #{inspect(err)}"} + Logger.debug("Parsing error: #{inspect(err)}") + {:error, :parsing, err} end rescue e -> - {:error, "Parsing error: #{inspect(e)} #{inspect(__STACKTRACE__)}"} + {:error, :unknown, "Parsing error: #{inspect(e)} #{inspect(__STACKTRACE__)}"} end end @@ -228,7 +230,7 @@ defmodule Mobilizon.Service.RichMedia.Parser do check_parsed_data(data, html, false) else Logger.debug("Found metadata was invalid or incomplete: #{inspect(data)}") - {:error, :invalid_parsed_data} + {:error, :parsing, :invalid_parsed_data} end end @@ -252,11 +254,11 @@ defmodule Mobilizon.Service.RichMedia.Parser do validate_ip(host) do {:ok, url} else - {:error, "Host violates local access rules"} + {:error, :local_address, "Host violates local access rules"} end _ -> - {:error, "Could not detect any host"} + {:error, :no_host, "Could not detect any host"} end end @@ -302,6 +304,8 @@ defmodule Mobilizon.Service.RichMedia.Parser do {:ok, data} end + defp check_remote_picture_path({:error, _, _} = err), do: err + defp check_remote_picture_path(data), do: {:ok, data} @spec format_url(String.t(), String.t()) :: String.t() diff --git a/lib/service/rich_media/parsers/oembed_parser.ex b/lib/service/rich_media/parsers/oembed_parser.ex index bcddd2205..b76c39561 100644 --- a/lib/service/rich_media/parsers/oembed_parser.ex +++ b/lib/service/rich_media/parsers/oembed_parser.ex @@ -67,8 +67,8 @@ defmodule Mobilizon.Service.RichMedia.Parsers.OEmbed do {:ok, data} <- Jason.decode(json), data <- data - |> Map.new(fn {k, v} -> {String.to_existing_atom(k), String.trim(v)} end) - |> Map.take(@oembed_allowed_attributes) do + |> Map.new(fn {k, v} -> {k, if(is_binary(v), do: String.trim(v), else: v)} end) + |> Map.take(Enum.map(@oembed_allowed_attributes, &to_string/1)) do {:ok, data} end end From b0a564f64f72f40b6bb9560f9bc0fbea5d099fd7 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 26 May 2023 16:25:04 +0200 Subject: [PATCH 03/66] fix(group): rephrase "Public Page" to "Announcements", as all posts are not necessary public Closes #900 Signed-off-by: Thomas Citharel --- js/src/components/Group/Sections/PostsSection.vue | 2 +- js/src/i18n/en_US.json | 4 ++-- js/src/i18n/fr_FR.json | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/js/src/components/Group/Sections/PostsSection.vue b/js/src/components/Group/Sections/PostsSection.vue index e4753ffdf..3ee6812f8 100644 --- a/js/src/components/Group/Sections/PostsSection.vue +++ b/js/src/components/Group/Sections/PostsSection.vue @@ -1,6 +1,6 @@