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:
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
27
src/Hub/Controllers/NotificationController.cs
Normal file
27
src/Hub/Controllers/NotificationController.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user