mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-23 08:22:50 +00:00
c689406114
Mobilizon.Actors.User -> Mobilizon.Users.User Also Mobilizon.Actors.Service now become Mobilizon.User.Service And Mobilizon.Users and Mobilizon.UsersTest is introduced. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
28 lines
802 B
Elixir
28 lines
802 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}}} <-
|
|
Comments.create_comment(username, comment) do
|
|
{:ok,
|
|
%Comment{
|
|
text: object["content"],
|
|
url: object["id"],
|
|
uuid: object["uuid"]
|
|
}}
|
|
end
|
|
end
|
|
|
|
def create_comment(_parent, _args, %{}) do
|
|
{:error, "You are not allowed to create a comment if not connected"}
|
|
end
|
|
end
|