View Source Mobilizon.Discussions (Mobilizon v4.1.0-alpha.1)
The discussions context
Summary
Functions
Counts all comments.
Counts local comments under events
Creates a comment.
Creates a discussion.
Callback for Absinthe Ecto Dataloader
Deletes a comment
Delete a discussion.
Get a paginated list of discussions for a group actor
Gets a single comment.
Gets a single comment.
Raises Ecto.NoResultsError
if the comment does not exist.
Gets a comment by its URL.
Gets a comment by its URL, with all associations loaded.
Gets a comment by its URL, with all associations loaded.
Raises Ecto.NoResultsError
if the comment does not exist.
Gets a comment by its UUID, with all associations loaded.
Get a single comment by it's ID and all associations preloaded
Get all the comments contained into a discussion
Get all the comments contained into a discussion
Get a discussion by it's ID
Get a discussion by it's slug
Get a discussion by it's URL
Gets paginated replies for root comment
Returns the list of comments by an actor and a list of ids.
Returns a paginated list of local comments
Returns the list of public comments for the actor.
Query for comment dataloader
Create a response to a discussion
Updates a comment.
Update a discussion. Only their title for now.
Functions
@spec count_comments_under_events() :: integer()
Counts all comments.
@spec count_local_comments_under_events() :: integer()
Counts local comments under events
@spec create_comment(map()) :: {:ok, Mobilizon.Discussions.Comment.t()} | {:error, Ecto.Changeset.t()}
Creates a comment.
@spec create_discussion(map()) :: {:ok, Mobilizon.Discussions.Discussion.t()} | {:error, atom(), Ecto.Changeset.t(), map()}
Creates a discussion.
@spec data() :: Dataloader.Ecto.t()
Callback for Absinthe Ecto Dataloader
@spec delete_comment(Mobilizon.Discussions.Comment.t(), Keyword.t()) :: {:ok, Mobilizon.Discussions.Comment.t()} | {:error, Ecto.Changeset.t()}
Deletes a comment
But actually just empty the fields so that threads are not broken.
@spec delete_discussion(Mobilizon.Discussions.Discussion.t()) :: {:ok, %{comments: {integer() | nil, any()}}} | {:error, :comments, Ecto.Changeset.t(), map()}
Delete a discussion.
@spec find_discussions_for_actor( Mobilizon.Actors.Actor.t(), integer() | nil, integer() | nil ) :: Mobilizon.Storage.Page.t(Mobilizon.Discussions.Discussion.t())
Get a paginated list of discussions for a group actor
@spec get_comment(integer() | String.t()) :: Mobilizon.Discussions.Comment.t() | nil
Gets a single comment.
@spec get_comment!(integer() | String.t()) :: Mobilizon.Discussions.Comment.t()
Gets a single comment.
Raises Ecto.NoResultsError
if the comment does not exist.
@spec get_comment_from_url(String.t()) :: Mobilizon.Discussions.Comment.t() | nil
Gets a comment by its URL.
@spec get_comment_from_url_with_preload(String.t()) :: {:ok, Mobilizon.Discussions.Comment.t()} | {:error, :comment_not_found}
Gets a comment by its URL, with all associations loaded.
@spec get_comment_from_url_with_preload!(String.t()) :: Mobilizon.Discussions.Comment.t()
Gets a comment by its URL, with all associations loaded.
Raises Ecto.NoResultsError
if the comment does not exist.
@spec get_comment_from_uuid_with_preload(String.t()) :: Mobilizon.Discussions.Comment.t() | nil
Gets a comment by its UUID, with all associations loaded.
@spec get_comment_with_preload(String.t() | integer() | nil) :: Mobilizon.Discussions.Comment.t() | nil
Get a single comment by it's ID and all associations preloaded
get_comments_for_discussion(discussion_id, page \\ nil, limit \\ nil)
View Source@spec get_comments_for_discussion(integer(), integer() | nil, integer() | nil) :: Mobilizon.Storage.Page.t(Mobilizon.Discussions.Comment.t())
Get all the comments contained into a discussion
get_comments_in_reply_to_comment_id(origin_comment_id, page \\ nil, limit \\ nil)
View Source@spec get_comments_in_reply_to_comment_id(integer(), integer() | nil, integer() | nil) :: Mobilizon.Storage.Page.t(Mobilizon.Discussions.Comment.t())
Get all the comments contained into a discussion
@spec get_discussion(String.t() | integer()) :: Mobilizon.Discussions.Discussion.t() | nil
Get a discussion by it's ID
@spec get_discussion_by_slug(String.t()) :: Mobilizon.Discussions.Discussion.t() | nil
Get a discussion by it's slug
@spec get_discussion_by_url(String.t() | nil) :: Mobilizon.Discussions.Discussion.t() | nil
Get a discussion by it's URL
@spec get_thread_replies(integer()) :: [Mobilizon.Discussions.Comment.t()]
Gets paginated replies for root comment
@spec list_comments_by_actor_and_ids(integer() | String.t(), [integer() | String.t()]) :: [ Mobilizon.Discussions.Comment.t() ]
Returns the list of comments by an actor and a list of ids.
@spec list_local_comments(integer() | nil, integer() | nil) :: Mobilizon.Storage.Page.t(Mobilizon.Discussions.Comment.t())
Returns a paginated list of local comments
@spec list_public_comments_for_actor( Mobilizon.Actors.Actor.t(), integer() | nil, integer() | nil ) :: Mobilizon.Storage.Page.t(Mobilizon.Discussions.Comment.t())
Returns the list of public comments for the actor.
@spec query(atom(), map()) :: Ecto.Query.t()
Query for comment dataloader
We only get first comment of thread, and count replies. Read: https://hexdocs.pm/absinthe/ecto.html#dataloader
@spec reply_to_discussion(Mobilizon.Discussions.Discussion.t(), map()) :: {:ok, Mobilizon.Discussions.Discussion.t()} | {:error, atom(), Ecto.Changeset.t(), map()}
Create a response to a discussion
@spec update_comment(Mobilizon.Discussions.Comment.t(), map()) :: {:ok, Mobilizon.Discussions.Comment.t()} | {:error, Ecto.Changeset.t()}
Updates a comment.
@spec update_discussion(Mobilizon.Discussions.Discussion.t(), map()) :: {:ok, Mobilizon.Discussions.Discussion.t()} | {:error, Ecto.Changeset.t()}
Update a discussion. Only their title for now.