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

support message pack protocol for signalr

This commit is contained in:
Kyle Spearrin
2018-08-23 21:56:48 -04:00
parent d458d77511
commit 68c349f72f
6 changed files with 62 additions and 37 deletions

View File

@ -1,9 +1,12 @@
using System.Threading.Tasks;
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
{
@ -19,9 +22,17 @@ namespace Bit.Notifications
}
[HttpPost("~/notifications")]
public async Task PostNotification([FromBody]PushNotificationData<object> model)
public async Task PostNotification()
{
await HubHelpers.SendNotificationToHubAsync(model, _hubContext);
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);
}
}
}
}
}