feat(notifications): support dismissing notifications in PostIt

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Paul Schneider 2026-10-18 12:49:52 +01:00
commit cb8cf9406d
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12
12 changed files with 389 additions and 181 deletions

View file

@ -8,7 +8,8 @@ using Yavsc.Abstract.Models.Messaging;
namespace Yavsc.Api.Client;
/// <summary>
/// Thin HTTP client for the notifications exposed to PostIt on the home page.
/// Thin HTTP client for the notifications exposed to PostIt on the home page,
/// and for their dismissal by the current user.
/// </summary>
public sealed class NotificationsApiClient
{
@ -48,6 +49,33 @@ public sealed class NotificationsApiClient
public Task<List<Notification>> GetPublicAsync(CancellationToken ct = default)
=> _api.GetAnonymousAsync<List<Notification>>(Absolute(PathPrefix), ct);
public Task<List<DismissedNotification>> GetDismissedAsync(CancellationToken ct = default)
{
return _api.CallAsync<List<DismissedNotification>>(
HttpMethod.Get,
Absolute(Constants.NotificationsDismissPath),
ct: ct);
}
public Task<DismissedNotification> DismissAsync(long notificationId, CancellationToken ct = default)
{
return _api.CallAsync<DismissedNotification>(
HttpMethod.Post,
Absolute(DismissClickPath(notificationId)),
ct: ct);
}
public Task RestoreAsync(long notificationId, CancellationToken ct = default)
{
return _api.CallAsync(
HttpMethod.Delete,
Absolute(DismissClickPath(notificationId)),
ct: ct);
}
private static string DismissClickPath(long notificationId)
=> $"{Constants.NotificationsDismissPath}/{Constants.NotificationsDismissClickRoute}/{notificationId}";
private string Absolute(string relativePath) => new Uri(ResolveBusinessBaseAddress(), relativePath).ToString();
private Uri ResolveBusinessBaseAddress()