Files
server/src/Notifications/Controllers/SendController.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
981 B
C#
Raw Normal View History

using System.Text;
2018-08-16 12:05:01 -04:00
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
namespace Bit.Notifications
2018-08-16 12:05:01 -04:00
{
[Authorize("Internal")]
public class SendController : Controller
2022-08-29 14:53:16 -04:00
{
private readonly IHubContext<NotificationsHub> _hubContext;
2018-08-16 12:05:01 -04:00
public SendController(IHubContext<NotificationsHub> hubContext)
{
_hubContext = hubContext;
}
[HttpPost("~/send")]
[SelfHosted(SelfHostedOnly = true)]
public async Task PostSend()
2018-08-16 12:05:01 -04:00
{
using (var reader = new StreamReader(Request.Body, Encoding.UTF8))
{
var notificationJson = await reader.ReadToEndAsync();
if (!string.IsNullOrWhiteSpace(notificationJson))
{
await HubHelpers.SendNotificationToHubAsync(notificationJson, _hubContext);
}
}
2018-08-16 12:05:01 -04:00
}
}
}