1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 17:42:49 -05:00

hub api notifications

This commit is contained in:
Kyle Spearrin
2018-08-16 12:05:01 -04:00
parent ff01ce5ca7
commit 28e6783a00
22 changed files with 320 additions and 179 deletions

View File

@ -1,25 +0,0 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
namespace Bit.Hub
{
[Authorize("Internal")]
public class EventsController : Controller
{
private readonly IHubContext<SyncHub> _syncHubContext;
public EventsController(IHubContext<SyncHub> syncHubContext)
{
_syncHubContext = syncHubContext;
}
[HttpGet("~/events")]
public async Task GetTest()
{
await _syncHubContext.Clients.All.SendAsync("ReceiveMessage", "From API.");
}
}
}

View File

@ -0,0 +1,27 @@
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)]
public class NotificationController : Controller
{
private readonly IHubContext<SyncHub> _syncHubContext;
public NotificationController(IHubContext<SyncHub> syncHubContext)
{
_syncHubContext = syncHubContext;
}
[HttpPost("~/notification")]
public async Task PostNotification([FromBody]PushNotificationData<object> model)
{
await HubHelpers.SendNotificationToHubAsync(model, _syncHubContext);
}
}
}