@@ -40,7 +40,8 @@ public RouteActionProvider(IEndpointRouteBuilder builder, DashboardOptions optio
4040 _agent = _serviceProvider . GetService < GatewayProxyAgent > ( ) ; // may be null
4141 }
4242
43- private IMonitoringApi MonitoringApi => _serviceProvider . GetRequiredService < IDataStorage > ( ) . GetMonitoringApi ( ) ;
43+ private IDataStorage DataStorage => _serviceProvider . GetRequiredService < IDataStorage > ( ) ;
44+ private IMonitoringApi MonitoringApi => DataStorage . GetMonitoringApi ( ) ;
4445
4546 public void MapDashboardRoutes ( )
4647 {
@@ -54,7 +55,9 @@ public void MapDashboardRoutes()
5455 _builder . MapGet ( prefixMatch + "/published/message/{id:long}" , PublishedMessageDetails ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
5556 _builder . MapGet ( prefixMatch + "/received/message/{id:long}" , ReceivedMessageDetails ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
5657 _builder . MapPost ( prefixMatch + "/published/requeue" , PublishedRequeue ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
58+ _builder . MapPost ( prefixMatch + "/published/delete" , PublishedDelete ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
5759 _builder . MapPost ( prefixMatch + "/received/reexecute" , ReceivedRequeue ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
60+ _builder . MapPost ( prefixMatch + "/received/delete" , ReceivedDelete ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
5861 _builder . MapGet ( prefixMatch + "/published/{status}" , PublishedList ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
5962 _builder . MapGet ( prefixMatch + "/received/{status}" , ReceivedList ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
6063 _builder . MapGet ( prefixMatch + "/subscriber" , Subscribers ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
@@ -79,7 +82,7 @@ public async Task MetaInfo(HttpContext httpContext)
7982 var cap = _serviceProvider . GetService < CapMarkerService > ( ) ;
8083 var broker = _serviceProvider . GetService < CapMessageQueueMakerService > ( ) ;
8184 var storage = _serviceProvider . GetService < CapStorageMarkerService > ( ) ;
82-
85+
8386 await httpContext . Response . WriteAsJsonAsync ( new
8487 {
8588 cap ,
@@ -215,6 +218,23 @@ public async Task PublishedRequeue(HttpContext httpContext)
215218 httpContext . Response . StatusCode = StatusCodes . Status204NoContent ;
216219 }
217220
221+ public async Task PublishedDelete ( HttpContext httpContext )
222+ {
223+ if ( _agent != null && await _agent . Invoke ( httpContext ) ) return ;
224+
225+ var messageIds = await httpContext . Request . ReadFromJsonAsync < long [ ] > ( ) ;
226+ if ( messageIds == null || messageIds . Length == 0 )
227+ {
228+ httpContext . Response . StatusCode = StatusCodes . Status422UnprocessableEntity ;
229+ return ;
230+ }
231+
232+ foreach ( var messageId in messageIds )
233+ _ = await DataStorage . DeletePublishedMessageAsync ( messageId ) ;
234+
235+ httpContext . Response . StatusCode = StatusCodes . Status204NoContent ;
236+ }
237+
218238 public async Task ReceivedRequeue ( HttpContext httpContext )
219239 {
220240 if ( _agent != null && await _agent . Invoke ( httpContext ) ) return ;
@@ -236,6 +256,24 @@ public async Task ReceivedRequeue(HttpContext httpContext)
236256 httpContext . Response . StatusCode = StatusCodes . Status204NoContent ;
237257 }
238258
259+ public async Task ReceivedDelete ( HttpContext httpContext )
260+ {
261+ if ( _agent != null && await _agent . Invoke ( httpContext ) ) return ;
262+
263+ var messageIds = await httpContext . Request . ReadFromJsonAsync < long [ ] > ( ) ;
264+ if ( messageIds == null || messageIds . Length == 0 )
265+ {
266+ httpContext . Response . StatusCode = StatusCodes . Status422UnprocessableEntity ;
267+ return ;
268+ }
269+
270+ foreach ( var messageId in messageIds )
271+ _ = await DataStorage . DeleteReceivedMessageAsync ( messageId ) ;
272+
273+ httpContext . Response . StatusCode = StatusCodes . Status204NoContent ;
274+ }
275+
276+
239277 public async Task PublishedList ( HttpContext httpContext )
240278 {
241279 if ( _agent != null && await _agent . Invoke ( httpContext ) ) return ;
@@ -293,7 +331,7 @@ public async Task ReceivedList(HttpContext httpContext)
293331 public async Task Subscribers ( HttpContext httpContext )
294332 {
295333 if ( _agent != null && await _agent . Invoke ( httpContext ) ) return ;
296-
334+
297335 var cache = _serviceProvider . GetRequiredService < MethodMatcherCache > ( ) ;
298336 var subscribers = cache . GetCandidatesMethodsOfGroupNameGrouped ( ) ;
299337
0 commit comments