Activity-log wrapper for the Comments module.
The module had none. Eleven mutating functions — including the moderation
ones, approve_comment/1, hide_comment/1 and bulk_update_status/2 —
wrote nothing to the audit trail, so "who hid this comment, and when"
had no answer anywhere in the system.
What is safe to record
Comment bodies are free text a user typed, so they never go in metadata. Neither do email addresses. What goes in is the shape of the action: status, resource type, counts, and uuids that resolve to a record for anyone entitled to look it up.
Logging never crashes the caller: core's PhoenixKit.Activity.log/3
returns a missing activity table (a host that has not migrated) or a
dead pool as a logged {:error, _} — an audit line is not worth losing
the write it describes.
Summary
Functions
Logs one action under the "comments" module key. Options as
PhoenixKit.Activity.log/3.
Pipe-step for {:ok, %Comment{}} repo results.
Functions
Logs one action under the "comments" module key. Options as
PhoenixKit.Activity.log/3.
@spec log_comment({:ok, struct()} | {:error, term()}, binary(), keyword()) :: {:ok, struct()} | {:error, term()}
Pipe-step for {:ok, %Comment{}} repo results.
Passes {:error, _} straight through, so a failed write logs nothing —
which is the point: the log should describe what happened, not what was
attempted.