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

28 lines
784 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;
namespace Bit.Hub
{
[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
{
private readonly IHubContext<SyncHub> _syncHubContext;
2018-08-16 13:35:16 -04:00
public NotificationsController(IHubContext<SyncHub> syncHubContext)
2018-08-16 12:05:01 -04:00
{
_syncHubContext = syncHubContext;
}
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)
{
await HubHelpers.SendNotificationToHubAsync(model, _syncHubContext);
}
}
}