From eaadf261ac9f3befdfd1872e11adec43e3b41a72 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 23 Apr 2021 09:25:57 +0200 Subject: [PATCH 1/6] Handle actor fetch issues better Signed-off-by: Thomas Citharel --- lib/federation/activity_pub/fetcher.ex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/federation/activity_pub/fetcher.ex b/lib/federation/activity_pub/fetcher.ex index 7d1b73d63..019e0237e 100644 --- a/lib/federation/activity_pub/fetcher.ex +++ b/lib/federation/activity_pub/fetcher.ex @@ -119,6 +119,10 @@ defmodule Mobilizon.Federation.ActivityPub.Fetcher do Logger.info("Response HTTP 410") {:error, :actor_deleted} + {:ok, %Tesla.Env{}} -> + Logger.info("Non 200 HTTP Code") + {:error, :http_error} + {:error, e} -> Logger.warn("Could not decode actor at fetch #{url}, #{inspect(e)}") {:error, e} From 2d0abaad4a11c48d2d42f03c92bf6980ca6681e2 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 23 Apr 2021 09:26:16 +0200 Subject: [PATCH 2/6] Handle rendering AP issues Signed-off-by: Thomas Citharel --- lib/web/views/error_view.ex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/web/views/error_view.ex b/lib/web/views/error_view.ex index 4cbc238a2..8d4ba7780 100644 --- a/lib/web/views/error_view.ex +++ b/lib/web/views/error_view.ex @@ -51,6 +51,10 @@ defmodule Mobilizon.Web.ErrorView do render("500.html", assigns) end + def render("500.activity-json", assigns) do + render("500.html", assigns) + end + def render("500.html", assigns) do Mobilizon.Config.instance_config() |> Keyword.get(:default_language, "en") From 687d1685f088970274dcf37daf268eb007cfc1f1 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 23 Apr 2021 09:57:23 +0200 Subject: [PATCH 3/6] Fix metadata remote image URL Signed-off-by: Thomas Citharel --- lib/service/rich_media/parser.ex | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/service/rich_media/parser.ex b/lib/service/rich_media/parser.ex index 2ea91f995..1d45b53d5 100644 --- a/lib/service/rich_media/parser.ex +++ b/lib/service/rich_media/parser.ex @@ -208,7 +208,7 @@ defmodule Mobilizon.Service.RichMedia.Parser do defp check_parsed_data(%{title: title} = data) when is_binary(title) and byte_size(title) > 0 do - {:ok, data} + data end defp check_parsed_data(data) do @@ -285,15 +285,20 @@ defmodule Mobilizon.Service.RichMedia.Parser do image_remote_url = cond do - is_nil(image_uri.host) -> "#{uri.scheme}://#{uri.host}#{image_remote_url}" + is_nil(image_uri.host) -> "#{uri.scheme}://#{uri.host}#{correct_path(image_remote_url)}" is_nil(image_uri.scheme) -> "#{uri.scheme}:#{image_remote_url}" true -> image_remote_url end - Map.put(data, :image_remote_url, image_remote_url) + data = Map.put(data, :image_remote_url, image_remote_url) + {:ok, data} end - defp check_remote_picture_path(data), do: data + defp check_remote_picture_path(data), do: {:ok, data} + + # Sometimes paths have "/" in front, sometimes not + defp correct_path("/" <> _ = path), do: path + defp correct_path(path), do: "/#{path}" # Twitter requires a well-know crawler user-agent to show server-rendered data defp default_user_agent("https://twitter.com/" <> _) do From c023ba63fedf25ce32c52b2e781596daecb7bb36 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 23 Apr 2021 19:12:42 +0200 Subject: [PATCH 4/6] Add org.opencontainers.image.source annotation to the Docker image Signed-off-by: Thomas Citharel --- docker/production/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/production/Dockerfile b/docker/production/Dockerfile index 07136160c..4865986d7 100644 --- a/docker/production/Dockerfile +++ b/docker/production/Dockerfile @@ -42,6 +42,7 @@ LABEL org.opencontainers.image.title="mobilizon" \ org.opencontainers.image.vendor="joinmobilizon.org" \ org.opencontainers.image.documentation="https://docs.joinmobilizon.org" \ org.opencontainers.image.licenses="AGPL-3.0" \ + org.opencontainers.image.source="https://framagit.org/framasoft/mobilizon" \ org.opencontainers.image.url="https://joinmobilizon.org" \ org.opencontainers.image.revision=$VCS_REF \ org.opencontainers.image.created=$BUILD_DATE From 18279f964b17c9cf7256dfe94f9a4a2341f2dfc2 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 23 Apr 2021 19:12:52 +0200 Subject: [PATCH 5/6] Fix building Docker images on master Signed-off-by: Thomas Citharel --- .gitlab-ci.yml | 2 +- docker/production/Dockerfile | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a0dfb27c4..2b386e9a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -184,7 +184,7 @@ pages: - mkdir -p /kaniko/.docker - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$CI_REGISTRY_AUTH\",\"email\":\"$CI_REGISTRY_EMAIL\"}}}" > /kaniko/.docker/config.json script: - - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/docker/production/Dockerfile --destination $DOCKER_IMAGE_NAME --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP --build-arg CI_COMMIT_TAG=$CI_COMMIT_TAG + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/docker/production/Dockerfile --destination $DOCKER_IMAGE_NAME --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP build-docker-master: <<: *docker diff --git a/docker/production/Dockerfile b/docker/production/Dockerfile index 4865986d7..b6f752afb 100644 --- a/docker/production/Dockerfile +++ b/docker/production/Dockerfile @@ -34,8 +34,6 @@ FROM alpine ARG BUILD_DATE ARG VCS_REF -ARG CI_COMMIT_TAG -ARG MOBILIZON_VERSION=${CI_COMMIT_TAG} LABEL org.opencontainers.image.title="mobilizon" \ org.opencontainers.image.description="Mobilizon for Docker" \ @@ -58,7 +56,7 @@ EXPOSE 4000 ENV MOBILIZON_DOCKER=true COPY --from=builder --chown=nobody:nobody _build/prod/rel/mobilizon ./ -RUN cp /releases/${MOBILIZON_VERSION}/runtime.exs /etc/mobilizon/config.exs +RUN cp /releases/*/runtime.exs /etc/mobilizon/config.exs COPY docker/production/docker-entrypoint.sh ./ ENTRYPOINT ["./docker-entrypoint.sh"] From ed52474b5172c0d581ab72e77c11380f9dd0b41c Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 26 Apr 2021 09:21:00 +0200 Subject: [PATCH 6/6] Disable sentry logging unknown activities Signed-off-by: Thomas Citharel --- lib/federation/activity_pub/transmogrifier.ex | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/federation/activity_pub/transmogrifier.ex b/lib/federation/activity_pub/transmogrifier.ex index 3399e9b9b..bf79f5ac2 100644 --- a/lib/federation/activity_pub/transmogrifier.ex +++ b/lib/federation/activity_pub/transmogrifier.ex @@ -774,10 +774,6 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do Logger.info("Handing something with type #{object["type"]} not supported") Logger.debug(inspect(object)) - Sentry.capture_message("Handing something with type #{object["type"]} not supported", - extra: %{object: object} - ) - {:error, :not_supported} end