Fix usage of is_bitstring instead of is_binary

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-04-08 16:41:49 +02:00
parent b79c2815fc
commit bd53bfc46b
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
10 changed files with 19 additions and 13 deletions

View file

@ -127,7 +127,7 @@ defmodule Mobilizon.Federation.ActivityPub.Refresher do
do: process_collection(first, on_behalf_of)
defp process_collection(%{"type" => "OrderedCollection", "first" => first}, on_behalf_of)
when is_bitstring(first) do
when is_binary(first) do
Logger.debug("OrderedCollection has a first property pointing to an URI")
with {:ok, data} <- Fetcher.fetch(first, on_behalf_of: on_behalf_of) do

View file

@ -126,7 +126,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
end
end
defp fetch_object(object) when is_bitstring(object), do: {object, object}
defp fetch_object(object) when is_binary(object), do: {object, object}
@spec fetch_actor(String.t()) :: {:ok, String.t()} | {:error, String.t()}
# Dirty hack

View file

@ -26,7 +26,7 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
# Some implementations send the actor URI as the actor field, others send the entire actor object,
# so figure out what the actor's URI is based on what we have.
def get_url(%{"id" => id}), do: id
def get_url(id) when is_bitstring(id), do: id
def get_url(id) when is_binary(id), do: id
def get_url(ids) when is_list(ids), do: get_url(hd(ids))
def get_url(_), do: nil
@ -223,7 +223,7 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
end
end
def get_actor(%{"actor" => %{"id" => id}}) when is_bitstring(id) do
def get_actor(%{"actor" => %{"id" => id}}) when is_binary(id) do
id
end

View file

@ -155,7 +155,7 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Event do
end
@spec get_address(map | binary | nil) :: integer | nil
defp get_address(address_url) when is_bitstring(address_url) do
defp get_address(address_url) when is_binary(address_url) do
get_address(%{"id" => address_url})
end

View file

@ -38,7 +38,7 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Media do
%{"type" => "Document", "url" => media_url, "name" => name},
actor_id
)
when is_bitstring(media_url) do
when is_binary(media_url) do
with {:ok, %{body: body}} <- Tesla.get(media_url, opts: @http_options),
{:ok, %{name: name, url: url, content_type: content_type, size: size}} <-
Upload.store(%{body: body, name: name}),

View file

@ -94,7 +94,7 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Utils do
end
end
defp fetch_tag(tag) when is_bitstring(tag), do: [tag_without_hash(tag)]
defp fetch_tag(tag) when is_binary(tag), do: [tag_without_hash(tag)]
defp tag_without_hash("#" <> tag_title), do: tag_title
defp tag_without_hash(tag_title), do: tag_title

View file

@ -321,7 +321,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
{:ok, _activity, follow} ->
{:ok, follow}
{:error, {:error, err}} when is_bitstring(err) ->
{:error, {:error, err}} when is_binary(err) ->
{:error, err}
end
end
@ -336,7 +336,10 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
{:ok, _activity, follow} ->
{:ok, follow}
{:error, {:error, err}} when is_bitstring(err) ->
{:error, {:error, err}} when is_binary(err) ->
{:error, err}
{:error, err} when is_binary(err) ->
{:error, err}
end
end
@ -351,7 +354,10 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
{:ok, _activity, follow} ->
{:ok, follow}
{:error, {:error, err}} when is_bitstring(err) ->
{:error, {:error, err}} when is_binary(err) ->
{:error, err}
{:error, err} when is_binary(err) ->
{:error, err}
end
end

View file

@ -264,7 +264,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Participant do
@spec valid_email?(String.t() | nil) :: boolean
defp valid_email?(email) when is_nil(email), do: false
defp valid_email?(email) when is_bitstring(email) do
defp valid_email?(email) when is_binary(email) do
email
|> String.trim()
|> Checker.valid?()

View file

@ -78,7 +78,7 @@ defmodule Mobilizon.Admin do
defp stringify_struct(struct), do: struct
def get_admin_setting_value(group, name, fallback \\ nil)
when is_bitstring(group) and is_bitstring(name) do
when is_binary(group) and is_binary(name) do
case Repo.get_by(Setting, group: group, name: name) do
nil ->
fallback

View file

@ -74,7 +74,7 @@ defmodule Mobilizon.Service.Geospatial.Provider do
%Geo.Point{coordinates: {x, y}, srid: srid}
end
def coordinates([x, y], srid) when is_bitstring(x) and is_bitstring(y) do
def coordinates([x, y], srid) when is_binary(x) and is_binary(y) do
%Geo.Point{coordinates: {String.to_float(x), String.to_float(y)}, srid: srid}
end