mobilizon.chapril.org-mobil.../lib/mobilizon_web/resolvers/comment.ex
Thomas Citharel 5fbaf42cad
Add address input and refactor federation stuff
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2019-07-30 10:35:29 +02:00

25 lines
725 B
Elixir

defmodule MobilizonWeb.Resolvers.Comment do
@moduledoc """
Handles the comment-related GraphQL calls
"""
require Logger
alias Mobilizon.Events.Comment
alias Mobilizon.Activity
alias Mobilizon.Users.User
alias MobilizonWeb.API.Comments
def create_comment(_parent, %{text: comment, actor_username: username}, %{
context: %{current_user: %User{} = _user}
}) do
with {:ok, %Activity{data: %{"object" => %{"type" => "Note"} = _object}},
%Comment{} = comment} <-
Comments.create_comment(username, comment) do
{:ok, comment}
end
end
def create_comment(_parent, _args, %{}) do
{:error, "You are not allowed to create a comment if not connected"}
end
end