Run mix format on Elixir 12

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-06-07 16:39:44 +02:00
parent 95913ba28b
commit a336e76aae
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
20 changed files with 52 additions and 180 deletions

View file

@ -317,9 +317,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
e -> e ->
Logger.warn( Logger.warn(
"Unable to process Accept activity #{inspect(id)} for object #{inspect(accepted_object)} only returned #{ "Unable to process Accept activity #{inspect(id)} for object #{inspect(accepted_object)} only returned #{inspect(e)}"
inspect(e)
}"
) )
:error :error
@ -347,9 +345,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
e -> e ->
Logger.warn( Logger.warn(
"Unable to process Reject activity #{inspect(id)} for object #{inspect(rejected_object)} only returned #{ "Unable to process Reject activity #{inspect(id)} for object #{inspect(rejected_object)} only returned #{inspect(e)}"
inspect(e)
}"
) )
:error :error
@ -734,9 +730,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
else else
{:is_admin, {:ok, %Member{}}} -> {:is_admin, {:ok, %Member{}}} ->
Logger.warn( Logger.warn(
"Person #{inspect(actor)} is not an admin from #{inspect(origin)} and can't remove member #{ "Person #{inspect(actor)} is not an admin from #{inspect(origin)} and can't remove member #{inspect(object)}"
inspect(object)
}"
) )
{:error, "Member already removed"} {:error, "Member already removed"}

View file

@ -303,18 +303,14 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
case role do case role do
:moderator -> :moderator ->
Logger.debug( Logger.debug(
"Checking if activity actor #{actor_url} is a moderator from group from #{ "Checking if activity actor #{actor_url} is a moderator from group from #{object.url}"
object.url
}"
) )
Actors.is_moderator?(actor_id, group_id) Actors.is_moderator?(actor_id, group_id)
:administrator -> :administrator ->
Logger.debug( Logger.debug(
"Checking if activity actor #{actor_url} is an administrator from group from #{ "Checking if activity actor #{actor_url} is an administrator from group from #{object.url}"
object.url
}"
) )
Actors.is_administrator?(actor_id, group_id) Actors.is_administrator?(actor_id, group_id)

View file

@ -104,9 +104,7 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Resource do
@spec get_parent_id(String.t(), String.t()) :: Resource.t() | map() @spec get_parent_id(String.t(), String.t()) :: Resource.t() | map()
defp get_parent_id(context, resources_url) do defp get_parent_id(context, resources_url) do
Logger.debug( Logger.debug(
"Getting parentID for context #{inspect(context)} and with resources_url #{ "Getting parentID for context #{inspect(context)} and with resources_url #{inspect(resources_url)}"
inspect(resources_url)
}"
) )
case Utils.get_url(context) do case Utils.get_url(context) do

View file

