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