Spec fixes

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-10-05 16:04:50 +02:00
parent f4284e1d3a
commit 98449b9cfd
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
4 changed files with 19 additions and 9 deletions

View File

@ -44,12 +44,12 @@ defmodule Mobilizon.CLI do
end
end
@spec migrate(String.t()) :: any()
@spec migrate(any()) :: any()
defp migrate(args) do
Migrate.run(args)
end
@spec rollback(String.t()) :: any()
@spec rollback(any()) :: any()
defp rollback(args) do
Rollback.run(args)
end

View File

@ -28,12 +28,12 @@ defmodule Mobilizon.Service.HTTP.ActivityPub do
Tesla.client(middleware, {adapter, opts})
end
@spec get(Tesla.Client.t(), String.t()) :: Tesla.Env.t()
@spec get(Tesla.Client.t(), String.t()) :: Tesla.Env.result()
def get(client, url) do
Tesla.get(client, url)
end
@spec post(Tesla.Client.t(), String.t(), map() | String.t()) :: Tesla.Env.t()
@spec post(Tesla.Client.t(), String.t(), map() | String.t()) :: Tesla.Env.result()
def post(client, url, data) do
Tesla.post(client, url, data)
end

View File

@ -25,19 +25,29 @@ defmodule Mobilizon.Service.RichMedia.Parsers.TwitterCard do
Logger.debug("Using Twitter card parser")
with {:ok, data} <- parse_name_attrs(data, html),
{:ok, data} <- parse_property_attrs(data, html),
data <- transform_tags(data) do
{:ok, data} <- parse_property_attrs(data, html) do
data = transform_tags(data)
Logger.debug("Data found with Twitter card parser")
Logger.debug(inspect(data))
data
end
end
@spec parse_name_attrs(map(), String.t()) :: {:ok, map()} | {:error, String.t()}
defp parse_name_attrs(data, html) do
MetaTagsParser.parse(html, data, "twitter", %{}, :name, :content, [:"twitter:card"])
MetaTagsParser.parse(
html,
data,
"twitter",
"No twitter card metadata found",
:name,
:content,
[:"twitter:card"]
)
end
defp parse_property_attrs({_, data}, html) do
@spec parse_property_attrs(map(), String.t()) :: {:ok, map()} | {:error, String.t()}
defp parse_property_attrs(data, html) do
MetaTagsParser.parse(
html,
data,
@ -49,6 +59,7 @@ defmodule Mobilizon.Service.RichMedia.Parsers.TwitterCard do
)
end
@spec transform_tags(map()) :: map()
defp transform_tags(data) do
data
|> Enum.reject(fn {_, v} -> is_nil(v) end)

View File

@ -30,7 +30,6 @@ defmodule Mobilizon.Web.FeedController do
return_data(conn, "ics", "event_" <> uuid, "event")
end
@spec instance(Plug.Conn.t(), map()) :: Plug.Conn.t()
def event(_conn, _) do
{:error, :not_found}
end