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

View file

@ -303,18 +303,14 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
case role do
:moderator ->
Logger.debug(
"Checking if activity actor #{actor_url} is a moderator from group from #{
object.url
}"
"Checking if activity actor #{actor_url} is a moderator from group from #{object.url}"
)
Actors.is_moderator?(actor_id, group_id)
:administrator ->
Logger.debug(
"Checking if activity actor #{actor_url} is an administrator from group from #{
object.url
}"
"Checking if activity actor #{actor_url} is an administrator from group from #{object.url}"
)
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()
defp get_parent_id(context, resources_url) do
Logger.debug(
"Getting parentID for context #{inspect(context)} and with resources_url #{
inspect(resources_url)
}"
"Getting parentID for context #{inspect(context)} and with resources_url #{inspect(resources_url)}"
)
case Utils.get_url(context) do

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -36,9 +36,7 @@ defmodule Mobilizon.Storage.Repo.Migrations.RenamePostgresTypes do
with %Postgrex.Result{columns: ["exists"], rows: [[true]]} <-
Ecto.Adapters.SQL.query!(
Mobilizon.Storage.Repo,
"select exists (select 1 from pg_type where typname = '#{
old_type_name |> remove_schema
}' and typnamespace = (select oid from pg_namespace where nspname = 'public'))"
"select exists (select 1 from pg_type where typname = '#{old_type_name |> remove_schema}' and typnamespace = (select oid from pg_namespace where nspname = 'public'))"
) do
Ecto.Migration.execute(
"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
Ecto.Adapters.SQL.query!(
Mobilizon.Storage.Repo,
"UPDATE members SET member_since = '#{DateTime.to_iso8601(DateTime.utc_now())}' WHERE id = '#{
Ecto.UUID.cast!(id)
}'"
"UPDATE members SET member_since = '#{DateTime.to_iso8601(DateTime.utc_now())}' WHERE id = '#{Ecto.UUID.cast!(id)}'"
)
end
end)

View file

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

View file

@ -130,11 +130,7 @@ defmodule Mobilizon.Service.FormatterTest do
assert length(mentions) == 3
expected_text =
"<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>"
"<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>"
assert expected_text == text
end

View file

@ -10,15 +10,7 @@ defmodule Mobilizon.Service.Metadata.InstanceTest do
description = Utils.process_description(Config.instance_description())
assert Instance.build_tags() |> Utils.stringify_tags() ==
"<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>#{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"
end
end
end

View file

@ -14,36 +14,16 @@ defmodule Mobilizon.Service.MetadataTest do
test "that is a group gives tags" do
%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() ==
"<meta content=\"#{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\">"
"<meta content="
# {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
|> Map.put(:avatar, nil)
|> Metadata.build_tags()
|> Metadata.Utils.stringify_tags() ==
"<meta content=\"#{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\">"
"<meta content="
end
test "that is not a group doesn't give anything" do
@ -67,45 +47,17 @@ defmodule Mobilizon.Service.MetadataTest do
assert event
|> Metadata.build_tags()
|> Metadata.Utils.stringify_tags() ==
"<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>"
"""
<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>
"""
assert event
|> Map.put(:picture, nil)
|> Metadata.build_tags()
|> Metadata.Utils.stringify_tags() ==
"<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>"
"""
<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>
"""
end
end
@ -116,15 +68,9 @@ defmodule Mobilizon.Service.MetadataTest do
assert post
|> Metadata.build_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)
}\" 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>"
"""
<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>
"""
end
end
@ -135,9 +81,9 @@ defmodule Mobilizon.Service.MetadataTest do
assert comment
|> Metadata.build_tags()
|> Metadata.Utils.stringify_tags() ==
"<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\">"
"""
<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">
"""
end
end

View file

@ -82,11 +82,7 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do
actor2 = insert(:actor, user: user)
output =
"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"
"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"
Show.run([@email])
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 output_received ==
"An user has been modified with the following information:\n - email: #{
user.email
}\n - Role: #{user.role}\n - account status: disabled\n"
"An user has been modified with the following information:\n - email: #{user.email}\n - Role: #{user.role}\n - account status: disabled\n"
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 output_received ==
"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"
"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"
refute is_nil(confirmed_at)
@ -183,9 +175,7 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do
Users.get_user_by_email(@modified_email)
assert output_received ==
"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"
"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"
end
end
end

View file

@ -23,9 +23,7 @@ defmodule Mobilizon.Web.WebFingerControllerTest do
conn = get(conn, "/.well-known/host-meta")
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=\"#{
Endpoint.url()
}/.well-known/webfinger?resource={uri}\" type=\"application/jrd+json\" /></XRD>"
"<?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>"
assert {"content-type", "application/xrd+xml; charset=utf-8"} in conn.resp_headers
end