Interface IForumService
- Namespace
- Builvero.Application.Interfaces.Services
- Assembly
- Builvero.Application.dll
Defines the contract for forum operations including topics, messages, subscriptions, and moderation.
public interface IForumService
Remarks
This interface provides methods for:
- Topic and message creation and retrieval with access control
- Subscription management for email notifications
- Soft deletion for moderation (admins/moderators only)
- Admin operations for viewing all projects and topics
Methods
AddMessageAsync(Guid, Guid, string, CancellationToken)
Adds a new message to an existing forum topic.
Task<ProjectForumMessageDto> AddMessageAsync(Guid topicId, Guid currentUserId, string body, CancellationToken ct)
Parameters
topicIdGuidThe unique identifier of the topic to add the message to.
currentUserIdGuidThe unique identifier of the user posting the message.
bodystringThe body content of the message.
ctCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ProjectForumMessageDto>
A ProjectForumMessageDto representing the created message.
CreateTopicAsync(Guid, Guid, string, string, CancellationToken)
Creates a new forum topic in a project with an initial message.
Task<ProjectForumTopicDto> CreateTopicAsync(Guid projectId, Guid currentUserId, string title, string body, CancellationToken ct)
Parameters
projectIdGuidThe unique identifier of the project where the topic should be created.
currentUserIdGuidThe unique identifier of the user creating the topic.
titlestringThe title of the forum topic. Must be unique within the project.
bodystringThe body content of the initial message in the topic.
ctCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ProjectForumTopicDto>
A ProjectForumTopicDto representing the created topic.
GetAllProjectsForAdminAsync(CancellationToken)
Retrieves a summary list of all projects for admin/moderation purposes.
Task<IReadOnlyList<ProjectSummaryDto>> GetAllProjectsForAdminAsync(CancellationToken ct)
Parameters
ctCancellationTokenCancellation token to cancel the operation.
Returns
- Task<IReadOnlyList<ProjectSummaryDto>>
A read-only list of project summaries.
Remarks
This method is intended for admin/moderation UI to browse all projects and their forums. Requires admin/moderator/team member privileges.
GetAllTopicsForProjectAsAdminAsync(Guid, CancellationToken)
Retrieves all forum topics for a project, including deleted topics, for admin/moderation purposes.
Task<IReadOnlyList<ProjectForumTopicDto>> GetAllTopicsForProjectAsAdminAsync(Guid projectId, CancellationToken ct)
Parameters
projectIdGuidThe unique identifier of the project.
ctCancellationTokenCancellation token to cancel the operation.
Returns
- Task<IReadOnlyList<ProjectForumTopicDto>>
A read-only list of all forum topics, including deleted ones.
Remarks
This method is intended for admin/moderation UI to view all topics, including soft-deleted ones. Requires admin/moderator/team member privileges.
GetSubscriptionStateAsync(Guid, Guid, Guid, CancellationToken)
Retrieves the current subscription state for a user regarding a project and topic.
Task<ForumSubscriptionStateDto> GetSubscriptionStateAsync(Guid projectId, Guid topicId, Guid userId, CancellationToken ct)
Parameters
projectIdGuidThe unique identifier of the project.
topicIdGuidThe unique identifier of the forum topic.
userIdGuidThe unique identifier of the user.
ctCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ForumSubscriptionStateDto>
A ForumSubscriptionStateDto containing global and topic-level subscription status.
GetTopicWithMessagesAsync(Guid, Guid, bool, CancellationToken)
Retrieves a forum topic with all its messages.
Task<ProjectForumTopicDto> GetTopicWithMessagesAsync(Guid topicId, Guid currentUserId, bool includeDeletedForAdmins, CancellationToken ct)
Parameters
topicIdGuidThe unique identifier of the topic to retrieve.
currentUserIdGuidThe unique identifier of the user requesting the topic.
includeDeletedForAdminsboolWhether to include soft-deleted messages (only effective for admins/moderators/team members).
ctCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ProjectForumTopicDto>
A ProjectForumTopicDto containing the topic and all its messages.
GetTopicsAsync(Guid, Guid, bool, CancellationToken)
Retrieves all forum topics for a project, with access control based on user role and project membership.
Task<IReadOnlyList<ProjectForumTopicDto>> GetTopicsAsync(Guid projectId, Guid currentUserId, bool includeDeletedForAdmins, CancellationToken ct)
Parameters
projectIdGuidThe unique identifier of the project whose topics should be retrieved.
currentUserIdGuidThe unique identifier of the user requesting the topics.
includeDeletedForAdminsboolWhether to include soft-deleted topics (only effective for admins/moderators/team members).
ctCancellationTokenCancellation token to cancel the operation.
Returns
- Task<IReadOnlyList<ProjectForumTopicDto>>
A read-only list of forum topics for the project.
SetGlobalSubscriptionAsync(Guid, Guid, bool, CancellationToken)
Sets the global forum notification preference for a user in a project.
Task SetGlobalSubscriptionAsync(Guid projectId, Guid userId, bool receiveAll, CancellationToken ct)
Parameters
projectIdGuidThe unique identifier of the project.
userIdGuidThe unique identifier of the user.
receiveAllboolWhether the user should receive all forum notifications for this project.
ctCancellationTokenCancellation token to cancel the operation.
Returns
- Task
- Defines the contract for forum operations including topics, messages, subscriptions, and moderation.
Remarks
When receiveAll is false, the user will not receive any forum notifications for the project,
regardless of individual topic subscriptions.
SetTopicSubscriptionAsync(Guid, Guid, bool, CancellationToken)
Sets the subscription status for a user to a specific forum topic.
Task SetTopicSubscriptionAsync(Guid topicId, Guid userId, bool isSubscribed, CancellationToken ct)
Parameters
topicIdGuidThe unique identifier of the forum topic.
userIdGuidThe unique identifier of the user.
isSubscribedboolWhether the user should be subscribed to receive notifications for this topic.
ctCancellationTokenCancellation token to cancel the operation.
Returns
- Task
- Defines the contract for forum operations including topics, messages, subscriptions, and moderation.
Remarks
Topic-level subscriptions only take effect if the user's global subscription for the project allows notifications.
SoftDeleteMessageAsync(Guid, Guid, bool, CancellationToken)
Soft-deletes a forum message, hiding it from normal view while preserving it in the database.
Task SoftDeleteMessageAsync(Guid messageId, Guid performedByUserId, bool asAdminOrModerator, CancellationToken ct)
Parameters
messageIdGuidThe unique identifier of the message to delete.
performedByUserIdGuidThe unique identifier of the user performing the deletion (must be admin/moderator or message creator).
asAdminOrModeratorboolWhether the deletion is being performed with admin/moderator privileges.
ctCancellationTokenCancellation token to cancel the operation.
Returns
- Task
- Defines the contract for forum operations including topics, messages, subscriptions, and moderation.
Remarks
Admins, moderators, and team members can delete any message. Regular users can only delete their own messages.
Exceptions
- UnauthorizedAccessException
Thrown when the user does not have permission to delete the message.
SoftDeleteTopicAsync(Guid, Guid, bool, CancellationToken)
Soft-deletes a forum topic, hiding it from normal view while preserving it in the database.
Task SoftDeleteTopicAsync(Guid topicId, Guid performedByUserId, bool asAdminOrModerator, CancellationToken ct)
Parameters
topicIdGuidThe unique identifier of the topic to delete.
performedByUserIdGuidThe unique identifier of the user performing the deletion (must be admin/moderator).
asAdminOrModeratorboolWhether the deletion is being performed with admin/moderator privileges.
ctCancellationTokenCancellation token to cancel the operation.
Returns
- Task
- Defines the contract for forum operations including topics, messages, subscriptions, and moderation.
Remarks
Only admins, moderators, and team members can soft-delete topics. The topic and all its messages are marked as deleted.
Exceptions
- UnauthorizedAccessException
Thrown when the user does not have permission to delete topics.