Wraith.Comments (Wraith v0.1.0)

View Source

Members comment on posts; one level of replies. A comment is id, post_id, member_id, member_name, parent_id, body (plain text, rendered with line breaks), status ("published" | "hidden"), created_at. Comments live under the post (POST#id / COMMENT#<at>#<id>) so a page is one query; the index COMMENTS#<status> feeds admin moderation. Changes broadcast {:comments, post_id} on "comments:<post_id>".

Summary

Functions

Every comment a member wrote (any status).

A member posts a comment (or a reply with parent_id).

A member removes their own comment (or an author removes any): the text goes, the slot stays for replies.

Published comments of a post, oldest first, as a tree: [%{comment, replies: [...]}].

Newest comments across the site, for moderation.

Hide (moderate) or show a comment.

Functions

by_member(member_id)

Every comment a member wrote (any status).

count(post_id)

create(post, member, body, parent_id \\ nil)

@spec create(map(), map(), String.t(), String.t() | nil) ::
  {:ok, map()} | {:error, String.t()}

A member posts a comment (or a reply with parent_id).

delete(c)

A member removes their own comment (or an author removes any): the text goes, the slot stays for replies.

enabled?()

for_post(post_id, opts \\ [])

Published comments of a post, oldest first, as a tree: [%{comment, replies: [...]}].

get(post_id, id)

recent(status \\ "published", limit \\ 50)

Newest comments across the site, for moderation.

set_status(c, status)

Hide (moderate) or show a comment.

subscribe(post_id)

topic(post_id)