🐛 Fix notification via Send didn't push via ws
This commit is contained in:
parent
1f2e9b1de8
commit
e7942fc687
@ -125,9 +125,10 @@ public class NotificationService(
|
|||||||
|
|
||||||
public async Task BroadcastNotification(Notification notification, bool save = false)
|
public async Task BroadcastNotification(Notification notification, bool save = false)
|
||||||
{
|
{
|
||||||
|
var accounts = await db.Accounts.ToListAsync();
|
||||||
|
|
||||||
if (save)
|
if (save)
|
||||||
{
|
{
|
||||||
var accounts = await db.Accounts.ToListAsync();
|
|
||||||
var notifications = accounts.Select(x =>
|
var notifications = accounts.Select(x =>
|
||||||
{
|
{
|
||||||
var newNotification = new Notification
|
var newNotification = new Notification
|
||||||
@ -146,6 +147,17 @@ public class NotificationService(
|
|||||||
await db.BulkInsertAsync(notifications);
|
await db.BulkInsertAsync(notifications);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var account in accounts)
|
||||||
|
{
|
||||||
|
notification.Account = account;
|
||||||
|
notification.AccountId = account.Id;
|
||||||
|
ws.SendPacketToAccount(account.Id, new WebSocketPacket
|
||||||
|
{
|
||||||
|
Type = "notifications.new",
|
||||||
|
Data = notification
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var subscribers = await db.NotificationPushSubscriptions
|
var subscribers = await db.NotificationPushSubscriptions
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
await _PushNotification(notification, subscribers);
|
await _PushNotification(notification, subscribers);
|
||||||
@ -173,6 +185,17 @@ public class NotificationService(
|
|||||||
await db.BulkInsertAsync(notifications);
|
await db.BulkInsertAsync(notifications);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var account in accounts)
|
||||||
|
{
|
||||||
|
notification.Account = account;
|
||||||
|
notification.AccountId = account.Id;
|
||||||
|
ws.SendPacketToAccount(account.Id, new WebSocketPacket
|
||||||
|
{
|
||||||
|
Type = "notifications.new",
|
||||||
|
Data = notification
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var accountsId = accounts.Select(x => x.Id).ToList();
|
var accountsId = accounts.Select(x => x.Id).ToList();
|
||||||
var subscribers = await db.NotificationPushSubscriptions
|
var subscribers = await db.NotificationPushSubscriptions
|
||||||
.Where(s => accountsId.Contains(s.AccountId))
|
.Where(s => accountsId.Contains(s.AccountId))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user