1- using Botticelli . Server . Back . Services ;
1+ using System . Collections ;
2+ using Botticelli . Server . Back . Services ;
3+ using Botticelli . Server . Back . Services . Broadcasting ;
24using Botticelli . Server . Data . Entities . Bot ;
5+ using Botticelli . Server . Data . Entities . Bot . Broadcasting ;
36using Botticelli . Shared . API . Admin . Responses ;
47using Botticelli . Shared . API . Client . Requests ;
58using Botticelli . Shared . API . Client . Responses ;
@@ -17,16 +20,19 @@ namespace Botticelli.Server.Back.Controllers;
1720public class AdminController
1821{
1922 private readonly IBotManagementService _botManagementService ;
23+ private readonly IBroadcastService _broadcastService ;
2024 private readonly IBotStatusDataService _botStatusDataService ;
2125 private readonly ILogger < AdminController > _logger ;
2226
2327 public AdminController ( IBotManagementService botManagementService ,
2428 IBotStatusDataService botStatusDataService ,
25- ILogger < AdminController > logger )
29+ ILogger < AdminController > logger ,
30+ IBroadcastService broadcastService )
2631 {
2732 _botManagementService = botManagementService ;
2833 _botStatusDataService = botStatusDataService ;
2934 _logger = logger ;
35+ _broadcastService = broadcastService ;
3036 }
3137
3238 [ HttpPost ( "[action]" ) ]
@@ -64,6 +70,23 @@ public async Task<UpdateBotResponse> UpdateBot([FromBody] UpdateBotRequest reque
6470 } ;
6571 }
6672
73+ /// <summary>
74+ /// Sends a broadcast message
75+ /// </summary>
76+ /// <param name="botId"></param>
77+ /// <param name="message"></param>
78+ /// <returns></returns>
79+ [ HttpGet ( "[action]" ) ]
80+ public async Task SendBroadcast ( [ FromQuery ] string botId , [ FromQuery ] string message )
81+ {
82+ await _broadcastService . BroadcastMessage ( new Broadcast
83+ {
84+ Id = Guid . NewGuid ( ) . ToString ( ) ,
85+ BotId = botId ,
86+ Body = message
87+ } ) ;
88+ }
89+
6790 [ HttpGet ( "[action]" ) ]
6891 public async Task < ICollection < BotInfo > > GetBots ( )
6992 => _botStatusDataService . GetBots ( ) ;
@@ -76,7 +99,6 @@ public async Task ActivateBot([FromQuery] string botId)
7699 public async Task DeactivateBot ( [ FromQuery ] string botId )
77100 => await _botManagementService . SetRequiredBotStatus ( botId , BotStatus . Locked ) ;
78101
79-
80102 [ HttpGet ( "[action]" ) ]
81103 public async Task RemoveBot ( [ FromQuery ] string botId )
82104 => await _botManagementService . RemoveBot ( botId ) ;
0 commit comments