Class UnsubscribeController
- Namespace
- Builvero.Api.Controllers
- Assembly
- Builvero.Api.dll
Provides public API endpoints for unsubscribing from forum notifications via email links (no authentication required).
[ApiController]
[Route("u/forum")]
public class UnsubscribeController : ControllerBase
- Inheritance
-
UnsubscribeController
- Inherited Members
Remarks
This is a public controller - no authentication is required. It provides:
- Unsubscribing from all forum notifications for a project
- Unsubscribing from notifications for a specific forum topic
All endpoints use secure tokens from email links to verify user identity without requiring login. Invalid tokens result in an error message displayed in HTML format. Successful unsubscriptions display a confirmation message in HTML format.
These endpoints are accessed via email links and return HTML content for direct browser display.
Constructors
UnsubscribeController(IUserRepository, IForumRepository)
Initializes a new instance of the UnsubscribeController class.
public UnsubscribeController(IUserRepository userRepository, IForumRepository forumRepository)
Parameters
userRepositoryIUserRepositoryRepository for user data access operations.
forumRepositoryIForumRepositoryRepository for forum data access operations.
Methods
UnsubscribeAll(Guid, string, Guid, CancellationToken)
Unsubscribes a user from all forum notifications for a specific project.
[HttpGet("unsubscribe-all")]
public Task<ContentResult> UnsubscribeAll(Guid userId, string token, Guid projectId, CancellationToken cancellationToken = default)
Parameters
userIdGuidThe unique identifier of the user to unsubscribe.
tokenstringThe secure unsubscribe token from the email link.
projectIdGuidThe unique identifier of the project to unsubscribe from.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ContentResult>
200 OK: Returns HTML content with success message
200 OK: Returns HTML content with error message if token is invalid
Remarks
Public endpoint (no authentication required). Verifies the user's identity using the secure token from the email link. Sets ReceiveAllNotifications to false for the project. Returns HTML content suitable for direct browser display. Invalid tokens result in an error message.
UnsubscribeTopic(Guid, string, Guid, CancellationToken)
Unsubscribes a user from notifications for a specific forum topic.
[HttpGet("unsubscribe-topic")]
public Task<ContentResult> UnsubscribeTopic(Guid userId, string token, Guid topicId, CancellationToken cancellationToken = default)
Parameters
userIdGuidThe unique identifier of the user to unsubscribe.
tokenstringThe secure unsubscribe token from the email link.
topicIdGuidThe unique identifier of the topic to unsubscribe from.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ContentResult>
200 OK: Returns HTML content with success message
200 OK: Returns HTML content with error message if token is invalid
Remarks
Public endpoint (no authentication required). Verifies the user's identity using the secure token from the email link. Sets IsSubscribed to false for the topic subscription. Returns HTML content suitable for direct browser display. Invalid tokens result in an error message.