Remove unused functions

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-10-05 15:29:06 +02:00
parent 5d8d2e80a5
commit f4284e1d3a
41 changed files with 114 additions and 714 deletions

View File

@@ -29,9 +29,9 @@ defmodule Mobilizon.GraphQL.API.Events do
@doc """
Trigger the deletion of an event
"""
@spec delete_event(Event.t(), Actor.t(), boolean()) :: {:ok, Activity.t(), Entity.t()} | any()
def delete_event(%Event{} = event, %Actor{} = actor, federate \\ true) do
Actions.Delete.delete(event, actor, federate)
@spec delete_event(Event.t(), Actor.t()) :: {:ok, Activity.t(), Entity.t()} | any()
def delete_event(%Event{} = event, %Actor{} = actor) do
Actions.Delete.delete(event, actor, true)
end
@spec prepare_args(map) :: map

View File

@@ -3,7 +3,7 @@ defmodule Mobilizon.GraphQL.API.Utils do
Utils for API.
"""
alias Mobilizon.{Config, Medias}
alias Mobilizon.Medias
alias Mobilizon.Medias.Media
alias Mobilizon.Service.Formatter
@@ -30,18 +30,6 @@ defmodule Mobilizon.GraphQL.API.Utils do
|> Formatter.linkify(options)
end
def make_report_content_text(nil), do: {:ok, nil}
def make_report_content_text(comment) do
max_size = Config.get([:instance, :max_report_comment_size], 1000)
if String.length(comment) <= max_size do
{:ok, Formatter.html_escape(comment, "text/plain")}
else
{:error, "Comment must be up to #{max_size} characters"}
end
end
@doc """
Use the data-media-id attributes to extract media from body text
"""

View File

@@ -89,7 +89,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Comment do
end
end
def edit_comment(_parent, _args, _context) do
def update_comment(_parent, _args, _context) do
{:error, dgettext("errors", "You are not allowed to update a comment if not connected")}
end

View File

@@ -21,17 +21,17 @@ defmodule Mobilizon.GraphQL.Resolvers.Todos do
{:ok, Page.t(TodoList.t())}
def find_todo_lists_for_group(
%Actor{id: group_id} = group,
_args,
%{page: page, limit: limit},
%{
context: %{current_actor: %Actor{id: actor_id}}
} = _resolution
) do
with {:member, true} <- {:member, Actors.is_member?(actor_id, group_id)},
%Page{} = page <- Todos.get_todo_lists_for_group(group) do
%Page{} = page <- Todos.get_todo_lists_for_group(group, page, limit) do
{:ok, page}
else
{:member, _} ->
with %Page{} = page <- Todos.get_todo_lists_for_group(group) do
with %Page{} = page <- Todos.get_todo_lists_for_group(group, page, limit) do
{:ok, %Page{page | elements: []}}
end
end
@@ -41,17 +41,17 @@ defmodule Mobilizon.GraphQL.Resolvers.Todos do
{:ok, %Page{total: 0, elements: []}}
end
@spec find_todo_lists_for_group(TodoList.t(), map(), Absinthe.Resolution.t()) ::
@spec find_todos_for_todo_list(TodoList.t(), map(), Absinthe.Resolution.t()) ::
{:ok, Page.t(Todo.t())} | {:error, String.t()}
def find_todos_for_todo_list(
%TodoList{actor_id: group_id} = todo_list,
_args,
%{page: page, limit: limit},
%{
context: %{current_actor: %Actor{id: actor_id}}
} = _resolution
) do
with {:member, true} <- {:member, Actors.is_member?(actor_id, group_id)},
%Page{} = page <- Todos.get_todos_for_todo_list(todo_list) do
%Page{} = page <- Todos.get_todos_for_todo_list(todo_list, page, limit) do
{:ok, page}
else
{:member, _} ->

View File

@@ -129,6 +129,12 @@ defmodule Mobilizon.GraphQL.Schema.Actors.GroupType do
end
field :todo_lists, :paginated_todo_list_list do
arg(:page, :integer,
default_value: 1,
description: "The page in the paginated todo-lists list"
)
arg(:limit, :integer, default_value: 10, description: "The limit of todo-lists per page")
resolve(&Todos.find_todo_lists_for_group/3)
description("A paginated list of the todo lists this group has")
end

View File

@@ -17,10 +17,20 @@ defmodule Mobilizon.GraphQL.Schema.Todos.TodoListType do
description: "The actor that owns this todo list"
)
field(:todos, :paginated_todo_list,
resolve: &Todos.find_todos_for_todo_list/3,
description: "The todo-list's todos"
)
field :todos, :paginated_todo_list do
arg(:page, :integer,
default_value: 1,
description: "The page in the paginated todos list"
)
arg(:limit, :integer,
default_value: 10,
description: "The limit of todos per page"
)
resolve(&Todos.find_todos_for_todo_list/3)
description("The todo-list's todos")
end
end
@desc """