From aed824f1aa1ad4acb132131726e8e26ca9ff00a3 Mon Sep 17 00:00:00 2001 From: miffigriffi Date: Sun, 22 Sep 2019 16:26:23 +0200 Subject: [PATCH] Fix code readability issues --- lib/mix/tasks/mobilizon/common.ex | 14 +++++-- lib/mix/tasks/mobilizon/create_bot.ex | 10 +++-- lib/mix/tasks/mobilizon/instance.ex | 12 +++--- lib/mix/tasks/mobilizon/relay.ex | 12 +++--- lib/mix/tasks/mobilizon/toot.ex | 3 +- lib/mobilizon/actors/actor.ex | 4 +- lib/mobilizon/events/comment.ex | 2 +- lib/mobilizon/events/event.ex | 2 +- lib/mobilizon/events/event_options.ex | 4 +- lib/mobilizon/events/tag.ex | 2 +- lib/mobilizon_web/api/comments.ex | 3 +- lib/mobilizon_web/api/events.ex | 6 ++- lib/mobilizon_web/api/follows.ex | 1 + lib/mobilizon_web/api/groups.ex | 6 ++- lib/mobilizon_web/api/participations.ex | 2 +- lib/mobilizon_web/api/reports.ex | 9 +++-- lib/mobilizon_web/api/utils.ex | 2 +- .../controllers/media_proxy_controller.ex | 2 +- lib/mobilizon_web/resolvers/admin.ex | 10 +++-- lib/mobilizon_web/resolvers/comment.ex | 5 ++- lib/mobilizon_web/resolvers/event.ex | 14 ++++--- lib/mobilizon_web/resolvers/feed_token.ex | 6 ++- lib/mobilizon_web/resolvers/group.ex | 5 ++- lib/mobilizon_web/resolvers/report.ex | 17 +++++---- lib/mobilizon_web/resolvers/user.ex | 8 ++-- lib/mobilizon_web/schema.ex | 7 ++-- lib/mobilizon_web/schema/actors/group.ex | 11 ++++-- lib/mobilizon_web/schema/admin.ex | 9 +++-- lib/mobilizon_web/schema/event.ex | 11 ++++-- lib/mobilizon_web/schema/events/feed_token.ex | 9 +++-- .../schema/events/participant.ex | 9 +++-- .../views/activity_pub/actor_view.ex | 3 +- .../views/json_ld/object_view.ex | 3 +- lib/mobilizon_web/views/page_view.ex | 2 +- lib/service/activity_pub/activity_pub.ex | 24 ++++-------- lib/service/activity_pub/converters/actor.ex | 4 +- .../activity_pub/converters/address.ex | 6 ++- .../activity_pub/converters/comment.ex | 9 +++-- lib/service/activity_pub/converters/event.ex | 28 +++++++------- lib/service/activity_pub/converters/flag.ex | 6 ++- .../activity_pub/converters/participant.ex | 6 ++- lib/service/activity_pub/relay.ex | 4 +- lib/service/activity_pub/transmogrifier.ex | 5 ++- lib/service/activity_pub/utils.ex | 12 ++---- lib/service/admin/action_log_service.ex | 6 +-- lib/service/email_checker.ex | 11 +++--- lib/service/export/feed.ex | 23 +++++------ lib/service/export/icalendar.ex | 8 ++-- lib/service/formatter/formatter.ex | 5 ++- lib/service/geospatial/addok.ex | 6 ++- lib/service/geospatial/geospatial.ex | 14 ++++--- lib/service/geospatial/google_maps.ex | 8 ++-- lib/service/geospatial/map_quest.ex | 4 +- lib/service/geospatial/nominatim.ex | 37 +++++++++--------- lib/service/geospatial/photon.ex | 6 ++- lib/service/geospatial/provider.ex | 38 ++++++++++--------- lib/service/users/activation.ex | 2 +- test/mobilizon/actors/actors_test.exs | 15 +------- test/mobilizon/events/events_test.exs | 18 +-------- .../activity_pub/activity_pub_test.exs | 10 +++-- .../activity_pub/converters/actor_test.exs | 3 +- .../activity_pub/transmogrifier_test.exs | 5 ++- .../service/activity_pub/utils_test.exs | 12 ++++-- .../service/admin/action_log_service_test.exs | 11 ++++-- .../service/geospatial/addok_test.exs | 15 ++++---- .../service/geospatial/google_maps_test.exs | 8 ++-- .../service/geospatial/map_quest_test.exs | 8 ++-- .../service/geospatial/nominatim_test.exs | 8 ++-- .../service/geospatial/photon_test.exs | 8 ++-- test/mobilizon_web/api/report_test.exs | 4 +- test/mobilizon_web/api/search_test.exs | 8 ++-- .../activity_pub_controller_test.exs | 12 ++++-- .../controllers/feed_controller_test.exs | 4 +- .../controllers/page_controller_test.exs | 5 ++- .../resolvers/admin_resolver_test.exs | 8 ++-- .../resolvers/report_resolver_test.exs | 8 ++-- .../resolvers/user_resolver_test.exs | 2 +- test/mobilizon_web/upload_test.exs | 2 +- test/support/factory.ex | 2 +- test/support/mocks/geospatial_mock.ex | 5 ++- test/tasks/relay_test.exs | 10 +++-- 81 files changed, 379 insertions(+), 309 deletions(-) diff --git a/lib/mix/tasks/mobilizon/common.ex b/lib/mix/tasks/mobilizon/common.ex index a511ddc7e..074b8d547 100644 --- a/lib/mix/tasks/mobilizon/common.ex +++ b/lib/mix/tasks/mobilizon/common.ex @@ -4,7 +4,9 @@ # Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/mix/tasks/pleroma/common.ex defmodule Mix.Tasks.Mobilizon.Common do - @moduledoc "Common functions to be reused in mix tasks" + @moduledoc """ + Common functions to be reused in mix tasks + """ def get_option(options, opt, prompt, defval \\ nil, defname \\ nil) do display = if defname || defval, do: "#{prompt} [#{defname || defval}]", else: "#{prompt}" @@ -13,17 +15,21 @@ defmodule Mix.Tasks.Mobilizon.Common do case Mix.shell().prompt(display) do "\n" -> case defval do - nil -> get_option(options, opt, prompt, defval) - defval -> defval + nil -> + get_option(options, opt, prompt, defval) + + defval -> + defval end opt -> - opt |> String.trim() + String.trim(opt) end end def start_mobilizon do Application.put_env(:phoenix, :serve_endpoints, false, persistent: true) + {:ok, _} = Application.ensure_all_started(:mobilizon) end diff --git a/lib/mix/tasks/mobilizon/create_bot.ex b/lib/mix/tasks/mobilizon/create_bot.ex index 13c321316..0f0f20357 100644 --- a/lib/mix/tasks/mobilizon/create_bot.ex +++ b/lib/mix/tasks/mobilizon/create_bot.ex @@ -1,13 +1,14 @@ defmodule Mix.Tasks.Mobilizon.CreateBot do @moduledoc """ - Creates a bot from a source + Creates a bot from a source. """ use Mix.Task - alias Mobilizon.Actors - alias Mobilizon.Users + + alias Mobilizon.{Actors, Users} alias Mobilizon.Actors.Bot alias Mobilizon.Users.User + require Logger @shortdoc "Register user" @@ -25,7 +26,8 @@ defmodule Mix.Tasks.Mobilizon.CreateBot do }) do bot else - e -> Logger.error(inspect(e)) + error -> + Logger.error(inspect(error)) end end end diff --git a/lib/mix/tasks/mobilizon/instance.ex b/lib/mix/tasks/mobilizon/instance.ex index 99c183882..451997f8c 100644 --- a/lib/mix/tasks/mobilizon/instance.ex +++ b/lib/mix/tasks/mobilizon/instance.ex @@ -4,11 +4,6 @@ # Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/mix/tasks/pleroma/instance.ex defmodule Mix.Tasks.Mobilizon.Instance do - use Mix.Task - alias Mix.Tasks.Mobilizon.Common - - @shortdoc "Generates a new config" - @preferred_cli_env "prod" @moduledoc """ Generates a new config @@ -31,6 +26,13 @@ defmodule Mix.Tasks.Mobilizon.Instance do - `--dbpass DBPASS` - the password to use for the database connection """ + use Mix.Task + + alias Mix.Tasks.Mobilizon.Common + + @preferred_cli_env "prod" + + @shortdoc "Generates a new config" def run(["gen" | options]) do {options, [], []} = OptionParser.parse( diff --git a/lib/mix/tasks/mobilizon/relay.ex b/lib/mix/tasks/mobilizon/relay.ex index e4db70f12..989c7ea92 100644 --- a/lib/mix/tasks/mobilizon/relay.ex +++ b/lib/mix/tasks/mobilizon/relay.ex @@ -4,11 +4,6 @@ # Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/mix/tasks/pleroma/relay.ex defmodule Mix.Tasks.Mobilizon.Relay do - use Mix.Task - alias Mobilizon.Service.ActivityPub.Relay - alias Mix.Tasks.Mobilizon.Common - - @shortdoc "Manages remote relays" @moduledoc """ Manages remote relays @@ -24,6 +19,13 @@ defmodule Mix.Tasks.Mobilizon.Relay do Example: ``mix mobilizon.relay unfollow https://example.org/relay`` """ + + use Mix.Task + + alias Mix.Tasks.Mobilizon.Common + alias Mobilizon.Service.ActivityPub.Relay + + @shortdoc "Manages remote relays" def run(["follow", target]) do Common.start_mobilizon() diff --git a/lib/mix/tasks/mobilizon/toot.ex b/lib/mix/tasks/mobilizon/toot.ex index 3f9371eb0..f93519d95 100644 --- a/lib/mix/tasks/mobilizon/toot.ex +++ b/lib/mix/tasks/mobilizon/toot.ex @@ -1,9 +1,10 @@ defmodule Mix.Tasks.Mobilizon.Toot do @moduledoc """ - Creates a bot from a source + Creates a bot from a source. """ use Mix.Task + require Logger @shortdoc "Toot to an user" diff --git a/lib/mobilizon/actors/actor.ex b/lib/mobilizon/actors/actor.ex index 610c68a73..939287766 100644 --- a/lib/mobilizon/actors/actor.ex +++ b/lib/mobilizon/actors/actor.ex @@ -11,11 +11,11 @@ defmodule Mobilizon.Actors.Actor do alias Mobilizon.Actors.{ActorOpenness, ActorType, ActorVisibility, Follower, Member} alias Mobilizon.Events.{Event, FeedToken} alias Mobilizon.Media.File - alias Mobilizon.Reports.{Report, Note} + alias Mobilizon.Reports.{Note, Report} alias Mobilizon.Users.User - alias MobilizonWeb.Router.Helpers, as: Routes alias MobilizonWeb.Endpoint + alias MobilizonWeb.Router.Helpers, as: Routes require Logger diff --git a/lib/mobilizon/events/comment.ex b/lib/mobilizon/events/comment.ex index a9c9b7869..a168ffb44 100644 --- a/lib/mobilizon/events/comment.ex +++ b/lib/mobilizon/events/comment.ex @@ -10,8 +10,8 @@ defmodule Mobilizon.Events.Comment do alias Mobilizon.Actors.Actor alias Mobilizon.Events.{Comment, CommentVisibility, Event} - alias MobilizonWeb.Router.Helpers, as: Routes alias MobilizonWeb.Endpoint + alias MobilizonWeb.Router.Helpers, as: Routes @type t :: %__MODULE__{ text: String.t(), diff --git a/lib/mobilizon/events/event.ex b/lib/mobilizon/events/event.ex index 75233a7df..8a33cf090 100644 --- a/lib/mobilizon/events/event.ex +++ b/lib/mobilizon/events/event.ex @@ -16,8 +16,8 @@ defmodule Mobilizon.Events.Event do EventVisibility, JoinOptions, Participant, - Tag, Session, + Tag, Track } diff --git a/lib/mobilizon/events/event_options.ex b/lib/mobilizon/events/event_options.ex index e4d5f03c7..e68a026ff 100644 --- a/lib/mobilizon/events/event_options.ex +++ b/lib/mobilizon/events/event_options.ex @@ -8,9 +8,9 @@ defmodule Mobilizon.Events.EventOptions do import Ecto.Changeset alias Mobilizon.Events.{ + CommentModeration, EventOffer, - EventParticipationCondition, - CommentModeration + EventParticipationCondition } @type t :: %__MODULE__{ diff --git a/lib/mobilizon/events/tag.ex b/lib/mobilizon/events/tag.ex index b1d0ec8d7..8ea6981f0 100644 --- a/lib/mobilizon/events/tag.ex +++ b/lib/mobilizon/events/tag.ex @@ -7,8 +7,8 @@ defmodule Mobilizon.Events.Tag do import Ecto.Changeset - alias Mobilizon.Events.TagRelation alias Mobilizon.Events.Tag.TitleSlug + alias Mobilizon.Events.TagRelation @type t :: %__MODULE__{ title: String.t(), diff --git a/lib/mobilizon_web/api/comments.ex b/lib/mobilizon_web/api/comments.ex index fbef71418..92f186b79 100644 --- a/lib/mobilizon_web/api/comments.ex +++ b/lib/mobilizon_web/api/comments.ex @@ -1,6 +1,6 @@ defmodule MobilizonWeb.API.Comments do @moduledoc """ - API for Comments + API for Comments. """ alias Mobilizon.Actors @@ -8,6 +8,7 @@ defmodule MobilizonWeb.API.Comments do alias Mobilizon.Events.Comment alias Mobilizon.Service.ActivityPub alias Mobilizon.Service.ActivityPub.Utils, as: ActivityPubUtils + alias MobilizonWeb.API.Utils @doc """ diff --git a/lib/mobilizon_web/api/events.ex b/lib/mobilizon_web/api/events.ex index 6a0c726ca..6e1c93b8c 100644 --- a/lib/mobilizon_web/api/events.ex +++ b/lib/mobilizon_web/api/events.ex @@ -1,12 +1,14 @@ defmodule MobilizonWeb.API.Events do @moduledoc """ - API for Events + API for Events. """ + alias Mobilizon.Events.Event alias Mobilizon.Actors.Actor alias Mobilizon.Service.ActivityPub - alias Mobilizon.Service.ActivityPub.Utils, as: ActivityPubUtils alias Mobilizon.Service.ActivityPub.Activity + alias Mobilizon.Service.ActivityPub.Utils, as: ActivityPubUtils + alias MobilizonWeb.API.Utils @doc """ diff --git a/lib/mobilizon_web/api/follows.ex b/lib/mobilizon_web/api/follows.ex index 4cba7a5ee..7979a4974 100644 --- a/lib/mobilizon_web/api/follows.ex +++ b/lib/mobilizon_web/api/follows.ex @@ -6,6 +6,7 @@ defmodule MobilizonWeb.API.Follows do alias Mobilizon.Actors alias Mobilizon.Actors.{Actor, Follower} alias Mobilizon.Service.ActivityPub + require Logger def follow(%Actor{} = follower, %Actor{} = followed) do diff --git a/lib/mobilizon_web/api/groups.ex b/lib/mobilizon_web/api/groups.ex index aaac7a6b1..9dc78941e 100644 --- a/lib/mobilizon_web/api/groups.ex +++ b/lib/mobilizon_web/api/groups.ex @@ -1,12 +1,14 @@ defmodule MobilizonWeb.API.Groups do @moduledoc """ - API for Events + API for Groups. """ + alias Mobilizon.Actors alias Mobilizon.Actors.Actor - alias Mobilizon.Users.User alias Mobilizon.Service.ActivityPub alias Mobilizon.Service.ActivityPub.Utils, as: ActivityPubUtils + alias Mobilizon.Users.User + alias MobilizonWeb.API.Utils @doc """ diff --git a/lib/mobilizon_web/api/participations.ex b/lib/mobilizon_web/api/participations.ex index 859f3b7f0..97b6ffaf6 100644 --- a/lib/mobilizon_web/api/participations.ex +++ b/lib/mobilizon_web/api/participations.ex @@ -1,6 +1,6 @@ defmodule MobilizonWeb.API.Participations do @moduledoc """ - Common API to join events and groups + Common API to join events and groups. """ alias Mobilizon.Actors.Actor diff --git a/lib/mobilizon_web/api/reports.ex b/lib/mobilizon_web/api/reports.ex index ac7e8ea4a..5f74ee1e9 100644 --- a/lib/mobilizon_web/api/reports.ex +++ b/lib/mobilizon_web/api/reports.ex @@ -1,18 +1,19 @@ defmodule MobilizonWeb.API.Reports do @moduledoc """ - API for Reports + API for Reports. """ - import MobilizonWeb.API.Utils import Mobilizon.Service.Admin.ActionLogService + import MobilizonWeb.API.Utils + alias Mobilizon.Actors alias Mobilizon.Actors.Actor alias Mobilizon.Events - alias Mobilizon.Service.ActivityPub.Activity alias Mobilizon.Reports, as: ReportsAction - alias Mobilizon.Reports.{Report, Note} + alias Mobilizon.Reports.{Note, Report} alias Mobilizon.Service.ActivityPub + alias Mobilizon.Service.ActivityPub.Activity alias Mobilizon.Users alias Mobilizon.Users.User diff --git a/lib/mobilizon_web/api/utils.ex b/lib/mobilizon_web/api/utils.ex index 6e98453f3..a6165b8d7 100644 --- a/lib/mobilizon_web/api/utils.ex +++ b/lib/mobilizon_web/api/utils.ex @@ -1,6 +1,6 @@ defmodule MobilizonWeb.API.Utils do @moduledoc """ - Utils for API + Utils for API. """ alias Mobilizon.Actors.Actor diff --git a/lib/mobilizon_web/controllers/media_proxy_controller.ex b/lib/mobilizon_web/controllers/media_proxy_controller.ex index 630d8b25f..175a94973 100644 --- a/lib/mobilizon_web/controllers/media_proxy_controller.ex +++ b/lib/mobilizon_web/controllers/media_proxy_controller.ex @@ -8,8 +8,8 @@ defmodule MobilizonWeb.MediaProxyController do alias Mobilizon.Config - alias MobilizonWeb.ReverseProxy alias MobilizonWeb.MediaProxy + alias MobilizonWeb.ReverseProxy @default_proxy_opts [max_body_length: 25 * 1_048_576, http: [follow_redirect: true]] diff --git a/lib/mobilizon_web/resolvers/admin.ex b/lib/mobilizon_web/resolvers/admin.ex index f08b23180..b0688d792 100644 --- a/lib/mobilizon_web/resolvers/admin.ex +++ b/lib/mobilizon_web/resolvers/admin.ex @@ -1,14 +1,16 @@ defmodule MobilizonWeb.Resolvers.Admin do @moduledoc """ - Handles the report-related GraphQL calls + Handles the report-related GraphQL calls. """ - alias Mobilizon.Events - alias Mobilizon.Users.User + import Mobilizon.Users.Guards + alias Mobilizon.Admin.ActionLog - alias Mobilizon.Reports.{Report, Note} + alias Mobilizon.Events alias Mobilizon.Events.Event + alias Mobilizon.Reports.{Note, Report} alias Mobilizon.Service.Statistics + alias Mobilizon.Users.User def list_action_logs( _parent, diff --git a/lib/mobilizon_web/resolvers/comment.ex b/lib/mobilizon_web/resolvers/comment.ex index d00b610ce..da0eb84f5 100644 --- a/lib/mobilizon_web/resolvers/comment.ex +++ b/lib/mobilizon_web/resolvers/comment.ex @@ -1,11 +1,12 @@ defmodule MobilizonWeb.Resolvers.Comment do @moduledoc """ - Handles the comment-related GraphQL calls + Handles the comment-related GraphQL calls. """ alias Mobilizon.Events.Comment - alias Mobilizon.Users.User alias Mobilizon.Service.ActivityPub.Activity + alias Mobilizon.Users.User + alias MobilizonWeb.API.Comments require Logger diff --git a/lib/mobilizon_web/resolvers/event.ex b/lib/mobilizon_web/resolvers/event.ex index 29f058ac5..e20e52797 100644 --- a/lib/mobilizon_web/resolvers/event.ex +++ b/lib/mobilizon_web/resolvers/event.ex @@ -1,19 +1,21 @@ defmodule MobilizonWeb.Resolvers.Event do @moduledoc """ - Handles the event-related GraphQL calls + Handles the event-related GraphQL calls. """ + + import Mobilizon.Service.Admin.ActionLogService + + alias Mobilizon.Actors alias Mobilizon.Actors.Actor alias Mobilizon.Addresses alias Mobilizon.Addresses.Address alias Mobilizon.Events alias Mobilizon.Events.{Event, Participant} alias Mobilizon.Media.Picture - alias Mobilizon.Users.User - alias Mobilizon.Actors - alias Mobilizon.Actors.Actor - alias MobilizonWeb.Resolvers.Person alias Mobilizon.Service.ActivityPub.Activity - import Mobilizon.Service.Admin.ActionLogService + alias Mobilizon.Users.User + + alias MobilizonWeb.Resolvers.Person # We limit the max number of events that can be retrieved @event_max_limit 100 diff --git a/lib/mobilizon_web/resolvers/feed_token.ex b/lib/mobilizon_web/resolvers/feed_token.ex index 3d8242a84..530044434 100644 --- a/lib/mobilizon_web/resolvers/feed_token.ex +++ b/lib/mobilizon_web/resolvers/feed_token.ex @@ -1,11 +1,13 @@ defmodule MobilizonWeb.Resolvers.FeedToken do @moduledoc """ - Handles the feed tokens-related GraphQL calls + Handles the feed tokens-related GraphQL calls. """ + alias Mobilizon.Actors.Actor - alias Mobilizon.Users.User alias Mobilizon.Events alias Mobilizon.Events.FeedToken + alias Mobilizon.Users.User + require Logger @doc """ diff --git a/lib/mobilizon_web/resolvers/group.ex b/lib/mobilizon_web/resolvers/group.ex index 4d1638910..c2242576f 100644 --- a/lib/mobilizon_web/resolvers/group.ex +++ b/lib/mobilizon_web/resolvers/group.ex @@ -1,12 +1,13 @@ defmodule MobilizonWeb.Resolvers.Group do @moduledoc """ - Handles the group-related GraphQL calls + Handles the group-related GraphQL calls. """ + alias Mobilizon.Actors alias Mobilizon.Actors.{Actor, Member} + alias Mobilizon.Service.ActivityPub alias Mobilizon.Service.ActivityPub.Activity alias Mobilizon.Users.User - alias Mobilizon.Service.ActivityPub alias MobilizonWeb.Resolvers.Person diff --git a/lib/mobilizon_web/resolvers/report.ex b/lib/mobilizon_web/resolvers/report.ex index ff9ce0391..0b06622e9 100644 --- a/lib/mobilizon_web/resolvers/report.ex +++ b/lib/mobilizon_web/resolvers/report.ex @@ -1,15 +1,18 @@ defmodule MobilizonWeb.Resolvers.Report do @moduledoc """ - Handles the report-related GraphQL calls + Handles the report-related GraphQL calls. """ - alias Mobilizon.Reports - alias Mobilizon.Reports.{Report, Note} - alias Mobilizon.Actors.Actor - alias Mobilizon.Actors - alias Mobilizon.Users.User - alias MobilizonWeb.API.Reports, as: ReportsAPI + import Mobilizon.Users.Guards + alias Mobilizon.Actors + alias Mobilizon.Actors.Actor + alias Mobilizon.Reports + alias Mobilizon.Reports.{Note, Report} + alias Mobilizon.Users.User + + alias MobilizonWeb.API.Reports, as: ReportsAPI + def list_reports( _parent, %{page: page, limit: limit, status: status}, diff --git a/lib/mobilizon_web/resolvers/user.ex b/lib/mobilizon_web/resolvers/user.ex index fbefd49c5..6d765e5e0 100644 --- a/lib/mobilizon_web/resolvers/user.ex +++ b/lib/mobilizon_web/resolvers/user.ex @@ -1,16 +1,16 @@ defmodule MobilizonWeb.Resolvers.User do @moduledoc """ - Handles the user-related GraphQL calls + Handles the user-related GraphQL calls. """ + import Mobilizon.Users.Guards + alias Mobilizon.{Actors, Config, Users, Events} alias Mobilizon.Actors.Actor - alias Mobilizon.Service.Users.{ResetPassword, Activation} + alias Mobilizon.Service.Users.{Activation, ResetPassword} alias Mobilizon.Users.User alias Mobilizon.Storage.Repo - import Mobilizon.Users.Guards - require Logger @doc """ diff --git a/lib/mobilizon_web/schema.ex b/lib/mobilizon_web/schema.ex index 9eaa26411..93dc840b5 100644 --- a/lib/mobilizon_web/schema.ex +++ b/lib/mobilizon_web/schema.ex @@ -1,12 +1,13 @@ defmodule MobilizonWeb.Schema do @moduledoc """ - GraphQL schema representation + GraphQL schema representation. """ + use Absinthe.Schema - alias Mobilizon.{Actors, Events, Users, Addresses, Media, Reports} + alias Mobilizon.{Actors, Addresses, Events, Media, Reports, Users} alias Mobilizon.Actors.{Actor, Follower, Member} - alias Mobilizon.Events.{Event, Comment, Participant} + alias Mobilizon.Events.{Comment, Event, Participant} alias Mobilizon.Storage.Repo import_types(MobilizonWeb.Schema.Custom.UUID) diff --git a/lib/mobilizon_web/schema/actors/group.ex b/lib/mobilizon_web/schema/actors/group.ex index dcf5929d4..f88192dd1 100644 --- a/lib/mobilizon_web/schema/actors/group.ex +++ b/lib/mobilizon_web/schema/actors/group.ex @@ -1,13 +1,18 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do @moduledoc """ - Schema representation for Group + Schema representation for Group. """ + use Absinthe.Schema.Notation + import Absinthe.Resolution.Helpers, only: [dataloader: 1] - import_types(MobilizonWeb.Schema.Actors.MemberType) - alias MobilizonWeb.Resolvers.{Member, Group} + alias Mobilizon.Events + alias MobilizonWeb.Resolvers.{Group, Member} + + import_types(MobilizonWeb.Schema.Actors.MemberType) + @desc """ Represents a group of actors """ diff --git a/lib/mobilizon_web/schema/admin.ex b/lib/mobilizon_web/schema/admin.ex index 715d7fdda..e73678f96 100644 --- a/lib/mobilizon_web/schema/admin.ex +++ b/lib/mobilizon_web/schema/admin.ex @@ -1,11 +1,14 @@ defmodule MobilizonWeb.Schema.AdminType do @moduledoc """ - Schema representation for ActionLog + Schema representation for ActionLog. """ + use Absinthe.Schema.Notation - alias MobilizonWeb.Resolvers.Admin - alias Mobilizon.Reports.{Report, Note} + alias Mobilizon.Events.Event + alias Mobilizon.Reports.{Note, Report} + + alias MobilizonWeb.Resolvers.Admin @desc "An action log" object :action_log do diff --git a/lib/mobilizon_web/schema/event.ex b/lib/mobilizon_web/schema/event.ex index 913023e5f..630848346 100644 --- a/lib/mobilizon_web/schema/event.ex +++ b/lib/mobilizon_web/schema/event.ex @@ -1,14 +1,19 @@ defmodule MobilizonWeb.Schema.EventType do @moduledoc """ - Schema representation for Event + Schema representation for Event. """ + use Absinthe.Schema.Notation - alias Mobilizon.{Actors, Addresses} + import Absinthe.Resolution.Helpers, only: [dataloader: 1] + + alias Mobilizon.{Actors, Addresses} + + alias MobilizonWeb.Resolvers.{Event, Picture, Tag} + import_types(MobilizonWeb.Schema.AddressType) import_types(MobilizonWeb.Schema.Events.ParticipantType) import_types(MobilizonWeb.Schema.TagType) - alias MobilizonWeb.Resolvers.{Picture, Event, Tag} @desc "An event" object :event do diff --git a/lib/mobilizon_web/schema/events/feed_token.ex b/lib/mobilizon_web/schema/events/feed_token.ex index 15cf80e63..ac8ba8b5d 100644 --- a/lib/mobilizon_web/schema/events/feed_token.ex +++ b/lib/mobilizon_web/schema/events/feed_token.ex @@ -1,12 +1,15 @@ defmodule MobilizonWeb.Schema.Events.FeedTokenType do @moduledoc """ - Schema representation for Participant + Schema representation for Participant. """ + use Absinthe.Schema.Notation + import Absinthe.Resolution.Helpers, only: [dataloader: 1] + + alias Mobilizon.{Actors, Users} + alias MobilizonWeb.Resolvers - alias Mobilizon.Users - alias Mobilizon.Actors @desc "Represents a participant to an event" object :feed_token do diff --git a/lib/mobilizon_web/schema/events/participant.ex b/lib/mobilizon_web/schema/events/participant.ex index 3dab24067..c70a3ee60 100644 --- a/lib/mobilizon_web/schema/events/participant.ex +++ b/lib/mobilizon_web/schema/events/participant.ex @@ -1,12 +1,15 @@ defmodule MobilizonWeb.Schema.Events.ParticipantType do @moduledoc """ - Schema representation for Participant + Schema representation for Participant. """ + use Absinthe.Schema.Notation + import Absinthe.Resolution.Helpers, only: [dataloader: 1] + + alias Mobilizon.{Actors, Events} + alias MobilizonWeb.Resolvers - alias Mobilizon.Events - alias Mobilizon.Actors @desc "Represents a participant to an event" object :participant do diff --git a/lib/mobilizon_web/views/activity_pub/actor_view.ex b/lib/mobilizon_web/views/activity_pub/actor_view.ex index b37c5848b..57160956a 100644 --- a/lib/mobilizon_web/views/activity_pub/actor_view.ex +++ b/lib/mobilizon_web/views/activity_pub/actor_view.ex @@ -3,9 +3,8 @@ defmodule MobilizonWeb.ActivityPub.ActorView do alias Mobilizon.Actors alias Mobilizon.Actors.Actor - alias Mobilizon.Service.ActivityPub.Activity alias Mobilizon.Service.ActivityPub - alias Mobilizon.Service.ActivityPub.Utils + alias Mobilizon.Service.ActivityPub.{Activity, Utils} @private_visibility_empty_collection %{elements: [], total: 0} diff --git a/lib/mobilizon_web/views/json_ld/object_view.ex b/lib/mobilizon_web/views/json_ld/object_view.ex index 9bfb028f8..96021a233 100644 --- a/lib/mobilizon_web/views/json_ld/object_view.ex +++ b/lib/mobilizon_web/views/json_ld/object_view.ex @@ -1,9 +1,10 @@ defmodule MobilizonWeb.JsonLD.ObjectView do use MobilizonWeb, :view - alias Mobilizon.Events.Event alias Mobilizon.Actors.Actor alias Mobilizon.Addresses.Address + alias Mobilizon.Events.Event + alias MobilizonWeb.JsonLD.ObjectView alias MobilizonWeb.MediaProxy diff --git a/lib/mobilizon_web/views/page_view.ex b/lib/mobilizon_web/views/page_view.ex index 9064aa4b9..27a943ad6 100644 --- a/lib/mobilizon_web/views/page_view.ex +++ b/lib/mobilizon_web/views/page_view.ex @@ -84,7 +84,7 @@ defmodule MobilizonWeb.PageView do end end - defp index_file_path() do + defp index_file_path do Path.join(Application.app_dir(:mobilizon, "priv/static"), "index.html") end end diff --git a/lib/service/activity_pub/activity_pub.ex b/lib/service/activity_pub/activity_pub.ex index 604a60165..961cfd918 100644 --- a/lib/service/activity_pub/activity_pub.ex +++ b/lib/service/activity_pub/activity_pub.ex @@ -5,28 +5,19 @@ defmodule Mobilizon.Service.ActivityPub do @moduledoc """ - # ActivityPub - - Every ActivityPub method + # ActivityPub context. """ - alias Mobilizon.Config - alias Mobilizon.Events - alias Mobilizon.Events.{Event, Comment, Participant} - alias Mobilizon.Service.ActivityPub.Transmogrifier - alias Mobilizon.Service.WebFinger + import Mobilizon.Service.ActivityPub.{Utils, Visibility} - alias Mobilizon.Actors + alias Mobilizon.{Actors, Config, Events} alias Mobilizon.Actors.{Actor, Follower} - - alias Mobilizon.Service.Federator + alias Mobilizon.Events.{Comment, Event, Participant} + alias Mobilizon.Service.ActivityPub.{Activity, Convertible, Transmogrifier} + alias Mobilizon.Service.{Federator, WebFinger} alias Mobilizon.Service.HTTPSignatures.Signature - alias Mobilizon.Service.ActivityPub.{Activity, Convertible} - require Logger - import Mobilizon.Service.ActivityPub.Utils - import Mobilizon.Service.ActivityPub.Visibility @doc """ Get recipients for an activity or object @@ -452,7 +443,8 @@ defmodule Mobilizon.Service.ActivityPub do def leave(object, actor, local \\ true) - # TODO: If we want to use this for exclusion we need to have an extra field for the actor that excluded the participant + # TODO: If we want to use this for exclusion we need to have an extra field + # for the actor that excluded the participant def leave( %Event{id: event_id, url: event_url} = event, %Actor{id: actor_id, url: actor_url} = _actor, diff --git a/lib/service/activity_pub/converters/actor.ex b/lib/service/activity_pub/converters/actor.ex index 002e7c3e8..69acba8d4 100644 --- a/lib/service/activity_pub/converters/actor.ex +++ b/lib/service/activity_pub/converters/actor.ex @@ -2,8 +2,10 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Actor do @moduledoc """ Actor converter - This module allows to convert events from ActivityStream format to our own internal one, and back + This module allows to convert events from ActivityStream format to our own + internal one, and back. """ + alias Mobilizon.Actors.Actor, as: ActorModel alias Mobilizon.Service.ActivityPub.Converter diff --git a/lib/service/activity_pub/converters/address.ex b/lib/service/activity_pub/converters/address.ex index 1d5ae0831..20ce1d73d 100644 --- a/lib/service/activity_pub/converters/address.ex +++ b/lib/service/activity_pub/converters/address.ex @@ -1,11 +1,13 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Address do @moduledoc """ - Flag converter + Address converter. - This module allows to convert reports from ActivityStream format to our own internal one, and back. + This module allows to convert reports from ActivityStream format to our own + internal one, and back. Note: Reports are named Flag in AS. """ + alias Mobilizon.Addresses.Address, as: AddressModel alias Mobilizon.Service.ActivityPub.Converter diff --git a/lib/service/activity_pub/converters/comment.ex b/lib/service/activity_pub/converters/comment.ex index 920d699e8..0fe596ba2 100644 --- a/lib/service/activity_pub/converters/comment.ex +++ b/lib/service/activity_pub/converters/comment.ex @@ -1,14 +1,17 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Comment do @moduledoc """ - Comment converter + Comment converter. - This module allows to convert events from ActivityStream format to our own internal one, and back + This module allows to convert events from ActivityStream format to our own + internal one, and back. """ + alias Mobilizon.Actors.Actor alias Mobilizon.Events.Comment, as: CommentModel alias Mobilizon.Events.Event - alias Mobilizon.Service.ActivityPub.Converter alias Mobilizon.Service.ActivityPub + alias Mobilizon.Service.ActivityPub.Converter + require Logger @behaviour Converter diff --git a/lib/service/activity_pub/converters/event.ex b/lib/service/activity_pub/converters/event.ex index b0586829d..ec6c56c98 100644 --- a/lib/service/activity_pub/converters/event.ex +++ b/lib/service/activity_pub/converters/event.ex @@ -1,26 +1,24 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Event do @moduledoc """ - Event converter + Event converter. - This module allows to convert events from ActivityStream format to our own internal one, and back + This module allows to convert events from ActivityStream format to our own + internal one, and back. """ - alias Mobilizon.Actors - alias Mobilizon.Media - alias Mobilizon.Media.Picture - alias Mobilizon.Actors.Actor - alias Mobilizon.Events.Event, as: EventModel - alias Mobilizon.Service.ActivityPub.Converter - alias Mobilizon.Service.ActivityPub.Converters.Address, as: AddressConverter - alias Mobilizon.Service.ActivityPub.Utils - alias Mobilizon.Events - alias Mobilizon.Events.Tag - alias Mobilizon.Addresses - alias Mobilizon.Addresses.Address - @behaviour Converter + alias Mobilizon.{Actors, Addresses, Events, Media} + alias Mobilizon.Actors.Actor + alias Mobilizon.Addresses.Address + alias Mobilizon.Events.Event, as: EventModel + alias Mobilizon.Events.Tag + alias Mobilizon.Media.Picture + alias Mobilizon.Service.ActivityPub.{Converter, Utils} + alias Mobilizon.Service.ActivityPub.Converters.Address, as: AddressConverter require Logger + @behaviour Converter + @doc """ Converts an AP object data to our internal data structure """ diff --git a/lib/service/activity_pub/converters/flag.ex b/lib/service/activity_pub/converters/flag.ex index fd5482700..e81a49a13 100644 --- a/lib/service/activity_pub/converters/flag.ex +++ b/lib/service/activity_pub/converters/flag.ex @@ -1,11 +1,13 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Flag do @moduledoc """ - Flag converter + Flag converter. - This module allows to convert reports from ActivityStream format to our own internal one, and back. + This module allows to convert reports from ActivityStream format to our own + internal one, and back. Note: Reports are named Flag in AS. """ + alias Mobilizon.Actors alias Mobilizon.Actors.Actor alias Mobilizon.Events diff --git a/lib/service/activity_pub/converters/participant.ex b/lib/service/activity_pub/converters/participant.ex index 35de9d85f..28fb4fe21 100644 --- a/lib/service/activity_pub/converters/participant.ex +++ b/lib/service/activity_pub/converters/participant.ex @@ -1,11 +1,13 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Participant do @moduledoc """ - Flag converter + Participant converter. - This module allows to convert reports from ActivityStream format to our own internal one, and back. + This module allows to convert reports from ActivityStream format to our own + internal one, and back. Note: Reports are named Flag in AS. """ + alias Mobilizon.Events.Participant, as: ParticipantModel @doc """ diff --git a/lib/service/activity_pub/relay.ex b/lib/service/activity_pub/relay.ex index 7b4396a1f..e6686bae9 100644 --- a/lib/service/activity_pub/relay.ex +++ b/lib/service/activity_pub/relay.ex @@ -5,13 +5,13 @@ defmodule Mobilizon.Service.ActivityPub.Relay do @moduledoc """ - Handles following and unfollowing relays and instances + Handles following and unfollowing relays and instances. """ alias Mobilizon.Actors alias Mobilizon.Actors.Actor - alias Mobilizon.Service.ActivityPub.Activity alias Mobilizon.Service.ActivityPub + alias Mobilizon.Service.ActivityPub.Activity alias MobilizonWeb.API.Follows diff --git a/lib/service/activity_pub/transmogrifier.ex b/lib/service/activity_pub/transmogrifier.ex index a41f538ab..446dab9c5 100644 --- a/lib/service/activity_pub/transmogrifier.ex +++ b/lib/service/activity_pub/transmogrifier.ex @@ -7,12 +7,13 @@ defmodule Mobilizon.Service.ActivityPub.Transmogrifier do @moduledoc """ A module to handle coding from internal to wire ActivityPub and back. """ + alias Mobilizon.Actors alias Mobilizon.Actors.{Actor, Follower} alias Mobilizon.Events - alias Mobilizon.Events.{Event, Comment, Participant} + alias Mobilizon.Events.{Comment, Event, Participant} alias Mobilizon.Service.ActivityPub - alias Mobilizon.Service.ActivityPub.{Visibility, Utils} + alias Mobilizon.Service.ActivityPub.{Utils, Visibility} require Logger diff --git a/lib/service/activity_pub/utils.ex b/lib/service/activity_pub/utils.ex index f8efacbe3..77b59f39b 100644 --- a/lib/service/activity_pub/utils.ex +++ b/lib/service/activity_pub/utils.ex @@ -5,25 +5,19 @@ defmodule Mobilizon.Service.ActivityPub.Utils do @moduledoc """ - # Utils - - Various utils + # Various ActivityPub related utils. """ alias Ecto.Changeset - alias Mobilizon.Addresses - alias Mobilizon.Addresses.Address - alias Mobilizon.Actors + alias Mobilizon.{Actors, Addresses, Events, Reports, Users} alias Mobilizon.Actors.Actor - alias Mobilizon.Events + alias Mobilizon.Addresses.Address alias Mobilizon.Events.{Comment, Event} alias Mobilizon.Media.Picture - alias Mobilizon.Reports alias Mobilizon.Reports.Report alias Mobilizon.Service.ActivityPub.{Activity, Converters} alias Mobilizon.Storage.Repo - alias Mobilizon.Users alias MobilizonWeb.{Email, Endpoint} alias MobilizonWeb.Router.Helpers, as: Routes diff --git a/lib/service/admin/action_log_service.ex b/lib/service/admin/action_log_service.ex index 6f82ead2f..7acbdb3a7 100644 --- a/lib/service/admin/action_log_service.ex +++ b/lib/service/admin/action_log_service.ex @@ -1,13 +1,13 @@ defmodule Mobilizon.Service.Admin.ActionLogService do @moduledoc """ - Module to handle action log creations + Module to handle action log creations. """ - alias Mobilizon.Users - alias Mobilizon.Users.User alias Mobilizon.Actors.Actor alias Mobilizon.Admin alias Mobilizon.Admin.ActionLog + alias Mobilizon.Users + alias Mobilizon.Users.User @doc """ Log an admin action diff --git a/lib/service/email_checker.ex b/lib/service/email_checker.ex index 62cbe7efa..f92ec33c1 100644 --- a/lib/service/email_checker.ex +++ b/lib/service/email_checker.ex @@ -1,15 +1,14 @@ defmodule Mobilizon.Service.EmailChecker do @moduledoc """ - Provides a function to test emails against a "not so bad" regex + Provides a function to test emails against a "not so bad" regex. """ + # TODO: simplify me! @email_regex ~r/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ @doc """ - Returns whether the email is valid + Returns whether the email is valid. """ - @spec valid?(String.t()) :: boolean() - def valid?(email) do - email =~ @email_regex - end + @spec valid?(String.t()) :: boolean + def valid?(email), do: email =~ @email_regex end diff --git a/lib/service/export/feed.ex b/lib/service/export/feed.ex index 002ed83ac..77ff71424 100644 --- a/lib/service/export/feed.ex +++ b/lib/service/export/feed.ex @@ -1,23 +1,24 @@ defmodule Mobilizon.Service.Export.Feed do @moduledoc """ - Serve Atom Syndication Feeds + Serve Atom Syndication Feeds. """ - alias Mobilizon.Users.User - alias Mobilizon.Users - alias Mobilizon.Actors - alias Mobilizon.Actors.Actor - alias Mobilizon.Events - alias Mobilizon.Events.{Event, FeedToken} - alias Atomex.{Feed, Entry} import MobilizonWeb.Gettext + + alias Atomex.{Entry, Feed} + + alias Mobilizon.{Actors, Events, Users} + alias Mobilizon.Actors.Actor + alias Mobilizon.Events.{Event, FeedToken} + alias Mobilizon.Users.User + + alias MobilizonWeb.{Endpoint, MediaProxy} alias MobilizonWeb.Router.Helpers, as: Routes - alias MobilizonWeb.Endpoint - alias MobilizonWeb.MediaProxy + require Logger @version Mix.Project.config()[:version] - def version(), do: @version + def version, do: @version @spec create_cache(String.t()) :: {:commit, String.t()} | {:ignore, any()} def create_cache("actor_" <> name) do diff --git a/lib/service/export/icalendar.ex b/lib/service/export/icalendar.ex index fe053d451..94a465d5a 100644 --- a/lib/service/export/icalendar.ex +++ b/lib/service/export/icalendar.ex @@ -1,14 +1,12 @@ defmodule Mobilizon.Service.Export.ICalendar do @moduledoc """ - Export an event to iCalendar format + Export an event to iCalendar format. """ - alias Mobilizon.Events.{Event, FeedToken} - alias Mobilizon.Events + alias Mobilizon.{Actors, Events, Users} alias Mobilizon.Actors.Actor - alias Mobilizon.Actors + alias Mobilizon.Events.{Event, FeedToken} alias Mobilizon.Users.User - alias Mobilizon.Users @doc """ Export a public event to iCalendar format. diff --git a/lib/service/formatter/formatter.ex b/lib/service/formatter/formatter.ex index f6e02cc47..bbff1ef5c 100644 --- a/lib/service/formatter/formatter.ex +++ b/lib/service/formatter/formatter.ex @@ -5,10 +5,11 @@ defmodule Mobilizon.Service.Formatter do @moduledoc """ - Formats input text to structured data, extracts mentions and hashtags + Formats input text to structured data, extracts mentions and hashtags. """ - alias Mobilizon.Actors.Actor + alias Mobilizon.Actors + alias Mobilizon.Actors.Actor alias Mobilizon.Service.HTML @link_regex ~r"((?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~%:/?#[\]@!\$&'\(\)\*\+,;=.]+)|[0-9a-z+\-\.]+:[0-9a-z$-_.+!*'(),]+"ui diff --git a/lib/service/geospatial/addok.ex b/lib/service/geospatial/addok.ex index a1b1ec0b7..b209ec0d9 100644 --- a/lib/service/geospatial/addok.ex +++ b/lib/service/geospatial/addok.ex @@ -2,9 +2,11 @@ defmodule Mobilizon.Service.Geospatial.Addok do @moduledoc """ [Addok](https://github.com/addok/addok) backend. """ - alias Mobilizon.Service.Geospatial.Provider - require Logger + alias Mobilizon.Addresses.Address + alias Mobilizon.Service.Geospatial.Provider + + require Logger @behaviour Provider diff --git a/lib/service/geospatial/geospatial.ex b/lib/service/geospatial/geospatial.ex index 0321997af..69386a1ee 100644 --- a/lib/service/geospatial/geospatial.ex +++ b/lib/service/geospatial/geospatial.ex @@ -1,15 +1,17 @@ defmodule Mobilizon.Service.Geospatial do @moduledoc """ - Module to load the service adapter defined inside the configuration + Module to load the service adapter defined inside the configuration. - See `Mobilizon.Service.Geospatial.Provider` + See `Mobilizon.Service.Geospatial.Provider`. """ @doc """ - Returns the appropriate service adapter + Returns the appropriate service adapter. - According to the config behind `config :mobilizon, Mobilizon.Service.Geospatial, service: Mobilizon.Service.Geospatial.Module` + According to the config behind + `config :mobilizon, Mobilizon.Service.Geospatial, + service: Mobilizon.Service.Geospatial.Module` """ - @spec service() :: module() - def service(), do: Application.get_env(:mobilizon, __MODULE__) |> get_in([:service]) + @spec service :: module + def service, do: get_in(Application.get_env(:mobilizon, __MODULE__), [:service]) end diff --git a/lib/service/geospatial/google_maps.ex b/lib/service/geospatial/google_maps.ex index 7b73475f7..72054c095 100644 --- a/lib/service/geospatial/google_maps.ex +++ b/lib/service/geospatial/google_maps.ex @@ -1,11 +1,13 @@ defmodule Mobilizon.Service.Geospatial.GoogleMaps do @moduledoc """ - Google Maps [Geocoding service](https://developers.google.com/maps/documentation/geocoding/intro) + Google Maps [Geocoding service](https://developers.google.com/maps/documentation/geocoding/intro). - Note: Endpoint is hardcoded to Google Maps API + Note: Endpoint is hardcoded to Google Maps API. """ - alias Mobilizon.Service.Geospatial.Provider + alias Mobilizon.Addresses.Address + alias Mobilizon.Service.Geospatial.Provider + require Logger @behaviour Provider diff --git a/lib/service/geospatial/map_quest.ex b/lib/service/geospatial/map_quest.ex index 340d173a1..1c45a38b6 100644 --- a/lib/service/geospatial/map_quest.ex +++ b/lib/service/geospatial/map_quest.ex @@ -8,8 +8,10 @@ defmodule Mobilizon.Service.Geospatial.MapQuest do * `:open_data` Whether to use [Open Data or Licenced Data](https://developer.mapquest.com/documentation/open/). Defaults to `true` """ - alias Mobilizon.Service.Geospatial.Provider + alias Mobilizon.Addresses.Address + alias Mobilizon.Service.Geospatial.Provider + require Logger @behaviour Provider diff --git a/lib/service/geospatial/nominatim.ex b/lib/service/geospatial/nominatim.ex index 029bed62e..47dda84f7 100644 --- a/lib/service/geospatial/nominatim.ex +++ b/lib/service/geospatial/nominatim.ex @@ -2,8 +2,10 @@ defmodule Mobilizon.Service.Geospatial.Nominatim do @moduledoc """ [Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim) backend. """ - alias Mobilizon.Service.Geospatial.Provider + alias Mobilizon.Addresses.Address + alias Mobilizon.Service.Geospatial.Provider + require Logger @behaviour Provider @@ -66,23 +68,22 @@ defmodule Mobilizon.Service.Geospatial.Nominatim do @spec process_data(map()) :: Address.t() defp process_data(%{"address" => address} = body) do - try do - %Address{ - country: Map.get(address, "country"), - locality: Map.get(address, "city"), - region: Map.get(address, "state"), - description: description(body), - floor: Map.get(address, "floor"), - geom: [Map.get(body, "lon"), Map.get(body, "lat")] |> Provider.coordinates(), - postal_code: Map.get(address, "postcode"), - street: street_address(address), - origin_id: "osm:" <> to_string(Map.get(body, "osm_id")) - } - rescue - e in ArgumentError -> - Logger.warn(inspect(e)) - nil - end + %Address{ + country: Map.get(address, "country"), + locality: Map.get(address, "city"), + region: Map.get(address, "state"), + description: description(body), + floor: Map.get(address, "floor"), + geom: [Map.get(body, "lon"), Map.get(body, "lat")] |> Provider.coordinates(), + postal_code: Map.get(address, "postcode"), + street: street_address(address), + origin_id: "osm:" <> to_string(Map.get(body, "osm_id")) + } + rescue + error in ArgumentError -> + Logger.warn(inspect(error)) + + nil end @spec street_address(map()) :: String.t() diff --git a/lib/service/geospatial/photon.ex b/lib/service/geospatial/photon.ex index 3320b5cc1..7bf11131d 100644 --- a/lib/service/geospatial/photon.ex +++ b/lib/service/geospatial/photon.ex @@ -2,9 +2,11 @@ defmodule Mobilizon.Service.Geospatial.Photon do @moduledoc """ [Photon](https://photon.komoot.de) backend. """ - alias Mobilizon.Service.Geospatial.Provider - require Logger + alias Mobilizon.Addresses.Address + alias Mobilizon.Service.Geospatial.Provider + + require Logger @behaviour Provider diff --git a/lib/service/geospatial/provider.ex b/lib/service/geospatial/provider.ex index e79ef2df8..e421df7f5 100644 --- a/lib/service/geospatial/provider.ex +++ b/lib/service/geospatial/provider.ex @@ -14,11 +14,13 @@ defmodule Mobilizon.Service.Geospatial.Provider do ## Shared options * `:user_agent` User-Agent string to send to the backend. Defaults to `"Mobilizon"` - * `:lang` Lang in which to prefer results. Used as a request parameter or through an `Accept-Language` HTTP header. - Defaults to `"en"`. - * `:limit` Maximum limit for the number of results returned by the backend. Defaults to `10` - * `:api_key` Allows to override the API key (if the backend requires one) set inside the configuration. - * `:endpoint` Allows to override the endpoint set inside the configuration + * `:lang` Lang in which to prefer results. Used as a request parameter or + through an `Accept-Language` HTTP header. Defaults to `"en"`. + * `:limit` Maximum limit for the number of results returned by the backend. + Defaults to `10` + * `:api_key` Allows to override the API key (if the backend requires one) set + inside the configuration. + * `:endpoint` Allows to override the endpoint set inside the configuration. """ alias Mobilizon.Addresses.Address @@ -35,38 +37,40 @@ defmodule Mobilizon.Service.Geospatial.Provider do iex> geocode(48.11, -1.77) %Address{} """ - @callback geocode(longitude :: number(), latitude :: number(), options :: keyword()) :: - list(Address.t()) + @callback geocode(longitude :: number, latitude :: number, options :: keyword) :: [Address.t()] @doc """ Search for an address ## Options - In addition to [the shared options](#module-shared-options), `c:search/2` also accepts the following options: + In addition to [the shared options](#module-shared-options), `c:search/2` also + accepts the following options: - * `coords` Map of coordinates (ex: `%{lon: 48.11, lat: -1.77}`) allowing to give a geographic priority to the search. - Defaults to `nil` + * `coords` Map of coordinates (ex: `%{lon: 48.11, lat: -1.77}`) allowing to + give a geographic priority to the search. Defaults to `nil`. ## Examples iex> search("10 rue Jangot") %Address{} """ - @callback search(address :: String.t(), options :: keyword()) :: list(Address.t()) + @callback search(address :: String.t(), options :: keyword) :: [Address.t()] @doc """ Returns a `Geo.Point` for given coordinates """ - @spec coordinates(list(number()), number()) :: Geo.Point.t() + @spec coordinates([number], number) :: Geo.Point.t() def coordinates(coords, srid \\ 4326) - def coordinates([x, y], srid) when is_number(x) and is_number(y), - do: %Geo.Point{coordinates: {x, y}, srid: srid} + def coordinates([x, y], srid) when is_number(x) and is_number(y) do + %Geo.Point{coordinates: {x, y}, srid: srid} + end - def coordinates([x, y], srid) when is_bitstring(x) and is_bitstring(y), - do: %Geo.Point{coordinates: {String.to_float(x), String.to_float(y)}, srid: srid} + def coordinates([x, y], srid) when is_bitstring(x) and is_bitstring(y) do + %Geo.Point{coordinates: {String.to_float(x), String.to_float(y)}, srid: srid} + end - @spec coordinates(any()) :: nil + @spec coordinates(any) :: nil def coordinates(_, _), do: nil end diff --git a/lib/service/users/activation.ex b/lib/service/users/activation.ex index 1d03da1a2..016650ce6 100644 --- a/lib/service/users/activation.ex +++ b/lib/service/users/activation.ex @@ -1,9 +1,9 @@ defmodule Mobilizon.Service.Users.Activation do @moduledoc false + alias Mobilizon.Service.Users.Tools alias Mobilizon.Users alias Mobilizon.Users.User - alias Mobilizon.Service.Users.Tools alias MobilizonWeb.Email diff --git a/test/mobilizon/actors/actors_test.exs b/test/mobilizon/actors/actors_test.exs index df5a5755b..2727f4d17 100644 --- a/test/mobilizon/actors/actors_test.exs +++ b/test/mobilizon/actors/actors_test.exs @@ -6,7 +6,7 @@ defmodule Mobilizon.ActorsTest do import Mobilizon.Factory alias Mobilizon.{Actors, Config, Users} - alias Mobilizon.Actors.{Actor, Member, Follower, Bot} + alias Mobilizon.Actors.{Actor, Bot, Follower, Member} alias Mobilizon.Media.File, as: FileModel alias Mobilizon.Service.ActivityPub alias Mobilizon.Storage.Page @@ -311,9 +311,6 @@ defmodule Mobilizon.ActorsTest do end describe "groups" do - alias Mobilizon.Actors - alias Mobilizon.Actors.Actor - @valid_attrs %{ summary: "some description", suspended: true, @@ -356,11 +353,7 @@ defmodule Mobilizon.ActorsTest do end end - alias Mobilizon.Actors - describe "bots" do - alias Mobilizon.Actors.Bot - @valid_attrs %{source: "some source", type: "some type"} @update_attrs %{source: "some updated source", type: "some updated type"} @invalid_attrs %{source: nil, type: nil} @@ -419,9 +412,6 @@ defmodule Mobilizon.ActorsTest do end describe "followers" do - alias Mobilizon.Actors.Follower - alias Mobilizon.Actors.Actor - @valid_attrs %{approved: true} @update_attrs %{approved: false} @invalid_attrs %{approved: nil} @@ -529,9 +519,6 @@ defmodule Mobilizon.ActorsTest do end describe "members" do - alias Mobilizon.Actors.Member - alias Mobilizon.Actors.Actor - @valid_attrs %{role: :member} @update_attrs %{role: :not_approved} @invalid_attrs %{role: nil} diff --git a/test/mobilizon/events/events_test.exs b/test/mobilizon/events/events_test.exs index 5564c4d0b..5aabd690f 100644 --- a/test/mobilizon/events/events_test.exs +++ b/test/mobilizon/events/events_test.exs @@ -3,7 +3,9 @@ defmodule Mobilizon.EventsTest do import Mobilizon.Factory + alias Mobilizon.Actors.Actor alias Mobilizon.Events + alias Mobilizon.Events.{Comment, Event, Participant, Session, Tag, TagRelation, Track} alias Mobilizon.Storage.Page @event_valid_attrs %{ @@ -17,8 +19,6 @@ defmodule Mobilizon.EventsTest do } describe "events" do - alias Mobilizon.Events.Event - setup do actor = insert(:actor) event = insert(:event, organizer_actor: actor, visibility: :public) @@ -176,8 +176,6 @@ defmodule Mobilizon.EventsTest do end describe "tags" do - alias Mobilizon.Events.Tag - @valid_attrs %{title: "some title"} @update_attrs %{title: "some updated title"} @invalid_attrs %{title: nil} @@ -227,9 +225,6 @@ defmodule Mobilizon.EventsTest do end describe "tags_relations" do - alias Mobilizon.Events.TagRelation - alias Mobilizon.Events.Tag - setup do tag1 = insert(:tag) tag2 = insert(:tag) @@ -302,9 +297,6 @@ defmodule Mobilizon.EventsTest do end describe "participants" do - alias Mobilizon.Events.{Participant, Event} - alias Mobilizon.Actors.Actor - @valid_attrs %{role: :creator} @update_attrs %{role: :moderator} @invalid_attrs %{role: :no_such_role} @@ -369,8 +361,6 @@ defmodule Mobilizon.EventsTest do end describe "sessions" do - alias Mobilizon.Events.Session - @valid_attrs %{ audios_urls: "some audios_urls", language: "some language", @@ -463,8 +453,6 @@ defmodule Mobilizon.EventsTest do end describe "tracks" do - alias Mobilizon.Events.Track - @valid_attrs %{color: "some color", description: "some description", name: "some name"} @update_attrs %{ color: "some updated color", @@ -525,8 +513,6 @@ defmodule Mobilizon.EventsTest do end describe "comments" do - alias Mobilizon.Events.Comment - @valid_attrs %{text: "some text"} @update_attrs %{text: "some updated text"} @invalid_attrs %{text: nil, url: nil} diff --git a/test/mobilizon/service/activity_pub/activity_pub_test.exs b/test/mobilizon/service/activity_pub/activity_pub_test.exs index f7ae2c816..1b7d10482 100644 --- a/test/mobilizon/service/activity_pub/activity_pub_test.exs +++ b/test/mobilizon/service/activity_pub/activity_pub_test.exs @@ -4,17 +4,19 @@ # Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/activity_pub/activity_pub_test.exs defmodule Mobilizon.Service.ActivityPub.ActivityPubTest do + use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + use Mobilizon.DataCase + import Mock + import Mobilizon.Factory + alias Mobilizon.Actors.Actor alias Mobilizon.Events alias Mobilizon.Events.Event - alias Mobilizon.Actors.Actor - alias Mobilizon.Service.HTTPSignatures.Signature alias Mobilizon.Service.ActivityPub - use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney - import Mock + alias Mobilizon.Service.HTTPSignatures.Signature setup_all do HTTPoison.start() diff --git a/test/mobilizon/service/activity_pub/converters/actor_test.exs b/test/mobilizon/service/activity_pub/converters/actor_test.exs index 242fc9385..b9f31b44d 100644 --- a/test/mobilizon/service/activity_pub/converters/actor_test.exs +++ b/test/mobilizon/service/activity_pub/converters/actor_test.exs @@ -1,7 +1,8 @@ defmodule Mobilizon.Service.ActivityPub.Converters.ActorTest do use Mobilizon.DataCase - alias Mobilizon.Service.ActivityPub.Converters.Actor, as: ActorConverter + alias Mobilizon.Actors.Actor + alias Mobilizon.Service.ActivityPub.Converters.Actor, as: ActorConverter describe "actor to AS" do test "valid actor to as" do diff --git a/test/mobilizon/service/activity_pub/transmogrifier_test.exs b/test/mobilizon/service/activity_pub/transmogrifier_test.exs index b7ed9d3bb..2f2f6e01a 100644 --- a/test/mobilizon/service/activity_pub/transmogrifier_test.exs +++ b/test/mobilizon/service/activity_pub/transmogrifier_test.exs @@ -4,6 +4,8 @@ # Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/activity_pub/transmogrifier_test.exs defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do + use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + use Mobilizon.DataCase import Mobilizon.Factory @@ -13,9 +15,8 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do alias Mobilizon.Events alias Mobilizon.Events.{Comment, Event, Participant} alias Mobilizon.Service.ActivityPub - alias Mobilizon.Service.ActivityPub.{Utils, Activity} + alias Mobilizon.Service.ActivityPub.{Activity, Utils} alias Mobilizon.Service.ActivityPub.Transmogrifier - use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney setup_all do HTTPoison.start() diff --git a/test/mobilizon/service/activity_pub/utils_test.exs b/test/mobilizon/service/activity_pub/utils_test.exs index dacb69bff..7d74df3cb 100644 --- a/test/mobilizon/service/activity_pub/utils_test.exs +++ b/test/mobilizon/service/activity_pub/utils_test.exs @@ -1,10 +1,14 @@ defmodule Mobilizon.Service.ActivityPub.UtilsTest do - use Mobilizon.DataCase - import Mobilizon.Factory - alias Mobilizon.Service.ActivityPub.Utils use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney - alias MobilizonWeb.Router.Helpers, as: Routes + + use Mobilizon.DataCase + + import Mobilizon.Factory + + alias Mobilizon.Service.ActivityPub.Utils + alias MobilizonWeb.Endpoint + alias MobilizonWeb.Router.Helpers, as: Routes setup_all do HTTPoison.start() diff --git a/test/mobilizon/service/admin/action_log_service_test.exs b/test/mobilizon/service/admin/action_log_service_test.exs index b96a3eefc..8ec336d37 100644 --- a/test/mobilizon/service/admin/action_log_service_test.exs +++ b/test/mobilizon/service/admin/action_log_service_test.exs @@ -1,12 +1,15 @@ defmodule Mobilizon.Service.Admin.ActionLogServiceTest do @moduledoc """ - Test the ActionLogService module + Test the ActionLogService module. """ + use Mobilizon.DataCase - import Mobilizon.Service.Admin.ActionLogService - alias Mobilizon.Reports.{Report, Note} - alias Mobilizon.Admin.ActionLog + import Mobilizon.Factory + import Mobilizon.Service.Admin.ActionLogService + + alias Mobilizon.Admin.ActionLog + alias Mobilizon.Reports.{Note, Report} setup do moderator_user = insert(:user, role: :moderator) diff --git a/test/mobilizon/service/geospatial/addok_test.exs b/test/mobilizon/service/geospatial/addok_test.exs index e28cf7beb..d81cfaab4 100644 --- a/test/mobilizon/service/geospatial/addok_test.exs +++ b/test/mobilizon/service/geospatial/addok_test.exs @@ -1,13 +1,14 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do - use Mobilizon.DataCase, async: false - alias Mobilizon.Service.Geospatial.Addok - alias Mobilizon.Addresses.Address - - import Mock use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney - @endpoint Application.get_env(:mobilizon, Mobilizon.Service.Geospatial.Addok) - |> get_in([:endpoint]) + use Mobilizon.DataCase, async: false + + import Mock + + alias Mobilizon.Addresses.Address + alias Mobilizon.Service.Geospatial.Addok + + @endpoint get_in(Application.get_env(:mobilizon, Addok), [:endpoint]) @fake_endpoint "https://domain.tld" describe "search address" do diff --git a/test/mobilizon/service/geospatial/google_maps_test.exs b/test/mobilizon/service/geospatial/google_maps_test.exs index 8cab24600..c29a3f106 100644 --- a/test/mobilizon/service/geospatial/google_maps_test.exs +++ b/test/mobilizon/service/geospatial/google_maps_test.exs @@ -1,10 +1,12 @@ defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do + use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + use Mobilizon.DataCase, async: false - alias Mobilizon.Service.Geospatial.GoogleMaps - alias Mobilizon.Addresses.Address import Mock - use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + + alias Mobilizon.Addresses.Address + alias Mobilizon.Service.Geospatial.GoogleMaps describe "search address" do test "without API Key triggers an error" do diff --git a/test/mobilizon/service/geospatial/map_quest_test.exs b/test/mobilizon/service/geospatial/map_quest_test.exs index 51d5646a8..1176ef316 100644 --- a/test/mobilizon/service/geospatial/map_quest_test.exs +++ b/test/mobilizon/service/geospatial/map_quest_test.exs @@ -1,10 +1,12 @@ defmodule Mobilizon.Service.Geospatial.MapQuestTest do + use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + use Mobilizon.DataCase, async: false - alias Mobilizon.Service.Geospatial.MapQuest - alias Mobilizon.Addresses.Address import Mock - use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + + alias Mobilizon.Addresses.Address + alias Mobilizon.Service.Geospatial.MapQuest describe "search address" do test "without API Key triggers an error" do diff --git a/test/mobilizon/service/geospatial/nominatim_test.exs b/test/mobilizon/service/geospatial/nominatim_test.exs index 11116072a..e436afbe3 100644 --- a/test/mobilizon/service/geospatial/nominatim_test.exs +++ b/test/mobilizon/service/geospatial/nominatim_test.exs @@ -1,10 +1,12 @@ defmodule Mobilizon.Service.Geospatial.NominatimTest do + use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + use Mobilizon.DataCase, async: false - alias Mobilizon.Service.Geospatial.Nominatim - alias Mobilizon.Addresses.Address import Mock - use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + + alias Mobilizon.Addresses.Address + alias Mobilizon.Service.Geospatial.Nominatim describe "search address" do test "produces a valid search address with options" do diff --git a/test/mobilizon/service/geospatial/photon_test.exs b/test/mobilizon/service/geospatial/photon_test.exs index 6d9c3872f..630035c60 100644 --- a/test/mobilizon/service/geospatial/photon_test.exs +++ b/test/mobilizon/service/geospatial/photon_test.exs @@ -1,10 +1,12 @@ defmodule Mobilizon.Service.Geospatial.PhotonTest do + use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + use Mobilizon.DataCase, async: false - alias Mobilizon.Service.Geospatial.Photon - alias Mobilizon.Addresses.Address import Mock - use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + + alias Mobilizon.Addresses.Address + alias Mobilizon.Service.Geospatial.Photon describe "search address" do test "produces a valid search address with options" do diff --git a/test/mobilizon_web/api/report_test.exs b/test/mobilizon_web/api/report_test.exs index 9ff39b988..26ba77f2e 100644 --- a/test/mobilizon_web/api/report_test.exs +++ b/test/mobilizon_web/api/report_test.exs @@ -5,10 +5,10 @@ defmodule MobilizonWeb.API.ReportTest do alias Mobilizon.Actors.Actor alias Mobilizon.Events.{Comment, Event} - alias Mobilizon.Reports.{Report, Note} + alias Mobilizon.Reports.{Note, Report} + alias Mobilizon.Service.ActivityPub.Activity alias Mobilizon.Users alias Mobilizon.Users.User - alias Mobilizon.Service.ActivityPub.Activity alias MobilizonWeb.API.Reports diff --git a/test/mobilizon_web/api/search_test.exs b/test/mobilizon_web/api/search_test.exs index af26b4018..c9acc25a8 100644 --- a/test/mobilizon_web/api/search_test.exs +++ b/test/mobilizon_web/api/search_test.exs @@ -1,17 +1,17 @@ defmodule MobilizonWeb.API.SearchTest do use ExUnit.Case, async: false - alias Mobilizon.Events - alias Mobilizon.Events.Event + import Mock + alias Mobilizon.Actors alias Mobilizon.Actors.Actor + alias Mobilizon.Events + alias Mobilizon.Events.Event alias Mobilizon.Service.ActivityPub alias Mobilizon.Storage.Page alias MobilizonWeb.API.Search - import Mock - test "search an user by username" do with_mock ActivityPub, find_or_make_actor_from_nickname: fn "toto@domain.tld" -> {:ok, %Actor{id: 42}} end do diff --git a/test/mobilizon_web/controllers/activity_pub_controller_test.exs b/test/mobilizon_web/controllers/activity_pub_controller_test.exs index c53c420e8..30e1f67ae 100644 --- a/test/mobilizon_web/controllers/activity_pub_controller_test.exs +++ b/test/mobilizon_web/controllers/activity_pub_controller_test.exs @@ -4,16 +4,20 @@ # Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/test/web/web_finger/web_finger_controller_test.exs defmodule MobilizonWeb.ActivityPubControllerTest do + use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + use MobilizonWeb.ConnCase + import Mobilizon.Factory - alias MobilizonWeb.ActivityPub.ActorView - alias MobilizonWeb.PageView + alias Mobilizon.{Actors, Config} alias Mobilizon.Actors.Actor alias Mobilizon.Service.ActivityPub - use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney - alias MobilizonWeb.Router.Helpers, as: Routes + + alias MobilizonWeb.ActivityPub.ActorView alias MobilizonWeb.Endpoint + alias MobilizonWeb.PageView + alias MobilizonWeb.Router.Helpers, as: Routes setup do conn = build_conn() |> put_req_header("accept", "application/activity+json") diff --git a/test/mobilizon_web/controllers/feed_controller_test.exs b/test/mobilizon_web/controllers/feed_controller_test.exs index 0851b40ce..d793586b3 100644 --- a/test/mobilizon_web/controllers/feed_controller_test.exs +++ b/test/mobilizon_web/controllers/feed_controller_test.exs @@ -1,8 +1,10 @@ defmodule MobilizonWeb.FeedControllerTest do use MobilizonWeb.ConnCase + import Mobilizon.Factory - alias MobilizonWeb.Router.Helpers, as: Routes + alias MobilizonWeb.Endpoint + alias MobilizonWeb.Router.Helpers, as: Routes describe "/@:preferred_username/feed/atom" do test "it returns an RSS representation of the actor's public events if the actor is publicly visible", diff --git a/test/mobilizon_web/controllers/page_controller_test.exs b/test/mobilizon_web/controllers/page_controller_test.exs index 477a11d25..9077a7af2 100644 --- a/test/mobilizon_web/controllers/page_controller_test.exs +++ b/test/mobilizon_web/controllers/page_controller_test.exs @@ -1,9 +1,12 @@ defmodule MobilizonWeb.PageControllerTest do use MobilizonWeb.ConnCase + import Mobilizon.Factory + alias Mobilizon.Actors.Actor - alias MobilizonWeb.Router.Helpers, as: Routes + alias MobilizonWeb.Endpoint + alias MobilizonWeb.Router.Helpers, as: Routes setup do conn = build_conn() |> put_req_header("accept", "text/html") diff --git a/test/mobilizon_web/resolvers/admin_resolver_test.exs b/test/mobilizon_web/resolvers/admin_resolver_test.exs index a1452d488..5078f28bf 100644 --- a/test/mobilizon_web/resolvers/admin_resolver_test.exs +++ b/test/mobilizon_web/resolvers/admin_resolver_test.exs @@ -1,12 +1,14 @@ defmodule MobilizonWeb.Resolvers.AdminResolverTest do - alias MobilizonWeb.AbsintheHelpers use MobilizonWeb.ConnCase + import Mobilizon.Factory - alias Mobilizon.Events.Event alias Mobilizon.Actors.Actor + alias Mobilizon.Events.Event + alias Mobilizon.Reports.{Note, Report} alias Mobilizon.Users.User - alias Mobilizon.Reports.{Report, Note} + + alias MobilizonWeb.AbsintheHelpers describe "Resolver: List the action logs" do @note_content "This a note on a report" diff --git a/test/mobilizon_web/resolvers/report_resolver_test.exs b/test/mobilizon_web/resolvers/report_resolver_test.exs index 5a4c24a7a..b66f111ef 100644 --- a/test/mobilizon_web/resolvers/report_resolver_test.exs +++ b/test/mobilizon_web/resolvers/report_resolver_test.exs @@ -1,12 +1,14 @@ defmodule MobilizonWeb.Resolvers.ReportResolverTest do - alias MobilizonWeb.AbsintheHelpers use MobilizonWeb.ConnCase + import Mobilizon.Factory alias Mobilizon.Actors.Actor - alias Mobilizon.Users.User alias Mobilizon.Events.Event - alias Mobilizon.Reports.{Report, Note} + alias Mobilizon.Reports.{Note, Report} + alias Mobilizon.Users.User + + alias MobilizonWeb.AbsintheHelpers describe "Resolver: Report a content" do test "create_report/3 creates a report", %{conn: conn} do diff --git a/test/mobilizon_web/resolvers/user_resolver_test.exs b/test/mobilizon_web/resolvers/user_resolver_test.exs index fa8a662e7..338de03c4 100644 --- a/test/mobilizon_web/resolvers/user_resolver_test.exs +++ b/test/mobilizon_web/resolvers/user_resolver_test.exs @@ -9,8 +9,8 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do alias Mobilizon.{Actors, Config, Users} alias Mobilizon.Actors.Actor alias Mobilizon.Service.Users.ResetPassword - alias Mobilizon.Users.User alias Mobilizon.Users + alias Mobilizon.Users.User alias MobilizonWeb.{AbsintheHelpers, Email} diff --git a/test/mobilizon_web/upload_test.exs b/test/mobilizon_web/upload_test.exs index de41d172f..907d6800b 100644 --- a/test/mobilizon_web/upload_test.exs +++ b/test/mobilizon_web/upload_test.exs @@ -198,7 +198,7 @@ defmodule Mobilizon.UploadTest do end end - defp upload() do + defp upload do File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") file = %Plug.Upload{ diff --git a/test/support/factory.ex b/test/support/factory.ex index a11634d39..c866ca6c4 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -8,8 +8,8 @@ defmodule Mobilizon.Factory do alias Mobilizon.Actors.Actor alias Mobilizon.Crypto - alias MobilizonWeb.Router.Helpers, as: Routes alias MobilizonWeb.Endpoint + alias MobilizonWeb.Router.Helpers, as: Routes alias MobilizonWeb.Upload def user_factory do diff --git a/test/support/mocks/geospatial_mock.ex b/test/support/mocks/geospatial_mock.ex index f5a3de8b4..870047466 100644 --- a/test/support/mocks/geospatial_mock.ex +++ b/test/support/mocks/geospatial_mock.ex @@ -1,9 +1,10 @@ defmodule Mobilizon.Service.Geospatial.Mock do @moduledoc """ - Mock for Geospatial Provider implementations + Mock for Geospatial Provider implementations. """ - alias Mobilizon.Service.Geospatial.Provider + alias Mobilizon.Addresses.Address + alias Mobilizon.Service.Geospatial.Provider @behaviour Provider diff --git a/test/tasks/relay_test.exs b/test/tasks/relay_test.exs index c93e8ad47..26ee7cb2c 100644 --- a/test/tasks/relay_test.exs +++ b/test/tasks/relay_test.exs @@ -3,12 +3,14 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Mix.Tasks.Mobilizon.RelayTest do - alias Mobilizon.Actors.{Actor, Follower} - alias Mobilizon.Actors - alias Mobilizon.Service.ActivityPub.Relay - use Mobilizon.DataCase use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + use Mobilizon.DataCase + + alias Mobilizon.Actors + alias Mobilizon.Actors.{Actor, Follower} + alias Mobilizon.Service.ActivityPub.Relay + describe "running follow" do test "relay is followed" do use_cassette "relay/fetch_relay_follow" do