2020-01-26 20:11:16 +00:00
|
|
|
defmodule Mobilizon.GraphQL.API.Comments do
|
2018-12-14 16:41:55 +00:00
|
|
|
@moduledoc """
|
2019-09-22 14:26:23 +00:00
|
|
|
API for Comments.
|
2018-12-14 16:41:55 +00:00
|
|
|
"""
|
2020-01-26 20:11:16 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
alias Mobilizon.Conversations.Comment
|
2020-01-22 01:14:42 +00:00
|
|
|
|
|
|
|
alias Mobilizon.Federation.ActivityPub
|
|
|
|
alias Mobilizon.Federation.ActivityPub.Activity
|
2018-12-14 16:41:55 +00:00
|
|
|
|
|
|
|
@doc """
|
|
|
|
Create a comment
|
|
|
|
|
2019-11-15 17:36:47 +00:00
|
|
|
Creates a comment from an actor
|
2018-12-14 16:41:55 +00:00
|
|
|
"""
|
2020-01-26 20:11:16 +00:00
|
|
|
@spec create_comment(map) :: {:ok, Activity.t(), Comment.t()} | any
|
2019-10-25 15:43:37 +00:00
|
|
|
def create_comment(args) do
|
|
|
|
ActivityPub.create(:comment, args, true)
|
2018-12-14 16:41:55 +00:00
|
|
|
end
|
2019-11-15 17:36:47 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
def update_comment(%Comment{} = comment, args) do
|
|
|
|
ActivityPub.update(:comment, comment, args, true)
|
|
|
|
end
|
|
|
|
|
2019-11-15 17:36:47 +00:00
|
|
|
@doc """
|
|
|
|
Deletes a comment
|
|
|
|
|
|
|
|
Deletes a comment from an actor
|
|
|
|
"""
|
2020-01-26 20:11:16 +00:00
|
|
|
@spec delete_comment(Comment.t()) :: {:ok, Activity.t(), Comment.t()} | any
|
2019-11-15 17:36:47 +00:00
|
|
|
def delete_comment(%Comment{} = comment) do
|
|
|
|
ActivityPub.delete(comment, true)
|
|
|
|
end
|
2018-12-14 16:41:55 +00:00
|
|
|
end
|