@ -170,9 +170,7 @@ defmodule Mix.Tasks.Mobilizon.Instance do
""" """
To get started: To get started:
1. Check the contents of the generated files. 1. Check the contents of the generated files.
2. Run `sudo -u postgres psql -f #{escape_sh_path(psql_path)} && rm #{ 2. Run `sudo -u postgres psql -f #{escape_sh_path(psql_path)} && rm #{escape_sh_path(psql_path)}`.
escape_sh_path(psql_path)
}`.
""" """
) )
else else

View file

@ -66,9 +66,7 @@ defmodule Mix.Tasks.Mobilizon.Users.Clean do
Enum.each(deleted_users, fn deleted_user -> Enum.each(deleted_users, fn deleted_user ->
shell_info( shell_info(
"ID: #{deleted_user.id}, Email: #{deleted_user.email}, Profile: @#{ "ID: #{deleted_user.id}, Email: #{deleted_user.email}, Profile: @#{hd(deleted_user.actors).preferred_username}"
hd(deleted_user.actors).preferred_username
}"
) )
end) end)
end end

View file

@ -58,11 +58,9 @@ defmodule Mix.Tasks.Mobilizon.Users.Modify do
An user has been modified with the following information: An user has been modified with the following information:
- email: #{user.email} - email: #{user.email}
- Role: #{user.role} - Role: #{user.role}
- account status: #{ - account status: #{if user.confirmed_at,
if user.confirmed_at,
do: "activated on #{DateTime.to_string(user.confirmed_at)} (UTC)", do: "activated on #{DateTime.to_string(user.confirmed_at)} (UTC)",
else: "disabled" else: "disabled"}
}
""") """)
else else
{:makes_changes, false} -> {:makes_changes, false} ->

View file

@ -19,11 +19,9 @@ defmodule Mix.Tasks.Mobilizon.Users.Show do
actors <- Users.get_actors_for_user(user) do actors <- Users.get_actors_for_user(user) do
shell_info(""" shell_info("""
Informations for the user #{user.email}: Informations for the user #{user.email}:
- account status: #{ - account status: #{if user.confirmed_at,
if user.confirmed_at,
do: "Activated on #{DateTime.to_string(user.confirmed_at)} (UTC)", do: "Activated on #{DateTime.to_string(user.confirmed_at)} (UTC)",
else: "disabled" else: "disabled"}
}
- Role: #{user.role} - Role: #{user.role}
#{display_actors(actors)} #{display_actors(actors)}
""") """)

View file

@ -1254,9 +1254,7 @@ defmodule Mobilizon.Actors do
# Check if followed has blocked follower # Check if followed has blocked follower
{:already_following, nil} <- {:already_following, is_following(follower, followed)} do {:already_following, nil} <- {:already_following, is_following(follower, followed)} do
Logger.info( Logger.info(
"Making #{Actor.preferred_username_and_domain(follower)} follow #{ "Making #{Actor.preferred_username_and_domain(follower)} follow #{Actor.preferred_username_and_domain(followed)} " <>
Actor.preferred_username_and_domain(followed)
} " <>
"(approved: #{approved})" "(approved: #{approved})"
) )
@ -1269,9 +1267,7 @@ defmodule Mobilizon.Actors do
else else
{:already_following, %Follower{}} -> {:already_following, %Follower{}} ->
{:error, :already_following, {:error, :already_following,
"Could not follow actor: you are already following #{ "Could not follow actor: you are already following #{Actor.preferred_username_and_domain(followed)}"}
Actor.preferred_username_and_domain(followed)
}"}
{:suspended, _} -> {:suspended, _} ->
{:error, :suspended, {:error, :suspended,

View file

@ -85,9 +85,7 @@ defmodule Mobilizon.Addresses.Address do
def representation(%__MODULE__{} = address) do def representation(%__MODULE__{} = address) do
String.trim( String.trim(
"#{address.street} #{address.postal_code} #{address.locality} #{address.region} #{ "#{address.street} #{address.postal_code} #{address.locality} #{address.region} #{address.country}"
address.country
}"
) )
end end
end end

View file

@ -35,9 +35,7 @@ defmodule Mobilizon.Service.Geospatial.MapQuest do
with {:ok, %{status: 200, body: body}} <- with {:ok, %{status: 200, body: body}} <-
GeospatialClient.get( GeospatialClient.get(
"https://#{prefix}.mapquestapi.com/geocoding/v1/reverse?key=#{api_key}&location=#{ "https://#{prefix}.mapquestapi.com/geocoding/v1/reverse?key=#{api_key}&location=#{lat},#{lon}&maxResults=#{limit}"
lat
},#{lon}&maxResults=#{limit}"
), ),
%{"results" => results, "info" => %{"statuscode" => 0}} <- body do %{"results" => results, "info" => %{"statuscode" => 0}} <- body do
results |> Enum.map(&process_data/1) results |> Enum.map(&process_data/1)
@ -63,9 +61,7 @@ defmodule Mobilizon.Service.Geospatial.MapQuest do
if is_nil(api_key), do: raise(ArgumentError, message: @api_key_missing_message) if is_nil(api_key), do: raise(ArgumentError, message: @api_key_missing_message)
url = url =
"https://#{prefix}.mapquestapi.com/geocoding/v1/address?key=#{api_key}&location=#{ "https://#{prefix}.mapquestapi.com/geocoding/v1/address?key=#{api_key}&location=#{URI.encode(q)}&maxResults=#{limit}"
URI.encode(q)
}&maxResults=#{limit}"
Logger.debug("Asking MapQuest for addresses with #{url}") Logger.debug("Asking MapQuest for addresses with #{url}")

View file

@ -42,14 +42,10 @@ defmodule Mobilizon.Service.Geospatial.Nominatim do
url = url =
case method do case method do
:search -> :search ->
"#{endpoint}/search?format=geocodejson&q=#{URI.encode(args.q)}&limit=#{limit}&accept-language=#{ "#{endpoint}/search?format=geocodejson&q=#{URI.encode(args.q)}&limit=#{limit}&accept-language=#{lang}&addressdetails=1&namedetails=1"
lang
}&addressdetails=1&namedetails=1"
:geocode -> :geocode ->
"#{endpoint}/reverse?format=geocodejson&lat=#{args.lat}&lon=#{args.lon}&accept-language=#{ "#{endpoint}/reverse?format=geocodejson&lat=#{args.lat}&lon=#{args.lon}&accept-language=#{lang}&addressdetails=1&namedetails=1"
lang
}&addressdetails=1&namedetails=1"
|> add_parameter(options, :zoom) |> add_parameter(options, :zoom)
end end

View file

@ -93,9 +93,7 @@ defmodule Mobilizon.Service.Notifications.Scheduler do
%DateTime{} = begins_on_shifted = shift_zone(begins_on, timezone) %DateTime{} = begins_on_shifted = shift_zone(begins_on, timezone)
Logger.debug( Logger.debug(
"Participation event start at #{inspect(begins_on_shifted)} (user timezone is #{ "Participation event start at #{inspect(begins_on_shifted)} (user timezone is #{timezone})"
timezone
})"
) )
notification_date = notification_date =

View file

@ -36,9 +36,7 @@ defmodule Mobilizon.Storage.Repo.Migrations.RenamePostgresTypes do
with %Postgrex.Result{columns: ["exists"], rows: [[true]]} <- with %Postgrex.Result{columns: ["exists"], rows: [[true]]} <-
Ecto.Adapters.SQL.query!( Ecto.Adapters.SQL.query!(
Mobilizon.Storage.Repo, Mobilizon.Storage.Repo,
"select exists (select 1 from pg_type where typname = '#{ "select exists (select 1 from pg_type where typname = '#{old_type_name |> remove_schema}' and typnamespace = (select oid from pg_namespace where nspname = 'public'))"
old_type_name |> remove_schema
}' and typnamespace = (select oid from pg_namespace where nspname = 'public'))"
) do ) do
Ecto.Migration.execute( Ecto.Migration.execute(
"ALTER TYPE #{old_type_name |> remove_schema} RENAME TO #{new_type_name |> remove_schema}" "ALTER TYPE #{old_type_name |> remove_schema} RENAME TO #{new_type_name |> remove_schema}"

View file

@ -18,9 +18,7 @@ defmodule Mobilizon.Storage.Repo.Migrations.AddMemberSinceToMembers do
if role in ["member", "moderator", "administrator", "creator"] do if role in ["member", "moderator", "administrator", "creator"] do
Ecto.Adapters.SQL.query!( Ecto.Adapters.SQL.query!(
Mobilizon.Storage.Repo, Mobilizon.Storage.Repo,
"UPDATE members SET member_since = '#{DateTime.to_iso8601(DateTime.utc_now())}' WHERE id = '#{ "UPDATE members SET member_since = '#{DateTime.to_iso8601(DateTime.utc_now())}' WHERE id = '#{Ecto.UUID.cast!(id)}'"
Ecto.UUID.cast!(id)
}'"
) )
end end
end) end)

View file

@ -384,9 +384,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
createEvent( createEvent(
title: "my event is referenced", title: "my event is referenced",
description: "with tags!", description: "with tags!",
begins_on: "#{ begins_on: "#{DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()}",
DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()
}",
organizer_actor_id: "#{actor.id}", organizer_actor_id: "#{actor.id}",
category: "birthday", category: "birthday",
tags: ["nicolas", "birthday", "bad tag"] tags: ["nicolas", "birthday", "bad tag"]
@ -428,9 +426,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
createEvent( createEvent(
title: "my event is referenced", title: "my event is referenced",
description: "with tags!", description: "with tags!",
begins_on: "#{ begins_on: "#{DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()}",
DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()
}",
organizer_actor_id: "#{actor.id}", organizer_actor_id: "#{actor.id}",
category: "birthday", category: "birthday",
physical_address: { physical_address: {
@ -470,9 +466,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
createEvent( createEvent(
title: "my event is referenced", title: "my event is referenced",
description: "with tags!", description: "with tags!",
begins_on: "#{ begins_on: "#{DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()}",
DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()
}",
organizer_actor_id: "#{actor.id}", organizer_actor_id: "#{actor.id}",
category: "birthday", category: "birthday",
physical_address: { physical_address: {
@ -520,9 +514,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
createEvent( createEvent(
title: "come to my event", title: "come to my event",
description: "it will be fine", description: "it will be fine",
begins_on: "#{ begins_on: "#{DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()}",
DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()
}",
organizer_actor_id: "#{actor.id}", organizer_actor_id: "#{actor.id}",
category: "birthday", category: "birthday",
picture: { picture: {
@ -609,9 +601,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
createEvent( createEvent(
title: "come to my event", title: "come to my event",
description: "it will be fine", description: "it will be fine",
begins_on: "#{ begins_on: "#{DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()}",
DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()
}",
organizer_actor_id: "#{actor.id}", organizer_actor_id: "#{actor.id}",
category: "birthday", category: "birthday",
picture: { picture: {

View file

@ -130,11 +130,7 @@ defmodule Mobilizon.Service.FormatterTest do
assert length(mentions) == 3 assert length(mentions) == 3
expected_text = expected_text =
"<span class=\"h-card mention\" data-user=\"#{gsimg.id}\">@<span>gsimg</span></span> According to <span class=\"h-card mention\" data-user=\"#{ "<span class=\"h-card mention\" data-user=\"#{gsimg.id}\">@<span>gsimg</span></span> According to <span class=\"h-card mention\" data-user=\"#{archaeme.id}\">@<span>archa_eme_</span></span>, that is @daggsy. Also hello <span class=\"h-card mention\" data-user=\"#{archaeme_remote.id}\">@<span>archaeme</span></span>"
archaeme.id
}\">@<span>archa_eme_</span></span>, that is @daggsy. Also hello <span class=\"h-card mention\" data-user=\"#{
archaeme_remote.id
}\">@<span>archaeme</span></span>"
assert expected_text == text assert expected_text == text
end end

View file

@ -10,15 +10,7 @@ defmodule Mobilizon.Service.Metadata.InstanceTest do
description = Utils.process_description(Config.instance_description()) description = Utils.process_description(Config.instance_description())
assert Instance.build_tags() |> Utils.stringify_tags() == assert Instance.build_tags() |> Utils.stringify_tags() ==
"<title>#{title}</title><meta content=\"#{description}\" name=\"description\"><meta content=\"#{ "<title>#{title}</title><meta content=\"#{description}\" name=\"description\"><meta content=\"#{title}\" property=\"og:title\"><meta content=\"#{Endpoint.url()}\" property=\"og:url\"><meta content=\"#{description}\" property=\"og:description\"><meta content=\"website\" property=\"og:type\"><script type=\"application/ld+json\">{\n\"@context\": \"http://schema.org\",\n\"@type\": \"WebSite\",\n\"name\": \"#{title}\",\n\"url\": \"#{Endpoint.url()}\",\n\"potentialAction\": {\n\"@type\": \"SearchAction\",\n\"target\": \"#{Endpoint.url()}/search?term={search_term}\",\n\"query-input\": \"required name=search_term\"\n}\n}</script>\n"
title
}\" property=\"og:title\"><meta content=\"#{Endpoint.url()}\" property=\"og:url\"><meta content=\"#{
description
}\" property=\"og:description\"><meta content=\"website\" property=\"og:type\"><script type=\"application/ld+json\">{\n\"@context\": \"http://schema.org\",\n\"@type\": \"WebSite\",\n\"name\": \"#{
title
}\",\n\"url\": \"#{Endpoint.url()}\",\n\"potentialAction\": {\n\"@type\": \"SearchAction\",\n\"target\": \"#{
Endpoint.url()
}/search?term={search_term}\",\n\"query-input\": \"required name=search_term\"\n}\n}</script>\n"
end end
end end
end end

View file

@ -14,36 +14,16 @@ defmodule Mobilizon.Service.MetadataTest do
test "that is a group gives tags" do test "that is a group gives tags" do
%Actor{} = group = insert(:group, name: "My group") %Actor{} = group = insert(:group, name: "My group")
# {group.name} (@#{group.preferred_username})" property="og:title"><meta content="#{group.url}" property="og:url"><meta content="The event organizer didn&#39;t add any description." property="og:description"><meta content="profile" property="og:type"><meta content="#{group.preferred_username}" property="profile:username"><meta content="summary" property="twitter:card"><meta content="#{group.avatar.url}" property="og:image"><script type="application/ld+json">{"@context":"http://schema.org","@type":"Organization","address":null,"name":"#{group.name}","url":"#{group.url}"}</script><link href="#{Routes.feed_url(Endpoint, :actor, group.preferred_username, "atom")}" rel="alternate" title="#{group.name}'s feed" type="application/atom+xml"><link href="#{Routes.feed_url(Endpoint, :actor, group.preferred_username, "ics")}" rel="alternate" title="#{group.name}'s feed" type="text/calendar">"
assert group |> Metadata.build_tags() |> Metadata.Utils.stringify_tags() == assert group |> Metadata.build_tags() |> Metadata.Utils.stringify_tags() ==
"<meta content=\"#{group.name} (@#{group.preferred_username})\" property=\"og:title\"><meta content=\"#{ "<meta content="
group.url
}\" property=\"og:url\"><meta content=\"The event organizer didn&#39;t add any description.\" property=\"og:description\"><meta content=\"profile\" property=\"og:type\"><meta content=\"#{
group.preferred_username
}\" property=\"profile:username\"><meta content=\"summary\" property=\"twitter:card\"><meta content=\"#{
group.avatar.url
}\" property=\"og:image\"><script type=\"application/ld+json\">{\"@context\":\"http://schema.org\",\"@type\":\"Organization\",\"address\":null,\"name\":\"#{
group.name
}\",\"url\":\"#{group.url}\"}</script><link href=\"#{
Routes.feed_url(Endpoint, :actor, group.preferred_username, "atom")
}\" rel=\"alternate\" title=\"#{group.name}'s feed\" type=\"application/atom+xml\"><link href=\"#{
Routes.feed_url(Endpoint, :actor, group.preferred_username, "ics")
}\" rel=\"alternate\" title=\"#{group.name}'s feed\" type=\"text/calendar\">"
# {group.name} (@#{group.preferred_username})" property="og:title"><meta content="#{group.url}" property="og:url"><meta content="The event organizer didn&#39;t add any description." property="og:description"><meta content="profile" property="og:type"><meta content="#{group.preferred_username}" property="profile:username"><meta content="summary" property="twitter:card"><script type="application/ld+json">{"@context":"http://schema.org","@type":"Organization","address":null,"name":"#{group.name}","url":"#{group.url}"}</script><link href="#{Routes.feed_url(Endpoint, :actor, group.preferred_username, "atom")}" rel="alternate" title="#{group.name}'s feed" type="application/atom+xml"><link href="#{Routes.feed_url(Endpoint, :actor, group.preferred_username, "ics")}" rel="alternate" title="#{group.name}'s feed" type="text/calendar">"
assert group assert group
|> Map.put(:avatar, nil) |> Map.put(:avatar, nil)
|> Metadata.build_tags() |> Metadata.build_tags()
|> Metadata.Utils.stringify_tags() == |> Metadata.Utils.stringify_tags() ==
"<meta content=\"#{group.name} (@#{group.preferred_username})\" property=\"og:title\"><meta content=\"#{ "<meta content="
group.url
}\" property=\"og:url\"><meta content=\"The event organizer didn&#39;t add any description.\" property=\"og:description\"><meta content=\"profile\" property=\"og:type\"><meta content=\"#{
group.preferred_username
}\" property=\"profile:username\"><meta content=\"summary\" property=\"twitter:card\"><script type=\"application/ld+json\">{\"@context\":\"http://schema.org\",\"@type\":\"Organization\",\"address\":null,\"name\":\"#{
group.name
}\",\"url\":\"#{group.url}\"}</script><link href=\"#{
Routes.feed_url(Endpoint, :actor, group.preferred_username, "atom")
}\" rel=\"alternate\" title=\"#{group.name}'s feed\" type=\"application/atom+xml\"><link href=\"#{
Routes.feed_url(Endpoint, :actor, group.preferred_username, "ics")
}\" rel=\"alternate\" title=\"#{group.name}'s feed\" type=\"text/calendar\">"
end end
test "that is not a group doesn't give anything" do test "that is not a group doesn't give anything" do
@ -67,45 +47,17 @@ defmodule Mobilizon.Service.MetadataTest do
assert event assert event
|> Metadata.build_tags() |> Metadata.build_tags()
|> Metadata.Utils.stringify_tags() == |> Metadata.Utils.stringify_tags() ==
"<title>#{event.title} - Mobilizon</title><meta content=\"#{event.description}\" name=\"description\"><meta content=\"#{ """
event.title <title>#{event.title} - Mobilizon</title><meta content="#{event.description}" name="description"><meta content="#{event.title}" property="og:title"><meta content="#{event.url}" property="og:url"><meta content="#{event.description}" property="og:description"><meta content="website" property="og:type"><link href="#{event.url}" rel="canonical"><meta content="#{event.picture.file.url}" property="og:image"><meta content="summary_large_image" property="twitter:card"><script type="application/ld+json">{"@context":"https://schema.org","@type":"Event","description":"#{String.replace(event.description, a, b)}","endDate":"#{DateTime.to_iso8601(event.ends_on)}","eventStatus":"https://schema.org/EventScheduled","image":["#{event.picture.file.url}"],"location":{"@type":"Place","address":{"@type":"PostalAddress","addressCountry":"My Country","addressLocality":"My Locality","addressRegion":"My Region","postalCode":"My Postal Code","streetAddress":"My Street Address"},"name":"#{event.physical_address.description}"},"name":"#{event.title}","organizer":{"@type":"Person","name":"#{event.organizer_actor.preferred_username}"},"performer":{"@type":"Person","name":"#{event.organizer_actor.preferred_username}"},"startDate":"#{DateTime.to_iso8601(event.begins_on)}"}</script>
}\" property=\"og:title\"><meta content=\"#{event.url}\" property=\"og:url\"><meta content=\"#{ """
event.description
}\" property=\"og:description\"><meta content=\"website\" property=\"og:type\"><link href=\"#{
event.url
}\" rel=\"canonical\"><meta content=\"#{event.picture.file.url}\" property=\"og:image\"><meta content=\"summary_large_image\" property=\"twitter:card\"><script type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"Event\",\"description\":\"#{
String.replace(event.description, a, b)
}\",\"endDate\":\"#{DateTime.to_iso8601(event.ends_on)}\",\"eventStatus\":\"https://schema.org/EventScheduled\",\"image\":[\"#{
event.picture.file.url
}\"],\"location\":{\"@type\":\"Place\",\"address\":{\"@type\":\"PostalAddress\",\"addressCountry\":\"My Country\",\"addressLocality\":\"My Locality\",\"addressRegion\":\"My Region\",\"postalCode\":\"My Postal Code\",\"streetAddress\":\"My Street Address\"},\"name\":\"#{
event.physical_address.description
}\"},\"name\":\"#{event.title}\",\"organizer\":{\"@type\":\"Person\",\"name\":\"#{
event.organizer_actor.preferred_username
}\"},\"performer\":{\"@type\":\"Person\",\"name\":\"#{
event.organizer_actor.preferred_username
}\"},\"startDate\":\"#{DateTime.to_iso8601(event.begins_on)}\"}</script>"
assert event assert event
|> Map.put(:picture, nil) |> Map.put(:picture, nil)
|> Metadata.build_tags() |> Metadata.build_tags()
|> Metadata.Utils.stringify_tags() == |> Metadata.Utils.stringify_tags() ==
"<title>#{event.title} - Mobilizon</title><meta content=\"#{event.description}\" name=\"description\"><meta content=\"#{ """
event.title <title>#{event.title} - Mobilizon</title><meta content="#{event.description}" name="description"><meta content="#{event.title}" property="og:title"><meta content="#{event.url}" property="og:url"><meta content="#{event.description}" property="og:description"><meta content="website" property="og:type"><link href="#{event.url}" rel="canonical"><meta content="summary_large_image" property="twitter:card"><script type="application/ld+json">{"@context":"https://schema.org","@type":"Event","description":"#{String.replace(event.description, a, b)}","endDate":"#{DateTime.to_iso8601(event.ends_on)}","eventStatus":"https://schema.org/EventScheduled","image":["#{"#{Endpoint.url()}/img/mobilizon_default_card.png"}"],"location":{"@type":"Place","address":{"@type":"PostalAddress","addressCountry":"My Country","addressLocality":"My Locality","addressRegion":"My Region","postalCode":"My Postal Code","streetAddress":"My Street Address"},"name":"#{event.physical_address.description}"},"name":"#{event.title}","organizer":{"@type":"Person","name":"#{event.organizer_actor.preferred_username}"},"performer":{"@type":"Person","name":"#{event.organizer_actor.preferred_username}"},"startDate":"#{DateTime.to_iso8601(event.begins_on)}"}</script>
}\" property=\"og:title\"><meta content=\"#{event.url}\" property=\"og:url\"><meta content=\"#{ """
event.description
}\" property=\"og:description\"><meta content=\"website\" property=\"og:type\"><link href=\"#{
event.url
}\" rel=\"canonical\"><meta content=\"summary_large_image\" property=\"twitter:card\"><script type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"Event\",\"description\":\"#{
String.replace(event.description, a, b)
}\",\"endDate\":\"#{DateTime.to_iso8601(event.ends_on)}\",\"eventStatus\":\"https://schema.org/EventScheduled\",\"image\":[\"#{
"#{Endpoint.url()}/img/mobilizon_default_card.png"
}\"],\"location\":{\"@type\":\"Place\",\"address\":{\"@type\":\"PostalAddress\",\"addressCountry\":\"My Country\",\"addressLocality\":\"My Locality\",\"addressRegion\":\"My Region\",\"postalCode\":\"My Postal Code\",\"streetAddress\":\"My Street Address\"},\"name\":\"#{
event.physical_address.description
}\"},\"name\":\"#{event.title}\",\"organizer\":{\"@type\":\"Person\",\"name\":\"#{
event.organizer_actor.preferred_username
}\"},\"performer\":{\"@type\":\"Person\",\"name\":\"#{
event.organizer_actor.preferred_username
}\"},\"startDate\":\"#{DateTime.to_iso8601(event.begins_on)}\"}</script>"
end end
end end
@ -116,15 +68,9 @@ defmodule Mobilizon.Service.MetadataTest do
assert post assert post
|> Metadata.build_tags() |> Metadata.build_tags()
|> Metadata.Utils.stringify_tags() == |> Metadata.Utils.stringify_tags() ==
"<meta content=\"#{post.title}\" property=\"og:title\"><meta content=\"#{post.url}\" property=\"og:url\"><meta content=\"#{ """
Metadata.Utils.process_description(post.body) <meta content="#{post.title}" property="og:title"><meta content="#{post.url}" property="og:url"><meta content="#{Metadata.Utils.process_description(post.body)}" property="og:description"><meta content="article" property="og:type"><meta content="summary" property="twitter:card"><link href="#{post.url}" rel="canonical"><meta content="#{post.picture.file.url}" property="og:image"><meta content="summary_large_image" property="twitter:card"><script type="application/ld+json">{"@context":"https://schema.org","@type":"Article","author":{"@type":"Organization","name":"#{post.attributed_to.preferred_username}"},"dateModified":"#{DateTime.to_iso8601(post.updated_at)}","datePublished":"#{DateTime.to_iso8601(post.publish_at)}","name":"My Awesome article"}</script>
}\" property=\"og:description\"><meta content=\"article\" property=\"og:type\"><meta content=\"summary\" property=\"twitter:card\"><link href=\"#{ """
post.url
}\" rel=\"canonical\"><meta content=\"#{post.picture.file.url}\" property=\"og:image\"><meta content=\"summary_large_image\" property=\"twitter:card\"><script type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"Article\",\"author\":{\"@type\":\"Organization\",\"name\":\"#{
post.attributed_to.preferred_username
}\"},\"dateModified\":\"#{DateTime.to_iso8601(post.updated_at)}\",\"datePublished\":\"#{
DateTime.to_iso8601(post.publish_at)
}\",\"name\":\"My Awesome article\"}</script>"
end end
end end
@ -135,9 +81,9 @@ defmodule Mobilizon.Service.MetadataTest do
assert comment assert comment
|> Metadata.build_tags() |> Metadata.build_tags()
|> Metadata.Utils.stringify_tags() == |> Metadata.Utils.stringify_tags() ==
"<meta content=\"#{comment.actor.preferred_username}\" property=\"og:title\"><meta content=\"#{ """
comment.url <meta content="#{comment.actor.preferred_username}" property="og:title"><meta content="#{comment.url}" property="og:url"><meta content="#{comment.text}" property="og:description"><meta content="website" property="og:type"><meta content="summary" property="twitter:card">
}\" property=\"og:url\"><meta content=\"#{comment.text}\" property=\"og:description\"><meta content=\"website\" property=\"og:type\"><meta content=\"summary\" property=\"twitter:card\">" """
end end
end end

View file

@ -82,11 +82,7 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do
actor2 = insert(:actor, user: user) actor2 = insert(:actor, user: user)
output = output =
"Informations for the user #{@email}:\n - account status: Activated on #{confirmed_at} (UTC)\n - Role: #{ "Informations for the user #{@email}:\n - account status: Activated on #{confirmed_at} (UTC)\n - Role: #{role}\n Identities (2):\n - @#{actor1.preferred_username} / \n - @#{actor2.preferred_username} / \n\n\n"
role
}\n Identities (2):\n - @#{actor1.preferred_username} / \n - @#{
actor2.preferred_username
} / \n\n\n"
Show.run([@email]) Show.run([@email])
assert_received {:mix_shell, :info, [output_received]} assert_received {:mix_shell, :info, [output_received]}
@ -136,9 +132,7 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do
assert_received {:mix_shell, :info, [output_received]} assert_received {:mix_shell, :info, [output_received]}
assert output_received == assert output_received ==
"An user has been modified with the following information:\n - email: #{ "An user has been modified with the following information:\n - email: #{user.email}\n - Role: #{user.role}\n - account status: disabled\n"
user.email
}\n - Role: #{user.role}\n - account status: disabled\n"
assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email) assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email)
@ -150,9 +144,7 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do
assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email) assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email)
assert output_received == assert output_received ==
"An user has been modified with the following information:\n - email: #{ "An user has been modified with the following information:\n - email: #{user.email}\n - Role: #{user.role}\n - account status: activated on #{confirmed_at} (UTC)\n"
user.email
}\n - Role: #{user.role}\n - account status: activated on #{confirmed_at} (UTC)\n"
refute is_nil(confirmed_at) refute is_nil(confirmed_at)
@ -183,9 +175,7 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do
Users.get_user_by_email(@modified_email) Users.get_user_by_email(@modified_email)
assert output_received == assert output_received ==
"An user has been modified with the following information:\n - email: #{ "An user has been modified with the following information:\n - email: #{@modified_email}\n - Role: #{user.role}\n - account status: activated on #{confirmed_at} (UTC)\n"
@modified_email
}\n - Role: #{user.role}\n - account status: activated on #{confirmed_at} (UTC)\n"
end end
end end
end end

View file

@ -23,9 +23,7 @@ defmodule Mobilizon.Web.WebFingerControllerTest do
conn = get(conn, "/.well-known/host-meta") conn = get(conn, "/.well-known/host-meta")
assert response(conn, 200) == assert response(conn, 200) ==
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\" xmlns:hm=\"http://host-meta.net/ns/1.0\"><hm:Host>mobilizon.test</hm:Host><Link rel=\"lrdd\" template=\"#{ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\" xmlns:hm=\"http://host-meta.net/ns/1.0\"><hm:Host>mobilizon.test</hm:Host><Link rel=\"lrdd\" template=\"#{Endpoint.url()}/.well-known/webfinger?resource={uri}\" type=\"application/jrd+json\" /></XRD>"
Endpoint.url()
}/.well-known/webfinger?resource={uri}\" type=\"application/jrd+json\" /></XRD>"
assert {"content-type", "application/xrd+xml; charset=utf-8"} in conn.resp_headers assert {"content-type", "application/xrd+xml; charset=utf-8"} in conn.resp_headers
end end