[WIP] Test transmogrifier
Introduce MobilizonWeb.API namespace Signed-off-by: Thomas Citharel <tcit@tcit.fr> Format Signed-off-by: Thomas Citharel <tcit@tcit.fr> WIP Signed-off-by: Thomas Citharel <tcit@tcit.fr> remove unneeded code Signed-off-by: Thomas Citharel <tcit@tcit.fr> Fix tests Signed-off-by: Thomas Citharel <tcit@tcit.fr> Fix warnings Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
25
lib/mobilizon_web/resolvers/comment.ex
Normal file
25
lib/mobilizon_web/resolvers/comment.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule MobilizonWeb.Resolvers.Comment do
|
||||
require Logger
|
||||
alias Mobilizon.Events.Comment
|
||||
alias Mobilizon.Activity
|
||||
alias Mobilizon.Actors.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
|
||||
Reference in New Issue
Block a user