Skip to main content

Overview

Returns a function that allows a space moderator to take action on a comment report. Available actions are: remove the comment, ban the comment’s author from the space, or dismiss the report.
Requires the authenticated user to have admin or moderator role in the target space.

Usage Example

import { useHandleSpaceCommentReport } from "@replyke/react-js";

function CommentReportActions({ report }) {
  const handleSpaceCommentReport = useHandleSpaceCommentReport();

  const removeComment = async () => {
    await handleSpaceCommentReport({
      spaceId: report.spaceId,
      reportId: report.id,
      commentId: report.targetId,
      actions: ["remove-comment"],
      summary: "Removed comment for harassment",
    });
  };

  const dismiss = async () => {
    await handleSpaceCommentReport({
      spaceId: report.spaceId,
      reportId: report.id,
      commentId: report.targetId,
      actions: ["dismiss"],
      summary: "No violation found",
    });
  };

  return (
    <div>
      <button onClick={removeComment}>Remove Comment</button>
      <button onClick={dismiss}>Dismiss</button>
    </div>
  );
}

Parameters

spaceId
string
required
The ID of the space the report belongs to.
reportId
string
required
The ID of the report to action.
commentId
string
required
The ID of the reported comment.
actions
Array<'remove-comment' | 'ban-user' | 'dismiss'>
required
One or more actions to take:
  • remove-comment — Removes the comment.
  • ban-user — Bans the comment’s author from the space (requires userId).
  • dismiss — Marks the report as dismissed.
summary
string
required
A moderator note describing the action taken.
userId
string
The ID of the user to ban. Required when ban-user is included in actions.
reason
string
The reason for banning, if applicable.

Returns

Returns Promise<{ message: string; code: string }>.

Notes