debianize-mobilizon/lib/graphql/api/comments.ex

35 lines
855 B
Elixir
Raw Normal View History

2020-01-26 21:11:16 +01:00
defmodule Mobilizon.GraphQL.API.Comments do
@moduledoc """
2019-09-22 16:26:23 +02:00
API for Comments.
"""
2020-01-26 21:11:16 +01:00
alias Mobilizon.Actors.Actor
alias Mobilizon.Discussions.Comment
2020-01-22 02:14:42 +01:00
alias Mobilizon.Federation.ActivityPub
alias Mobilizon.Federation.ActivityPub.Activity
@doc """
Create a comment
Creates a comment from an actor
"""
2020-01-26 21:11:16 +01:00
@spec create_comment(map) :: {:ok, Activity.t(), Comment.t()} | any
def create_comment(args) do
ActivityPub.create(:comment, args, true)
end
def update_comment(%Comment{} = comment, args) do
ActivityPub.update(comment, args, true)
end
@doc """
Deletes a comment
Deletes a comment from an actor
"""
@spec delete_comment(Comment.t(), Actor.t()) :: {:ok, Activity.t(), Comment.t()} | any
def delete_comment(%Comment{} = comment, %Actor{} = actor) do
ActivityPub.delete(comment, actor, true)
end
end