1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 09:02:48 -05:00

rename notifications api endpoint to send

This commit is contained in:
Kyle Spearrin
2018-08-24 20:31:17 -04:00
parent 816bf1546e
commit 5ecd45abd6
2 changed files with 5 additions and 5 deletions

View File

@ -0,0 +1,38 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Bit.Core.Models;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Newtonsoft.Json;
namespace Bit.Notifications
{
[Authorize("Internal")]
[SelfHosted(SelfHostedOnly = true)]
public class SendController : Controller
{
private readonly IHubContext<NotificationsHub> _hubContext;
public SendController(IHubContext<NotificationsHub> hubContext)
{
_hubContext = hubContext;
}
[HttpPost("~/send")]
public async Task PostSend()
{
using(var reader = new StreamReader(Request.Body, Encoding.UTF8))
{
var notificationJson = await reader.ReadToEndAsync();
if(!string.IsNullOrWhiteSpace(notificationJson))
{
var notification = JsonConvert.DeserializeObject<PushNotificationData<object>>(notificationJson);
await HubHelpers.SendNotificationToHubAsync(notification.Type, notificationJson, _hubContext);
}
}
}
}
}