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

28 lines
792 B
C#
Raw Normal View History

2018-08-16 12:05:01 -04:00
using System.Threading.Tasks;
using Bit.Core.Models;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
2018-08-16 13:45:31 -04:00
namespace Bit.Notifications
2018-08-16 12:05:01 -04:00
{
[Authorize("Internal")]
[SelfHosted(SelfHostedOnly = true)]
2018-08-16 13:35:16 -04:00
public class NotificationsController : Controller
2018-08-16 12:05:01 -04:00
{
2018-08-16 13:45:31 -04:00
private readonly IHubContext<NotificationsHub> _hubContext;
2018-08-16 12:05:01 -04:00
2018-08-16 13:45:31 -04:00
public NotificationsController(IHubContext<NotificationsHub> hubContext)
2018-08-16 12:05:01 -04:00
{
2018-08-16 13:45:31 -04:00
_hubContext = hubContext;
2018-08-16 12:05:01 -04:00
}
2018-08-16 13:35:16 -04:00
[HttpPost("~/notifications")]
2018-08-16 12:05:01 -04:00
public async Task PostNotification([FromBody]PushNotificationData<object> model)
{
2018-08-16 13:45:31 -04:00
await HubHelpers.SendNotificationToHubAsync(model, _hubContext);
2018-08-16 12:05:01 -04:00
}
}
}