Skip to main content

Overview

Returns a function to fetch content reports (entities and comments) from spaces where the current user has an admin or moderator role. If spaceId is provided, returns reports for that specific space (the user must moderate it). If omitted, returns reports aggregated from all spaces the user moderates.
Requires an authenticated user with admin or moderator role in at least one space.

Usage Example

import { useFetchModeratedReports } from "@replyke/react-js";
import { useEffect, useState } from "react";

function ModerationQueue({ spaceId }: { spaceId: string }) {
  const fetchModeratedReports = useFetchModeratedReports();
  const [reports, setReports] = useState([]);

  useEffect(() => {
    fetchModeratedReports({ spaceId, status: "pending", page: 1, limit: 20 })
      .then(res => setReports(res.data));
  }, [spaceId]);

  return (
    <ul>
      {reports.map(r => (
        <li key={r.id}>{r.targetType}: {r.reporterCount} reports</li>
      ))}
    </ul>
  );
}

Parameters

spaceId
string
Filter reports to a specific space. If omitted, returns reports from all spaces the user moderates.
targetType
"comment" | "entity"
Filter by target type.
status
"pending" | "on-hold" | "escalated" | "dismissed" | "actioned"
Filter by report status.
sortBy
"new" | "old"
Sort order. Defaults to "new" (newest first).
page
number
Page number for pagination. Defaults to 1.
limit
number
Items per page. Defaults to 20.

Returns

Returns Promise<PaginatedResponse<Report>>:
{
  data: Report[];
  pagination: {
    page: number;
    pageSize: number;
    totalPages: number;
    totalItems: number;
    hasMore: boolean;
  };
}

Report object

id
string
UUID of the report record.
projectId
string
Project the report belongs to.
spaceId
string | null
Space the reported content belongs to.
targetId
string
ID of the reported entity or comment.
targetType
"comment" | "entity"
Type of the reported content.
reporterCount
number
Total number of users who have reported this target.
userReports
array
Individual user report entries. Each includes id, userId, reason, details, and createdAt.
status
string
Current moderation status: pending, on-hold, escalated, dismissed, or actioned.
actionTaken
string | null
Free-text description of action taken, if any.
target
Entity | Comment | null
The reported content record (includes the author user object). Populated even if the content was soft-deleted.
space
Space | null
The space the reported content belongs to.
createdAt
Date
When the first report for this target was submitted.
updatedAt
Date
When the report record was last updated.
deletedAt
Date | null
Soft-delete timestamp. null if the report has not been deleted.