Resources fixes and improvements

- Fix getting page description
- Fix fetching metadata from Twitter (thx @marienfressinaud)
- Improve error handling

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-03-24 10:45:29 +01:00
parent 50c89e21da
commit 7b9910f251
4 changed files with 56 additions and 16 deletions

View File

@@ -70,8 +70,14 @@ defmodule Mobilizon.Service.RichMedia.Parsers.MetaTagsParser do
defp maybe_put_description(meta, html) when meta != %{} do
case get_page_description(html) do
"" -> meta
description -> Map.put_new(meta, :description, description)
"" ->
meta
descriptions when is_list(descriptions) and length(descriptions) > 0 ->
Map.put_new(meta, :description, hd(descriptions))
description ->
Map.put_new(meta, :description, description)
end
end