From: William Pitcock Date: Mon, 28 Jan 2019 20:31:43 +0000 (+0000) Subject: rich media: parser: add some basic sanity checks on the returned data with pattern... X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=0f11254a065d014d8fbb4f4a48cb03d14d8e02d0;p=akkoma rich media: parser: add some basic sanity checks on the returned data with pattern matching --- diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex index 279e27273..76d977ac2 100644 --- a/lib/pleroma/web/rich_media/parser.ex +++ b/lib/pleroma/web/rich_media/parser.ex @@ -46,11 +46,11 @@ defmodule Pleroma.Web.RichMedia.Parser do end) end - defp get_parsed_data(data) when data == %{} do - {:error, "No metadata found"} + defp get_parsed_data(%{title: title} = data) when is_binary(title) and byte_size(title) > 0 do + {:ok, data} end defp get_parsed_data(data) do - {:ok, data} + {:error, "Found metadata was invalid or incomplete: #{inspect(data)}"} end end