Introduce comments below events

Also add tomstones

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-11-15 18:36:47 +01:00
parent 45155a3bde
commit dc07f34d78
71 changed files with 2642 additions and 879 deletions

View File

@@ -5,7 +5,7 @@ defmodule MobilizonWeb.Schema.AdminType do
use Absinthe.Schema.Notation
alias Mobilizon.Events.Event
alias Mobilizon.Events.{Event, Comment}
alias Mobilizon.Reports.{Note, Report}
alias MobilizonWeb.Resolvers.Admin
@@ -26,6 +26,7 @@ defmodule MobilizonWeb.Schema.AdminType do
value(:note_creation)
value(:note_deletion)
value(:event_deletion)
value(:comment_deletion)
value(:event_update)
end
@@ -43,6 +44,9 @@ defmodule MobilizonWeb.Schema.AdminType do
%Event{}, _ ->
:event
%Comment{}, _ ->
:comment
_, _ ->
nil
end)

View File

@@ -4,9 +4,12 @@ defmodule MobilizonWeb.Schema.CommentType do
"""
use Absinthe.Schema.Notation
alias MobilizonWeb.Resolvers.Comment
alias Mobilizon.{Actors, Events}
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
@desc "A comment"
object :comment do
interfaces([:action_log_object])
field(:id, :id, description: "Internal ID for this comment")
field(:uuid, :uuid)
field(:url, :string)
@@ -14,8 +17,20 @@ defmodule MobilizonWeb.Schema.CommentType do
field(:visibility, :comment_visibility)
field(:text, :string)
field(:primaryLanguage, :string)
field(:replies, list_of(:comment))
field(:replies, list_of(:comment)) do
resolve(dataloader(Events))
end
field(:total_replies, :integer)
field(:in_reply_to_comment, :comment, resolve: dataloader(Events))
field(:event, :event, resolve: dataloader(Events))
field(:origin_comment, :comment, resolve: dataloader(Events))
field(:threadLanguages, non_null(list_of(:string)))
field(:actor, :person, resolve: dataloader(Actors))
field(:inserted_at, :datetime)
field(:updated_at, :datetime)
field(:deleted_at, :datetime)
end
@desc "The list of visibility options for a comment"
@@ -31,13 +46,30 @@ defmodule MobilizonWeb.Schema.CommentType do
value(:invite, description: "visible only to people invited")
end
object :comment_queries do
@desc "Get replies for thread"
field :thread, type: list_of(:comment) do
arg(:id, :id)
resolve(&Comment.get_thread/3)
end
end
object :comment_mutations do
@desc "Create a comment"
field :create_comment, type: :comment do
arg(:text, non_null(:string))
arg(:event_id, :id)
arg(:in_reply_to_comment_id, :id)
arg(:actor_id, non_null(:id))
resolve(&Comment.create_comment/3)
end
field :delete_comment, type: :comment do
arg(:comment_id, non_null(:id))
arg(:actor_id, non_null(:id))
resolve(&Comment.delete_comment/3)
end
end
end

View File

@@ -8,7 +8,7 @@ defmodule MobilizonWeb.Schema.EventType do
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
import MobilizonWeb.Schema.Utils
alias Mobilizon.{Actors, Addresses}
alias Mobilizon.{Actors, Addresses, Events}
alias MobilizonWeb.Resolvers.{Event, Picture, Tag}
@@ -78,6 +78,10 @@ defmodule MobilizonWeb.Schema.EventType do
description: "Events related to this one"
)
field(:comments, list_of(:comment), description: "The comments in reply to the event") do
resolve(dataloader(Events))
end
# field(:tracks, list_of(:track))
# field(:sessions, list_of(:session))

View File

@@ -71,8 +71,8 @@ defmodule MobilizonWeb.Schema.ReportType do
@desc "Create a report"
field :create_report, type: :report do
arg(:content, :string)
arg(:reporter_actor_id, non_null(:id))
arg(:reported_actor_id, non_null(:id))
arg(:reporter_id, non_null(:id))
arg(:reported_id, non_null(:id))
arg(:event_id, :id, default_value: nil)
arg(:comments_ids, list_of(:id), default_value: [])
resolve(&Report.create_report/3)