Class AdminForumController
- Namespace
- Builvero.Api.Controllers
- Assembly
- Builvero.Api.dll
Provides administrative API endpoints for forum management, including viewing all projects, topics, and messages, and performing moderation actions.
[ApiController]
[Route("api/admin")]
[Authorize(Roles = "Admin,Moderator,BetaTester")]
public class AdminForumController : ControllerBase
- Inheritance
-
AdminForumController
- Inherited Members
Remarks
This controller requires authorization via roles: Admin, Moderator, or BetaTester. All endpoints are prefixed with /api/admin.
The controller provides:
- Retrieving all projects for forum administration
- Retrieving all topics for a project (including deleted topics)
- Soft-deleting forum topics (Admin and Moderator only)
- Soft-deleting forum messages (Admin and Moderator only)
Unlike the regular ForumController, this controller allows viewing deleted content and provides moderation capabilities. Soft-deleted topics and messages are hidden from regular users but remain visible to admins and moderators.
Constructors
AdminForumController(IForumService)
Initializes a new instance of the AdminForumController class.
public AdminForumController(IForumService forumService)
Parameters
forumServiceIForumServiceService for forum operations.
Methods
DeleteMessage(Guid, CancellationToken)
Soft-deletes a forum message (Admin and Moderator only).
[HttpPost("forum/messages/{messageId}/delete")]
[Authorize(Roles = "Admin,Moderator")]
public Task<IActionResult> DeleteMessage(Guid messageId, CancellationToken cancellationToken = default)
Parameters
messageIdGuidThe unique identifier of the message to delete.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<IActionResult>
200 OK: Returns
{ "message": "Message deleted" }400 Bad Request: Message not found or error deleting message
Remarks
Requires Admin or Moderator role. Soft-deletes the message, hiding it from regular users but keeping it visible to admins and moderators. The message can be restored if needed. This is a moderation action.
DeleteTopic(Guid, CancellationToken)
Soft-deletes a forum topic (Admin and Moderator only).
[HttpPost("forum/topics/{topicId}/delete")]
[Authorize(Roles = "Admin,Moderator")]
public Task<IActionResult> DeleteTopic(Guid topicId, CancellationToken cancellationToken = default)
Parameters
topicIdGuidThe unique identifier of the topic to delete.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<IActionResult>
200 OK: Returns
{ "message": "Topic deleted" }400 Bad Request: Topic not found or error deleting topic
Remarks
Requires Admin or Moderator role. Soft-deletes the topic, hiding it from regular users but keeping it visible to admins and moderators. The topic can be restored if needed. This is a moderation action.
GetAllProjects(CancellationToken)
Retrieves all projects in the system for forum administration purposes.
[HttpGet("projects")]
public Task<ActionResult<IReadOnlyList<ProjectSummaryDto>>> GetAllProjects(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ActionResult<IReadOnlyList<ProjectSummaryDto>>>
200 OK: Returns list of ProjectSummaryDto objects
400 Bad Request: Error retrieving projects
Remarks
Requires Admin, Moderator, or BetaTester role. Returns all projects regardless of status or membership. Used by admin interfaces to browse projects and access their forums.
GetProjectTopics(Guid, CancellationToken)
Retrieves all forum topics for a specific project, including deleted topics.
[HttpGet("projects/{projectId}/forum/topics")]
public Task<ActionResult<IReadOnlyList<ProjectForumTopicDto>>> GetProjectTopics(Guid projectId, CancellationToken cancellationToken = default)
Parameters
projectIdGuidThe unique identifier of the project whose topics to retrieve.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ActionResult<IReadOnlyList<ProjectForumTopicDto>>>
200 OK: Returns list of ProjectForumTopicDto objects, including deleted topics
400 Bad Request: Error retrieving topics
Remarks
Requires Admin, Moderator, or BetaTester role. Returns all topics for the project, including soft-deleted ones that are hidden from regular users. This allows admins to review and manage forum content.