Add Credo checks and refactor code
Signed-off-by: Thomas Citharel <tcit@tcit.fr> Make Logger.debug calls lazy Signed-off-by: Thomas Citharel <tcit@tcit.fr> Add missing @moduledocs Signed-off-by: Thomas Citharel <tcit@tcit.fr> Refactor according to credo Signed-off-by: Thomas Citharel <tcit@tcit.fr> Final fixes and add credo to CI Signed-off-by: Thomas Citharel <tcit@tcit.fr> Closes #52
This commit is contained in:
@@ -17,13 +17,18 @@ defmodule MobilizonWeb.API.Comments do
|
||||
Creates a comment from an actor and a status
|
||||
"""
|
||||
@spec create_comment(String.t(), String.t(), String.t()) :: {:ok, Activity.t()} | any()
|
||||
def create_comment(from_username, status, visibility \\ "public", inReplyToCommentURL \\ nil) do
|
||||
def create_comment(
|
||||
from_username,
|
||||
status,
|
||||
visibility \\ "public",
|
||||
in_reply_to_comment_URL \\ nil
|
||||
) do
|
||||
with {:local_actor, %Actor{url: url} = actor} <-
|
||||
{:local_actor, Actors.get_local_actor_by_name(from_username)},
|
||||
status <- String.trim(status),
|
||||
mentions <- Formatter.parse_mentions(status),
|
||||
inReplyToComment <- get_in_reply_to_comment(inReplyToCommentURL),
|
||||
{to, cc} <- to_for_actor_and_mentions(actor, mentions, inReplyToComment, visibility),
|
||||
in_reply_to_comment <- get_in_reply_to_comment(in_reply_to_comment_URL),
|
||||
{to, cc} <- to_for_actor_and_mentions(actor, mentions, in_reply_to_comment, visibility),
|
||||
tags <- Formatter.parse_tags(status),
|
||||
content_html <-
|
||||
make_content_html(
|
||||
@@ -37,7 +42,7 @@ defmodule MobilizonWeb.API.Comments do
|
||||
url,
|
||||
to,
|
||||
content_html,
|
||||
inReplyToComment,
|
||||
in_reply_to_comment,
|
||||
tags,
|
||||
cc
|
||||
) do
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule MobilizonWeb.Context do
|
||||
@moduledoc """
|
||||
Guardian context for MobilizonWeb
|
||||
"""
|
||||
@behaviour Plug
|
||||
|
||||
import Plug.Conn
|
||||
|
||||
@@ -23,14 +23,12 @@ defmodule MobilizonWeb.ActivityPubController do
|
||||
|
||||
def actor(conn, %{"name" => name}) do
|
||||
with %Actor{} = actor <- Actors.get_local_actor_by_name(name) do
|
||||
cond do
|
||||
conn |> get_req_header("accept") |> is_ap_header() ->
|
||||
conn |> render_ap_actor(actor)
|
||||
|
||||
true ->
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|> send_file(200, "priv/static/index.html")
|
||||
if conn |> get_req_header("accept") |> is_ap_header() do
|
||||
conn |> render_ap_actor(actor)
|
||||
else
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|> send_file(200, "priv/static/index.html")
|
||||
end
|
||||
else
|
||||
nil -> {:error, :not_found}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule MobilizonWeb.Resolvers.Category do
|
||||
@moduledoc """
|
||||
Handles the category-related GraphQL calls
|
||||
"""
|
||||
require Logger
|
||||
alias Mobilizon.Actors.User
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule MobilizonWeb.Resolvers.Comment do
|
||||
@moduledoc """
|
||||
Handles the comment-related GraphQL calls
|
||||
"""
|
||||
require Logger
|
||||
alias Mobilizon.Events.Comment
|
||||
alias Mobilizon.Activity
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule MobilizonWeb.Resolvers.Event do
|
||||
@moduledoc """
|
||||
Handles the event-related GraphQL calls
|
||||
"""
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Activity
|
||||
alias Mobilizon.Actors
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule MobilizonWeb.Resolvers.Group do
|
||||
@moduledoc """
|
||||
Handles the group-related GraphQL calls
|
||||
"""
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.{Actor}
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule MobilizonWeb.Resolvers.Person do
|
||||
@moduledoc """
|
||||
Handles the person-related GraphQL calls
|
||||
"""
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
defmodule MobilizonWeb.Resolvers.Upload do
|
||||
end
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule MobilizonWeb.Resolvers.User do
|
||||
@moduledoc """
|
||||
Handles the user-related GraphQL calls
|
||||
"""
|
||||
alias Mobilizon.Actors.{User, Actor}
|
||||
alias Mobilizon.Actors
|
||||
require Logger
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule MobilizonWeb.Schema do
|
||||
@moduledoc """
|
||||
GraphQL schema representation
|
||||
"""
|
||||
use Absinthe.Schema
|
||||
|
||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule MobilizonWeb.UploadPlug do
|
||||
@moduledoc """
|
||||
Plug to intercept uploads
|
||||
"""
|
||||
use Plug.Builder
|
||||
|
||||
plug(Plug.Static,
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule MobilizonWeb.Uploaders.Avatar do
|
||||
@moduledoc """
|
||||
Handles avatar uploads
|
||||
"""
|
||||
use Arc.Definition
|
||||
|
||||
# Include ecto support (requires package arc_ecto installed):
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule MobilizonWeb.Uploaders.Category do
|
||||
@moduledoc """
|
||||
Handles file uploads for categories
|
||||
"""
|
||||
use Arc.Definition
|
||||
use Arc.Ecto.Definition
|
||||
|
||||
|
||||
Reference in New Issue
Block a user