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

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 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

Link to this function

count_comments_under_events()

View Source
@spec count_comments_under_events() :: integer()

Counts all comments.

Link to this function

count_local_comments_under_events()

View Source
@spec count_local_comments_under_events() :: integer()

Counts local comments under events

Link to this function

create_comment(attrs \\ %{})

View Source
@spec create_comment(map()) ::
  {:ok, Mobilizon.Discussions.Comment.t()} | {:error, Ecto.Changeset.t()}

Creates a comment.

Link to this function

create_discussion(attrs)

View Source
@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

Link to this function

delete_comment(comment, options \\ [])

View Source
@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.

Link to this function

delete_discussion(discussion)

View Source
@spec delete_discussion(Mobilizon.Discussions.Discussion.t()) ::
  {:ok, %{comments: {integer() | nil, any()}}}
  | {:error, :comments, Ecto.Changeset.t(), map()}

Delete a discussion.

Link to this function

find_discussions_for_actor(actor, page \\ nil, limit \\ nil)

View Source
@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.

Link to this function

get_comment_from_url(url)

View Source
@spec get_comment_from_url(String.t()) :: Mobilizon.Discussions.Comment.t() | nil

Gets a comment by its URL.

Link to this function

get_comment_from_url_with_preload(url)

View Source
@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.

Link to this function

get_comment_from_url_with_preload!(url)

View Source
@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.

Link to this function

get_comment_from_uuid_with_preload(uuid)

View Source
@spec get_comment_from_uuid_with_preload(String.t()) ::
  Mobilizon.Discussions.Comment.t() | nil

Gets a comment by its UUID, with all associations loaded.

Link to this function

get_comment_with_preload(id)

View Source
@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

Link to this function

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

Link to this function

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

Link to this function

get_discussion(discussion_id)

View Source
@spec get_discussion(String.t() | integer()) ::
  Mobilizon.Discussions.Discussion.t() | nil

Get a discussion by it's ID

Link to this function

get_discussion_by_slug(discussion_slug)

View Source
@spec get_discussion_by_slug(String.t()) :: Mobilizon.Discussions.Discussion.t() | nil

Get a discussion by it's slug

Link to this function

get_discussion_by_url(discussion_url)

View Source
@spec get_discussion_by_url(String.t() | nil) ::
  Mobilizon.Discussions.Discussion.t() | nil

Get a discussion by it's URL

Link to this function

get_thread_replies(parent_id)

View Source
@spec get_thread_replies(integer()) :: [Mobilizon.Discussions.Comment.t()]

Gets paginated replies for root comment

Link to this function

list_comments_by_actor_and_ids(actor_id, comment_ids \\ [])

View Source
@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.

Link to this function

list_local_comments(page \\ nil, limit \\ nil)

View Source
@spec list_local_comments(integer() | nil, integer() | nil) ::
  Mobilizon.Storage.Page.t(Mobilizon.Discussions.Comment.t())

Returns a paginated list of local comments

Link to this function

list_public_comments_for_actor(actor, page \\ nil, limit \\ nil)

View Source
@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

Link to this function

reply_to_discussion(discussion, attrs \\ %{})

View Source
@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

Link to this function

update_comment(comment, attrs)

View Source
@spec update_comment(Mobilizon.Discussions.Comment.t(), map()) ::
  {:ok, Mobilizon.Discussions.Comment.t()} | {:error, Ecto.Changeset.t()}

Updates a comment.

Link to this function

update_discussion(discussion, attrs \\ %{})

View Source
@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.