Fix opengraph issue

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-06-26 14:42:40 +02:00
parent c3f73f4f87
commit b11674fc9e
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -34,8 +34,9 @@ defmodule Mobilizon.Service.RichMedia.Parsers.OGP do
|> Map.put(:height, get_integer_value(data, :"image:height")) |> Map.put(:height, get_integer_value(data, :"image:height"))
end end
@spec get_integer_value(Map.t(), atom()) :: integer() | nil
defp get_integer_value(data, key) do defp get_integer_value(data, key) do
with value <- Map.get(data, key), with value when not is_nil(value) <- Map.get(data, key),
{value, ""} <- Integer.parse(value) do {value, ""} <- Integer.parse(value) do
value value
else else