2020-01-26 19:34:25 +00:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.ReportType do
|
2019-07-23 11:49:22 +00:00
|
|
|
@moduledoc """
|
|
|
|
Schema representation for User
|
|
|
|
"""
|
|
|
|
use Absinthe.Schema.Notation
|
2020-01-26 19:34:25 +00:00
|
|
|
|
2019-09-09 07:31:08 +00:00
|
|
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
2019-07-23 11:49:22 +00:00
|
|
|
|
2020-01-26 19:34:25 +00:00
|
|
|
alias Mobilizon.GraphQL.Resolvers.Report
|
2020-01-28 19:15:59 +00:00
|
|
|
alias Mobilizon.Reports
|
2019-07-23 11:49:22 +00:00
|
|
|
|
|
|
|
@desc "A report object"
|
|
|
|
object :report do
|
2023-03-17 17:10:59 +00:00
|
|
|
meta(:authorize, :all)
|
2019-07-23 11:49:22 +00:00
|
|
|
interfaces([:action_log_object])
|
|
|
|
field(:id, :id, description: "The internal ID of the report")
|
|
|
|
field(:content, :string, description: "The comment the reporter added about this report")
|
|
|
|
field(:status, :report_status, description: "Whether the report is still active")
|
2023-03-17 17:10:59 +00:00
|
|
|
field(:uri, :string, description: "The URI of the report", meta: [private: true])
|
2019-07-23 11:49:22 +00:00
|
|
|
field(:reported, :actor, description: "The actor that is being reported")
|
|
|
|
field(:reporter, :actor, description: "The actor that created the report")
|
2023-06-05 16:32:29 +00:00
|
|
|
field(:events, list_of(:event), description: "The event that is being reported")
|
2019-07-23 11:49:22 +00:00
|
|
|
field(:comments, list_of(:comment), description: "The comments that are reported")
|
2019-09-09 07:31:08 +00:00
|
|
|
|
|
|
|
field(:notes, list_of(:report_note),
|
|
|
|
description: "The notes made on the event",
|
2023-03-17 17:10:59 +00:00
|
|
|
meta: [private: true],
|
2019-09-09 07:31:08 +00:00
|
|
|
resolve: dataloader(Reports)
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:inserted_at, :datetime, description: "When the report was created")
|
|
|
|
field(:updated_at, :datetime, description: "When the report was updated")
|
2019-07-23 11:49:22 +00:00
|
|
|
end
|
|
|
|
|
2021-05-12 16:16:30 +00:00
|
|
|
object :paginated_report_list do
|
2023-03-17 17:10:59 +00:00
|
|
|
meta(:authorize, :moderator)
|
2021-05-12 16:16:30 +00:00
|
|
|
field(:elements, list_of(:report), description: "A list of reports")
|
|
|
|
field(:total, :integer, description: "The total number of reports in the list")
|
|
|
|
end
|
|
|
|
|
2019-07-23 11:49:22 +00:00
|
|
|
@desc "A report note object"
|
|
|
|
object :report_note do
|
2023-03-17 17:10:59 +00:00
|
|
|
meta(:authorize, :moderator)
|
2019-07-23 11:49:22 +00:00
|
|
|
interfaces([:action_log_object])
|
|
|
|
field(:id, :id, description: "The internal ID of the report note")
|
|
|
|
field(:content, :string, description: "The content of the note")
|
2019-09-09 07:31:08 +00:00
|
|
|
|
|
|
|
field(:moderator, :actor,
|
|
|
|
description: "The moderator who added the note",
|
|
|
|
resolve: dataloader(Reports)
|
|
|
|
)
|
|
|
|
|
2019-07-23 11:49:22 +00:00
|
|
|
field(:report, :report, description: "The report on which this note is added")
|
2019-09-09 07:31:08 +00:00
|
|
|
field(:inserted_at, :datetime, description: "When the report note was created")
|
2019-07-23 11:49:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "The list of possible statuses for a report object"
|
|
|
|
enum :report_status do
|
|
|
|
value(:open, description: "The report has been opened")
|
|
|
|
value(:closed, description: "The report has been closed")
|
|
|
|
value(:resolved, description: "The report has been marked as resolved")
|
|
|
|
end
|
|
|
|
|
2023-01-31 18:35:29 +00:00
|
|
|
enum :anti_spam_feedback do
|
|
|
|
value(:ham, description: "The report is ham")
|
|
|
|
value(:spam, description: "The report is spam")
|
|
|
|
end
|
|
|
|
|
2019-07-23 11:49:22 +00:00
|
|
|
object :report_queries do
|
|
|
|
@desc "Get all reports"
|
2021-05-12 16:16:30 +00:00
|
|
|
field :reports, :paginated_report_list do
|
2020-11-19 16:06:28 +00:00
|
|
|
arg(:page, :integer,
|
|
|
|
default_value: 1,
|
2021-05-12 16:16:30 +00:00
|
|
|
description: "The page in the report list"
|
2020-11-19 16:06:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
arg(:limit, :integer, default_value: 10, description: "The limit of reports per page")
|
|
|
|
arg(:status, :report_status, default_value: :open, description: "Filter reports by status")
|
2022-01-10 09:17:50 +00:00
|
|
|
arg(:domain, :string, default_value: nil, description: "Filter reports by domain name")
|
2023-03-17 17:10:59 +00:00
|
|
|
|
|
|
|
middleware(Rajska.QueryAuthorization,
|
|
|
|
permit: :moderator,
|
|
|
|
scope: Mobilizon.Reports.Report,
|
|
|
|
args: %{}
|
|
|
|
)
|
|
|
|
|
2019-07-23 11:49:22 +00:00
|
|
|
resolve(&Report.list_reports/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Get a report by id"
|
|
|
|
field :report, :report do
|
2020-11-19 16:06:28 +00:00
|
|
|
arg(:id, non_null(:id), description: "The report ID")
|
2023-03-17 17:10:59 +00:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :moderator, scope: Mobilizon.Reports.Report)
|
2019-07-23 11:49:22 +00:00
|
|
|
resolve(&Report.get_report/3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
object :report_mutations do
|
|
|
|
@desc "Create a report"
|
|
|
|
field :create_report, type: :report do
|
2020-11-19 16:06:28 +00:00
|
|
|
arg(:content, :string, description: "The message sent with the report")
|
|
|
|
arg(:reported_id, non_null(:id), description: "The actor's ID that is being reported")
|
2023-06-05 16:32:29 +00:00
|
|
|
|
|
|
|
arg(:events_ids, list_of(:id),
|
|
|
|
default_value: [],
|
|
|
|
description: "The list of event IDs that are being reported"
|
|
|
|
)
|
2020-11-19 16:06:28 +00:00
|
|
|
|
|
|
|
arg(:comments_ids, list_of(:id),
|
|
|
|
default_value: [],
|
2023-06-05 16:32:29 +00:00
|
|
|
description: "The comment IDs that are being reported"
|
2020-11-19 16:06:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
arg(:forward, :boolean,
|
|
|
|
default_value: false,
|
|
|
|
description:
|
|
|
|
"Whether to forward the report to the original instance if the content is remote"
|
|
|
|
)
|
|
|
|
|
2023-03-17 17:10:59 +00:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :all)
|
|
|
|
|
2019-07-23 11:49:22 +00:00
|
|
|
resolve(&Report.create_report/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Update a report"
|
|
|
|
field :update_report_status, type: :report do
|
2020-11-19 16:06:28 +00:00
|
|
|
arg(:report_id, non_null(:id), description: "The report's ID")
|
|
|
|
arg(:status, non_null(:report_status), description: "The report's new status")
|
2023-01-31 18:35:29 +00:00
|
|
|
|
|
|
|
arg(:antispam_feedback, :anti_spam_feedback,
|
|
|
|
description: "The feedback to send to the anti-spam system"
|
|
|
|
)
|
|
|
|
|
2023-03-17 17:10:59 +00:00
|
|
|
middleware(Rajska.QueryAuthorization,
|
|
|
|
permit: :moderator,
|
|
|
|
scope: Mobilizon.Reports.Report,
|
|
|
|
args: %{id: :report_id}
|
|
|
|
)
|
|
|
|
|
2019-07-23 11:49:22 +00:00
|
|
|
resolve(&Report.update_report/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Create a note on a report"
|
|
|
|
field :create_report_note, type: :report_note do
|
2020-11-19 16:06:28 +00:00
|
|
|
arg(:content, :string, description: "The note's content")
|
|
|
|
arg(:report_id, non_null(:id), description: "The report's ID")
|
2023-03-17 17:10:59 +00:00
|
|
|
|
|
|
|
middleware(Rajska.QueryAuthorization,
|
|
|
|
permit: :moderator,
|
|
|
|
scope: Mobilizon.Reports.Report,
|
|
|
|
args: %{id: :report_id}
|
|
|
|
)
|
|
|
|
|
2019-07-23 11:49:22 +00:00
|
|
|
resolve(&Report.create_report_note/3)
|
|
|
|
end
|
|
|
|
|
2020-11-19 16:06:28 +00:00
|
|
|
@desc "Delete a note on a report"
|
2019-07-23 11:49:22 +00:00
|
|
|
field :delete_report_note, type: :deleted_object do
|
2020-11-19 16:06:28 +00:00
|
|
|
arg(:note_id, non_null(:id), description: "The note's ID")
|
2023-03-17 17:10:59 +00:00
|
|
|
|
|
|
|
middleware(Rajska.QueryAuthorization,
|
|
|
|
permit: :moderator,
|
|
|
|
scope: Mobilizon.Reports.Note,
|
|
|
|
args: %{id: :note_id}
|
|
|
|
)
|
|
|
|
|
2019-07-23 11:49:22 +00:00
|
|
|
resolve(&Report.delete_report_note/3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|