Merge branch 'fix-sentry-issues' into 'master'

Handle actor fetch issues better

See merge request framasoft/mobilizon!907
This commit is contained in:
Thomas Citharel 2021-04-26 07:59:20 +00:00
commit 7f0256d845
6 changed files with 20 additions and 12 deletions

View File

@ -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

View File

@ -34,14 +34,13 @@ 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" \
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
@ -57,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"]

View File

@ -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}

View File

@ -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

View File

@ -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

View File

@ -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")