Table of Contents

Class SendAlertController

Namespace
adas_core.Controllers
Assembly
adas-core.dll
[Route("send-alerts")]
[ApiController]
public class SendAlertController : ControllerBase
Inheritance
SendAlertController
Inherited Members
Extension Methods

Constructors

SendAlertController(ISendAlertService)

public SendAlertController(ISendAlertService sendAlertService)

Parameters

sendAlertService ISendAlertService

Properties

Subscriptions

public static List<PushSubscription> Subscriptions { get; set; }

Property Value

List<PushSubscription>

Methods

Broadcast(string, object)

Broadcasts a push notification to the subscription identified by the given endpoint. Requires the caller to have the AuthAdmin role, and returns NotFound when no matching subscription exists.

[HttpPost("broadcast/{sub}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthAdmin)]
public IActionResult Broadcast(string sub, object message)

Parameters

sub string

The endpoint identifier of the push subscription that will receive the notification.

message object

The payload to send, serialized to JSON before transmission.

Returns

IActionResult

An IActionResult that returns NotFound if the subscription is not found, or Ok when the notification is sent successfully.

GetApiClients()

Retrieves the list of configured API clients. Restricted to users with the AuthAdmin role.

[HttpGet("api-clients")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthAdmin)]
public Task<IActionResult> GetApiClients()

Returns

Task<IActionResult>

An IActionResult containing the collection of API clients returned by the send alert service.

GetErrorQueues()

Retrieves the list of error queues from the alert service.

[HttpGet("rabbit")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthAdmin)]
public Task<IActionResult> GetErrorQueues()

Returns

Task<IActionResult>

An IActionResult containing the error queues returned by the service.

GetPerformance()

Retrieves performance metrics for the alert system. Requires the AuthAdmin role; the performance data is fetched from the send alert service and returned in an HTTP 200 OK response.

[HttpGet("performance")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthAdmin)]
public IActionResult GetPerformance()

Returns

IActionResult

An IActionResult containing the performance data returned by the service.

WebSubscribe(PushSubscription)

Registers a new web push subscription for push notifications by adding the provided subscription to the internal subscriptions store.

[HttpPost("web-subscribe")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthAdmin)]
public IActionResult WebSubscribe(PushSubscription sub)

Parameters

sub PushSubscription

The push subscription payload received from the client, containing the endpoint and cryptographic keys required for delivering web push notifications.

Returns

IActionResult

An IActionResult containing an HTTP 200 OK response with a confirmation message indicating the subscription was accepted.

WebUnSubscribe(PushSubscription)

Handles web push notification unsubscription for an authenticated admin user. Removes the matching subscription from the store when its endpoint is found; otherwise returns a failure message while still responding with a successful HTTP status.

[HttpPost("web-unsubscribe")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthAdmin)]
public IActionResult WebUnSubscribe(PushSubscription sub)

Parameters

sub PushSubscription

The push subscription to remove, identified by its endpoint.

Returns

IActionResult

An IActionResult containing a success message when the subscription is removed, or a failure message when no matching subscription is found.