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. A missing activity table (a host that
has not migrated) and a dead pool are both :ok — an audit line is not
worth losing the write it describes.
Summary
Functions
Logs one action. opts mirrors PhoenixKit.Activity.log/1's keys.
Pipe-step for {:ok, %Comment{}} repo results.
Functions
Logs one action. opts mirrors PhoenixKit.Activity.log/1's keys.
@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.