diff --git a/lib/federation/activity_pub/activity_pub.ex b/lib/federation/activity_pub/activity_pub.ex
index 2bf6edefb..b6257e71d 100644
--- a/lib/federation/activity_pub/activity_pub.ex
+++ b/lib/federation/activity_pub/activity_pub.ex
@@ -30,7 +30,8 @@ defmodule Mobilizon.Federation.ActivityPub do
alias Mobilizon.Federation.HTTPSignatures.Signature
alias Mobilizon.Federation.WebFinger
- alias MobilizonWeb.API.Utils, as: APIUtils
+ alias Mobilizon.GraphQL.API.Utils, as: APIUtils
+
alias MobilizonWeb.Email.{Admin, Mailer}
require Logger
diff --git a/lib/federation/activity_pub/relay.ex b/lib/federation/activity_pub/relay.ex
index 6a0fec7ef..f940f2359 100644
--- a/lib/federation/activity_pub/relay.ex
+++ b/lib/federation/activity_pub/relay.ex
@@ -15,7 +15,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
alias Mobilizon.Federation.ActivityPub.{Activity, Transmogrifier}
alias Mobilizon.Federation.WebFinger
- alias MobilizonWeb.API.Follows
+ alias Mobilizon.GraphQL.API.Follows
require Logger
diff --git a/lib/mobilizon_web/api/comments.ex b/lib/graphql/api/comments.ex
similarity index 69%
rename from lib/mobilizon_web/api/comments.ex
rename to lib/graphql/api/comments.ex
index 24fe79771..18bd7ea3c 100644
--- a/lib/mobilizon_web/api/comments.ex
+++ b/lib/graphql/api/comments.ex
@@ -1,7 +1,8 @@
-defmodule MobilizonWeb.API.Comments do
+defmodule Mobilizon.GraphQL.API.Comments do
@moduledoc """
API for Comments.
"""
+
alias Mobilizon.Events.Comment
alias Mobilizon.Federation.ActivityPub
@@ -12,8 +13,7 @@ defmodule MobilizonWeb.API.Comments do
Creates a comment from an actor
"""
- @spec create_comment(map()) ::
- {:ok, Activity.t(), Comment.t()} | any()
+ @spec create_comment(map) :: {:ok, Activity.t(), Comment.t()} | any
def create_comment(args) do
ActivityPub.create(:comment, args, true)
end
@@ -23,8 +23,7 @@ defmodule MobilizonWeb.API.Comments do
Deletes a comment from an actor
"""
- @spec delete_comment(Comment.t()) ::
- {:ok, Activity.t(), Comment.t()} | any()
+ @spec delete_comment(Comment.t()) :: {:ok, Activity.t(), Comment.t()} | any
def delete_comment(%Comment{} = comment) do
ActivityPub.delete(comment, true)
end
diff --git a/lib/mobilizon_web/api/events.ex b/lib/graphql/api/events.ex
similarity index 89%
rename from lib/mobilizon_web/api/events.ex
rename to lib/graphql/api/events.ex
index b3a7b58bf..fdbb92ae8 100644
--- a/lib/mobilizon_web/api/events.ex
+++ b/lib/graphql/api/events.ex
@@ -1,4 +1,4 @@
-defmodule MobilizonWeb.API.Events do
+defmodule Mobilizon.GraphQL.API.Events do
@moduledoc """
API for Events.
"""
@@ -12,7 +12,7 @@ defmodule MobilizonWeb.API.Events do
@doc """
Create an event
"""
- @spec create_event(map()) :: {:ok, Activity.t(), Event.t()} | any()
+ @spec create_event(map) :: {:ok, Activity.t(), Event.t()} | any
def create_event(args) do
with organizer_actor <- Map.get(args, :organizer_actor),
args <-
@@ -27,7 +27,7 @@ defmodule MobilizonWeb.API.Events do
@doc """
Update an event
"""
- @spec update_event(map(), Event.t()) :: {:ok, Activity.t(), Event.t()} | any()
+ @spec update_event(map, Event.t()) :: {:ok, Activity.t(), Event.t()} | any
def update_event(args, %Event{} = event) do
with organizer_actor <- Map.get(args, :organizer_actor),
args <-
diff --git a/lib/mobilizon_web/api/follows.ex b/lib/graphql/api/follows.ex
similarity index 97%
rename from lib/mobilizon_web/api/follows.ex
rename to lib/graphql/api/follows.ex
index ca4e11af2..1796c80d8 100644
--- a/lib/mobilizon_web/api/follows.ex
+++ b/lib/graphql/api/follows.ex
@@ -1,4 +1,4 @@
-defmodule MobilizonWeb.API.Follows do
+defmodule Mobilizon.GraphQL.API.Follows do
@moduledoc """
Common API for following, unfollowing, accepting and rejecting stuff.
"""
diff --git a/lib/mobilizon_web/api/groups.ex b/lib/graphql/api/groups.ex
similarity index 89%
rename from lib/mobilizon_web/api/groups.ex
rename to lib/graphql/api/groups.ex
index b8747a8cc..4ff5371c1 100644
--- a/lib/mobilizon_web/api/groups.ex
+++ b/lib/graphql/api/groups.ex
@@ -1,4 +1,4 @@
-defmodule MobilizonWeb.API.Groups do
+defmodule Mobilizon.GraphQL.API.Groups do
@moduledoc """
API for Groups.
"""
@@ -12,7 +12,7 @@ defmodule MobilizonWeb.API.Groups do
@doc """
Create a group
"""
- @spec create_group(map()) :: {:ok, Activity.t(), Actor.t()} | any()
+ @spec create_group(map) :: {:ok, Activity.t(), Actor.t()} | any
def create_group(args) do
with preferred_username <-
args |> Map.get(:preferred_username) |> HtmlSanitizeEx.strip_tags() |> String.trim(),
diff --git a/lib/mobilizon_web/api/participations.ex b/lib/graphql/api/participations.ex
similarity index 91%
rename from lib/mobilizon_web/api/participations.ex
rename to lib/graphql/api/participations.ex
index 4c53d5005..a280d7fcd 100644
--- a/lib/mobilizon_web/api/participations.ex
+++ b/lib/graphql/api/participations.ex
@@ -1,4 +1,4 @@
-defmodule MobilizonWeb.API.Participations do
+defmodule Mobilizon.GraphQL.API.Participations do
@moduledoc """
Common API to join events and groups.
"""
@@ -27,11 +27,13 @@ defmodule MobilizonWeb.API.Participations do
@doc """
Update participation status
"""
- def update(%Participant{} = participation, %Actor{} = moderator, :participant),
- do: accept(participation, moderator)
+ def update(%Participant{} = participation, %Actor{} = moderator, :participant) do
+ accept(participation, moderator)
+ end
- def update(%Participant{} = participation, %Actor{} = moderator, :rejected),
- do: reject(participation, moderator)
+ def update(%Participant{} = participation, %Actor{} = moderator, :rejected) do
+ reject(participation, moderator)
+ end
defp accept(
%Participant{} = participation,
diff --git a/lib/mobilizon_web/api/reports.ex b/lib/graphql/api/reports.ex
similarity index 98%
rename from lib/mobilizon_web/api/reports.ex
rename to lib/graphql/api/reports.ex
index 2281f47e4..e56547654 100644
--- a/lib/mobilizon_web/api/reports.ex
+++ b/lib/graphql/api/reports.ex
@@ -1,4 +1,4 @@
-defmodule MobilizonWeb.API.Reports do
+defmodule Mobilizon.GraphQL.API.Reports do
@moduledoc """
API for Reports.
"""
diff --git a/lib/mobilizon_web/api/search.ex b/lib/graphql/api/search.ex
similarity index 98%
rename from lib/mobilizon_web/api/search.ex
rename to lib/graphql/api/search.ex
index 7cb2d600d..343d179bf 100644
--- a/lib/mobilizon_web/api/search.ex
+++ b/lib/graphql/api/search.ex
@@ -1,4 +1,4 @@
-defmodule MobilizonWeb.API.Search do
+defmodule Mobilizon.GraphQL.API.Search do
@moduledoc """
API for search.
"""
diff --git a/lib/mobilizon_web/api/utils.ex b/lib/graphql/api/utils.ex
similarity index 80%
rename from lib/mobilizon_web/api/utils.ex
rename to lib/graphql/api/utils.ex
index c785b389f..1ff7e3282 100644
--- a/lib/mobilizon_web/api/utils.ex
+++ b/lib/graphql/api/utils.ex
@@ -1,4 +1,4 @@
-defmodule MobilizonWeb.API.Utils do
+defmodule Mobilizon.GraphQL.API.Utils do
@moduledoc """
Utils for API.
"""
@@ -10,11 +10,7 @@ defmodule MobilizonWeb.API.Utils do
Creates HTML content from text and mentions
"""
@spec make_content_html(String.t(), list(), String.t()) :: String.t()
- def make_content_html(
- text,
- additional_tags,
- content_type
- ) do
+ def make_content_html(text, additional_tags, content_type) do
with {text, mentions, tags} <- format_input(text, content_type, []) do
{text, mentions, additional_tags ++ Enum.map(tags, fn {_, tag} -> tag end)}
end
@@ -24,9 +20,7 @@ defmodule MobilizonWeb.API.Utils do
text
|> Formatter.html_escape("text/plain")
|> Formatter.linkify(options)
- |> (fn {text, mentions, tags} ->
- {String.replace(text, ~r/\r?\n/, "
"), mentions, tags}
- end).()
+ |> (fn {text, mentions, tags} -> {String.replace(text, ~r/\r?\n/, "
"), mentions, tags} end).()
end
def format_input(text, "text/html", options) do
diff --git a/lib/graphql/resolvers/comment.ex b/lib/graphql/resolvers/comment.ex
index 002e1f7d3..4779468a1 100644
--- a/lib/graphql/resolvers/comment.ex
+++ b/lib/graphql/resolvers/comment.ex
@@ -9,7 +9,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Comment do
alias Mobilizon.Events.Comment, as: CommentModel
alias Mobilizon.Users.User
- alias MobilizonWeb.API.Comments
+ alias Mobilizon.GraphQL.API.Comments
require Logger
diff --git a/lib/graphql/resolvers/event.ex b/lib/graphql/resolvers/event.ex
index a502e1cfe..8864091c5 100644
--- a/lib/graphql/resolvers/event.ex
+++ b/lib/graphql/resolvers/event.ex
@@ -8,12 +8,11 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
alias Mobilizon.Events.{Event, Participant, EventParticipantStats}
alias Mobilizon.Users.User
+ alias Mobilizon.GraphQL.API
alias Mobilizon.GraphQL.Resolvers.Person
alias Mobilizon.Federation.ActivityPub.Activity
- alias MobilizonWeb.API
-
# We limit the max number of events that can be retrieved
@event_max_limit 100
@number_of_related_events 3
@@ -231,7 +230,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
{:actor_approve_permission,
Mobilizon.Events.moderator_for_event?(participation.event.id, moderator_actor_id)},
{:ok, _activity, participation} <-
- MobilizonWeb.API.Participations.update(participation, moderator_actor, new_role) do
+ API.Participations.update(participation, moderator_actor, new_role) do
{:ok, participation}
else
{:is_owned, nil} ->
@@ -268,7 +267,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
{:is_owned, %Actor{} = organizer_actor} <- User.owns_actor(user, organizer_actor_id),
args_with_organizer <- Map.put(args, :organizer_actor, organizer_actor),
{:ok, %Activity{data: %{"object" => %{"type" => "Event"}}}, %Event{} = event} <-
- MobilizonWeb.API.Events.create_event(args_with_organizer) do
+ API.Events.create_event(args_with_organizer) do
{:ok, event}
else
{:is_owned, nil} ->
@@ -302,7 +301,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
User.owns_actor(user, organizer_actor_id),
args <- Map.put(args, :organizer_actor, organizer_actor),
{:ok, %Activity{data: %{"object" => %{"type" => "Event"}}}, %Event{} = event} <-
- MobilizonWeb.API.Events.update_event(args, event) do
+ API.Events.update_event(args, event) do
{:ok, event}
else
{:error, :event_not_found} ->
@@ -360,7 +359,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
end
defp do_delete_event(event, federate \\ true) when is_boolean(federate) do
- with {:ok, _activity, event} <- MobilizonWeb.API.Events.delete_event(event) do
+ with {:ok, _activity, event} <- API.Events.delete_event(event) do
{:ok, %{id: event.id}}
end
end
diff --git a/lib/graphql/resolvers/group.ex b/lib/graphql/resolvers/group.ex
index c2ff0409d..99ab2abb7 100644
--- a/lib/graphql/resolvers/group.ex
+++ b/lib/graphql/resolvers/group.ex
@@ -7,12 +7,11 @@ defmodule Mobilizon.GraphQL.Resolvers.Group do
alias Mobilizon.Actors.{Actor, Member}
alias Mobilizon.Users.User
+ alias Mobilizon.GraphQL.API
alias Mobilizon.GraphQL.Resolvers.Person
alias Mobilizon.Federation.ActivityPub
- alias MobilizonWeb.API
-
require Logger
@doc """
diff --git a/lib/graphql/resolvers/member.ex b/lib/graphql/resolvers/member.ex
index 65cdd249c..fffe483d9 100644
--- a/lib/graphql/resolvers/member.ex
+++ b/lib/graphql/resolvers/member.ex
@@ -2,6 +2,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Member do
@moduledoc """
Handles the member-related GraphQL calls
"""
+
alias Mobilizon.Actors
alias Mobilizon.Actors.{Actor}
diff --git a/lib/graphql/resolvers/picture.ex b/lib/graphql/resolvers/picture.ex
index 941ef6fd7..d8f4ce72c 100644
--- a/lib/graphql/resolvers/picture.ex
+++ b/lib/graphql/resolvers/picture.ex
@@ -2,6 +2,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Picture do
@moduledoc """
Handles the picture-related GraphQL calls
"""
+
alias Mobilizon.Actors.Actor
alias Mobilizon.Media
alias Mobilizon.Media.Picture
diff --git a/lib/graphql/resolvers/report.ex b/lib/graphql/resolvers/report.ex
index e8b78199c..6e07b10bf 100644
--- a/lib/graphql/resolvers/report.ex
+++ b/lib/graphql/resolvers/report.ex
@@ -11,7 +11,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Report do
alias Mobilizon.Reports.{Note, Report}
alias Mobilizon.Users.User
- alias MobilizonWeb.API.Reports, as: ReportsAPI
+ alias Mobilizon.GraphQL.API
def list_reports(
_parent,
@@ -50,7 +50,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Report do
%{context: %{current_user: user}} = _resolution
) do
with {:is_owned, %Actor{}} <- User.owns_actor(user, reporter_id),
- {:ok, _, %Report{} = report} <- ReportsAPI.report(args) do
+ {:ok, _, %Report{} = report} <- API.Reports.report(args) do
{:ok, report}
else
{:is_owned, nil} ->
@@ -76,8 +76,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Report do
when is_moderator(role) do
with {:is_owned, %Actor{} = actor} <- User.owns_actor(user, moderator_id),
%Report{} = report <- Mobilizon.Reports.get_report(report_id),
- {:ok, %Report{} = report} <-
- MobilizonWeb.API.Reports.update_report_status(actor, report, status) do
+ {:ok, %Report{} = report} <- API.Reports.update_report_status(actor, report, status) do
{:ok, report}
else
{:is_owned, nil} ->
@@ -101,8 +100,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Report do
with {:is_owned, %Actor{}} <- User.owns_actor(user, moderator_id),
%Report{} = report <- Reports.get_report(report_id),
%Actor{} = moderator <- Actors.get_local_actor_with_preload(moderator_id),
- {:ok, %Note{} = note} <-
- MobilizonWeb.API.Reports.create_report_note(report, moderator, content) do
+ {:ok, %Note{} = note} <- API.Reports.create_report_note(report, moderator, content) do
{:ok, note}
end
end
@@ -116,8 +114,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Report do
with {:is_owned, %Actor{}} <- User.owns_actor(user, moderator_id),
%Note{} = note <- Reports.get_note(note_id),
%Actor{} = moderator <- Actors.get_local_actor_with_preload(moderator_id),
- {:ok, %Note{} = note} <-
- MobilizonWeb.API.Reports.delete_report_note(note, moderator) do
+ {:ok, %Note{} = note} <- API.Reports.delete_report_note(note, moderator) do
{:ok, %{id: note.id}}
end
end
diff --git a/lib/graphql/resolvers/search.ex b/lib/graphql/resolvers/search.ex
index acb74b963..9c33e94ee 100644
--- a/lib/graphql/resolvers/search.ex
+++ b/lib/graphql/resolvers/search.ex
@@ -2,7 +2,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Search do
@moduledoc """
Handles the event-related GraphQL calls
"""
- alias MobilizonWeb.API.Search
+
+ alias Mobilizon.GraphQL.API.Search
@doc """
Search persons
diff --git a/lib/graphql/resolvers/tag.ex b/lib/graphql/resolvers/tag.ex
index b7a5dd117..a21eb7420 100644
--- a/lib/graphql/resolvers/tag.ex
+++ b/lib/graphql/resolvers/tag.ex
@@ -2,6 +2,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Tag do
@moduledoc """
Handles the tag-related GraphQL calls
"""
+
alias Mobilizon.Events
alias Mobilizon.Events.{Event, Tag}
diff --git a/lib/mix/tasks/mobilizon/move_participant_stats.ex b/lib/mix/tasks/mobilizon/move_participant_stats.ex
index 6ecba7e28..5c31be348 100644
--- a/lib/mix/tasks/mobilizon/move_participant_stats.ex
+++ b/lib/mix/tasks/mobilizon/move_participant_stats.ex
@@ -7,11 +7,12 @@ defmodule Mix.Tasks.Mobilizon.MoveParticipantStats do
use Mix.Task
- alias Mobilizon.Storage.Repo
+ import Ecto.Query
+
alias Mobilizon.Events
alias Mobilizon.Events.Event
alias Mobilizon.Events.ParticipantRole
- import Ecto.Query
+ alias Mobilizon.Storage.Repo
require Logger
diff --git a/lib/mix/tasks/mobilizon/relay.ex b/lib/mix/tasks/mobilizon/relay.ex
index f7f0830a4..d91b20065 100644
--- a/lib/mix/tasks/mobilizon/relay.ex
+++ b/lib/mix/tasks/mobilizon/relay.ex
@@ -23,6 +23,7 @@ defmodule Mix.Tasks.Mobilizon.Relay do
use Mix.Task
alias Mix.Tasks.Mobilizon.Common
+
alias Mobilizon.Federation.ActivityPub.Relay
@shortdoc "Manages remote relays"
diff --git a/lib/mix/tasks/mobilizon/toot.ex b/lib/mix/tasks/mobilizon/toot.ex
index a8aabe23f..3473d8b56 100644
--- a/lib/mix/tasks/mobilizon/toot.ex
+++ b/lib/mix/tasks/mobilizon/toot.ex
@@ -5,10 +5,11 @@ defmodule Mix.Tasks.Mobilizon.Toot do
use Mix.Task
- alias MobilizonWeb.API.Comments
alias Mobilizon.Actors
alias Mobilizon.Actors.Actor
+ alias Mobilizon.GraphQL.API.Comments
+
require Logger
@shortdoc "Toot to an user"
diff --git a/test/federation/activity_pub/transmogrifier_test.exs b/test/federation/activity_pub/transmogrifier_test.exs
index 07065c4cc..f6730a017 100644
--- a/test/federation/activity_pub/transmogrifier_test.exs
+++ b/test/federation/activity_pub/transmogrifier_test.exs
@@ -20,7 +20,7 @@ defmodule Mobilizon.Federation.ActivityPub.TransmogrifierTest do
alias Mobilizon.Federation.ActivityPub.{Activity, Relay, Transmogrifier}
alias Mobilizon.Federation.ActivityStream.{Convertible}
- alias MobilizonWeb.API
+ alias Mobilizon.GraphQL.API
setup_all do
HTTPoison.start()
diff --git a/test/mobilizon_web/api/report_test.exs b/test/graphql/api/report_test.exs
similarity index 98%
rename from test/mobilizon_web/api/report_test.exs
rename to test/graphql/api/report_test.exs
index 03cfaa432..3ce187d40 100644
--- a/test/mobilizon_web/api/report_test.exs
+++ b/test/graphql/api/report_test.exs
@@ -1,4 +1,4 @@
-defmodule MobilizonWeb.API.ReportTest do
+defmodule Mobilizon.GraphQL.API.ReportTest do
use Mobilizon.DataCase
import Mobilizon.Factory
@@ -9,9 +9,9 @@ defmodule MobilizonWeb.API.ReportTest do
alias Mobilizon.Users
alias Mobilizon.Users.User
- alias Mobilizon.Federation.ActivityPub.{Activity, Relay}
+ alias Mobilizon.GraphQL.API.Reports
- alias MobilizonWeb.API.Reports
+ alias Mobilizon.Federation.ActivityPub.{Activity, Relay}
describe "reports" do
test "creates a report on a event" do
diff --git a/test/mobilizon_web/api/search_test.exs b/test/graphql/api/search_test.exs
similarity index 95%
rename from test/mobilizon_web/api/search_test.exs
rename to test/graphql/api/search_test.exs
index e3d800bc5..849591489 100644
--- a/test/mobilizon_web/api/search_test.exs
+++ b/test/graphql/api/search_test.exs
@@ -1,4 +1,4 @@
-defmodule MobilizonWeb.API.SearchTest do
+defmodule Mobilizon.GraphQL.API.SearchTest do
use ExUnit.Case, async: false
import Mock
@@ -9,9 +9,9 @@ defmodule MobilizonWeb.API.SearchTest do
alias Mobilizon.Events.Event
alias Mobilizon.Storage.Page
- alias Mobilizon.Federation.ActivityPub
+ alias Mobilizon.GraphQL.API.Search
- alias MobilizonWeb.API.Search
+ alias Mobilizon.Federation.ActivityPub
test "search an user by username" do
with_mock ActivityPub,
diff --git a/test/graphql/resolvers/admin_test.exs b/test/graphql/resolvers/admin_test.exs
index 7bc2d8578..a4e61fce0 100644
--- a/test/graphql/resolvers/admin_test.exs
+++ b/test/graphql/resolvers/admin_test.exs
@@ -10,8 +10,8 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
alias Mobilizon.Federation.ActivityPub.Relay
+ alias Mobilizon.GraphQL.API
alias Mobilizon.GraphQL.AbsintheHelpers
- alias MobilizonWeb.API
describe "Resolver: List the action logs" do
@note_content "This a note on a report"