Spec fixes
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
f4284e1d3a
commit
98449b9cfd
|
@ -44,12 +44,12 @@ defmodule Mobilizon.CLI do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec migrate(String.t()) :: any()
|
@spec migrate(any()) :: any()
|
||||||
defp migrate(args) do
|
defp migrate(args) do
|
||||||
Migrate.run(args)
|
Migrate.run(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec rollback(String.t()) :: any()
|
@spec rollback(any()) :: any()
|
||||||
defp rollback(args) do
|
defp rollback(args) do
|
||||||
Rollback.run(args)
|
Rollback.run(args)
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,12 +28,12 @@ defmodule Mobilizon.Service.HTTP.ActivityPub do
|
||||||
Tesla.client(middleware, {adapter, opts})
|
Tesla.client(middleware, {adapter, opts})
|
||||||
end
|
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
|
def get(client, url) do
|
||||||
Tesla.get(client, url)
|
Tesla.get(client, url)
|
||||||
end
|
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
|
def post(client, url, data) do
|
||||||
Tesla.post(client, url, data)
|
Tesla.post(client, url, data)
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,19 +25,29 @@ defmodule Mobilizon.Service.RichMedia.Parsers.TwitterCard do
|
||||||
Logger.debug("Using Twitter card parser")
|
Logger.debug("Using Twitter card parser")
|
||||||
|
|
||||||
with {:ok, data} <- parse_name_attrs(data, html),
|
with {:ok, data} <- parse_name_attrs(data, html),
|
||||||
{:ok, data} <- parse_property_attrs(data, html),
|
{:ok, data} <- parse_property_attrs(data, html) do
|
||||||
data <- transform_tags(data) do
|
data = transform_tags(data)
|
||||||
Logger.debug("Data found with Twitter card parser")
|
Logger.debug("Data found with Twitter card parser")
|
||||||
Logger.debug(inspect(data))
|
Logger.debug(inspect(data))
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec parse_name_attrs(map(), String.t()) :: {:ok, map()} | {:error, String.t()}
|
||||||
defp parse_name_attrs(data, html) do
|
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
|
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(
|
MetaTagsParser.parse(
|
||||||
html,
|
html,
|
||||||
data,
|
data,
|
||||||
|
@ -49,6 +59,7 @@ defmodule Mobilizon.Service.RichMedia.Parsers.TwitterCard do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec transform_tags(map()) :: map()
|
||||||
defp transform_tags(data) do
|
defp transform_tags(data) do
|
||||||
data
|
data
|
||||||
|> Enum.reject(fn {_, v} -> is_nil(v) end)
|
|> Enum.reject(fn {_, v} -> is_nil(v) end)
|
||||||
|
|
|
@ -30,7 +30,6 @@ defmodule Mobilizon.Web.FeedController do
|
||||||
return_data(conn, "ics", "event_" <> uuid, "event")
|
return_data(conn, "ics", "event_" <> uuid, "event")
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec instance(Plug.Conn.t(), map()) :: Plug.Conn.t()
|
|
||||||
def event(_conn, _) do
|
def event(_conn, _) do
|
||||||
{:error, :not_found}
|
{:error, :not_found}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue