Fix code readability issues

This commit is contained in:
miffigriffi 2019-09-22 16:26:23 +02:00 committed by Thomas Citharel
parent 20dfce5c83
commit aed824f1aa
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
81 changed files with 379 additions and 309 deletions

View file

@ -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

View file

@ -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

View file

@ -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(

View file

@ -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()

View file

@ -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"

View file

@ -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

View file

@ -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(),

View file

@ -16,8 +16,8 @@ defmodule Mobilizon.Events.Event do
EventVisibility,
JoinOptions,
Participant,
Tag,
Session,
Tag,
Track
}

View file

@ -8,9 +8,9 @@ defmodule Mobilizon.Events.EventOptions do
import Ecto.Changeset
alias Mobilizon.Events.{
CommentModeration,
EventOffer,
EventParticipationCondition,
CommentModeration
EventParticipationCondition
}
@type t :: %__MODULE__{

View file

@ -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(),

View file

@ -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 """

View file

@ -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 """

View file

@ -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

View file

@ -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 """

View file

@ -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

View file

@ -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

View file

@ -1,6 +1,6 @@
defmodule MobilizonWeb.API.Utils do
@moduledoc """
Utils for API
Utils for API.
"""
alias Mobilizon.Actors.Actor

View file

@ -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]]

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -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 """

View file

@ -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

View file

@ -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},

View file

@ -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 """

View file

@ -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)

View file

@ -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
"""

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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}

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
"""

View file

@ -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

View file

@ -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 """

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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}

View file

@ -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}

View file

@ -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()

View file

@ -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

View file

@ -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()

View file

@ -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()

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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")

View file

@ -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",

View file

@ -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")

View file

@ -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"

View file

@ -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

View file

@ -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}

View file

@ -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{

View file

@ -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

View file

@ -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

View file

@ -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