@@ -73,7 +73,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Comment do
|
||||
) do
|
||||
with {actor_id, ""} <- Integer.parse(actor_id),
|
||||
{:is_owned, %Actor{} = _organizer_actor} <- User.owns_actor(user, actor_id),
|
||||
%CommentModel{} = comment <- Conversations.get_comment_with_preload(comment_id) do
|
||||
%CommentModel{deleted_at: nil} = comment <-
|
||||
Conversations.get_comment_with_preload(comment_id) do
|
||||
cond do
|
||||
{:comment_can_be_managed, true} == CommentModel.can_be_managed_by(comment, actor_id) ->
|
||||
do_delete_comment(comment)
|
||||
@@ -90,6 +91,9 @@ defmodule Mobilizon.GraphQL.Resolvers.Comment do
|
||||
{:error, "You cannot delete this comment"}
|
||||
end
|
||||
else
|
||||
%CommentModel{deleted_at: deleted_at} when not is_nil(deleted_at) ->
|
||||
{:error, "Comment is already deleted"}
|
||||
|
||||
{:is_owned, nil} ->
|
||||
{:error, "Actor id is not owned by authenticated user"}
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ defmodule Mobilizon.GraphQL.Schema.Conversations.CommentType do
|
||||
|
||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||
|
||||
alias Mobilizon.{Actors, Events}
|
||||
alias Mobilizon.{Actors, Conversations}
|
||||
alias Mobilizon.GraphQL.Resolvers.Comment
|
||||
|
||||
@desc "A comment"
|
||||
@@ -21,13 +21,13 @@ defmodule Mobilizon.GraphQL.Schema.Conversations.CommentType do
|
||||
field(:primaryLanguage, :string)
|
||||
|
||||
field(:replies, list_of(:comment)) do
|
||||
resolve(dataloader(Events))
|
||||
resolve(dataloader(Conversations))
|
||||
end
|
||||
|
||||
field(:total_replies, :integer)
|
||||
field(:in_reply_to_comment, :comment, resolve: dataloader(Events))
|
||||
field(:in_reply_to_comment, :comment, resolve: dataloader(Conversations))
|
||||
field(:event, :event, resolve: dataloader(Events))
|
||||
field(:origin_comment, :comment, resolve: dataloader(Events))
|
||||
field(:origin_comment, :comment, resolve: dataloader(Conversations))
|
||||
field(:threadLanguages, non_null(list_of(:string)))
|
||||
field(:actor, :person, resolve: dataloader(Actors))
|
||||
field(:inserted_at, :datetime)
|
||||
|
||||
Reference in New Issue
Block a user