🐛 Fix chat notification and listing members
This commit is contained in:
@ -181,19 +181,12 @@ public class NotificationService
|
|||||||
{
|
{
|
||||||
if (save)
|
if (save)
|
||||||
{
|
{
|
||||||
// Create new notification objects for each account instead of reusing
|
var notifications = accounts.Select(x =>
|
||||||
var notifications = accounts.Select(x => new Notification
|
|
||||||
{
|
{
|
||||||
Topic = notification.Topic,
|
notification.Account = x;
|
||||||
Title = notification.Title,
|
notification.AccountId = x.Id;
|
||||||
Subtitle = notification.Subtitle,
|
return notification;
|
||||||
Content = notification.Content,
|
|
||||||
Meta = notification.Meta != null ? new Dictionary<string, object>(notification.Meta) : null,
|
|
||||||
Priority = notification.Priority,
|
|
||||||
Account = x,
|
|
||||||
AccountId = x.Id
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
await _db.BulkInsertAsync(notifications);
|
await _db.BulkInsertAsync(notifications);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,20 +194,12 @@ public class NotificationService
|
|||||||
var subscribers = await _db.NotificationPushSubscriptions
|
var subscribers = await _db.NotificationPushSubscriptions
|
||||||
.Where(s => accountsId.Contains(s.AccountId))
|
.Where(s => accountsId.Contains(s.AccountId))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
var tasks = new List<Task>();
|
||||||
var tasks = (from subscriber in subscribers
|
foreach (var subscriber in subscribers)
|
||||||
let notificationCopy = new Notification
|
|
||||||
{
|
{
|
||||||
Id = notification.Id,
|
notification.AccountId = subscriber.AccountId;
|
||||||
Topic = notification.Topic,
|
tasks.Add(_PushSingleNotification(notification, subscriber));
|
||||||
Title = notification.Title,
|
|
||||||
Subtitle = notification.Subtitle,
|
|
||||||
Content = notification.Content,
|
|
||||||
Meta = notification.Meta != null ? new Dictionary<string, object>(notification.Meta) : null,
|
|
||||||
Priority = notification.Priority,
|
|
||||||
AccountId = subscriber.AccountId
|
|
||||||
}
|
}
|
||||||
select _PushSingleNotification(notificationCopy, subscriber)).ToList();
|
|
||||||
|
|
||||||
await Task.WhenAll(tasks);
|
await Task.WhenAll(tasks);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ public class ChatRoomService(AppDatabase db, ICacheService cache)
|
|||||||
return cachedMembers;
|
return cachedMembers;
|
||||||
|
|
||||||
var members = await db.ChatMembers
|
var members = await db.ChatMembers
|
||||||
|
.Include(m => m.Account)
|
||||||
|
.ThenInclude(m => m.Profile)
|
||||||
.Where(m => m.ChatRoomId == roomId)
|
.Where(m => m.ChatRoomId == roomId)
|
||||||
.Where(m => m.JoinedAt != null)
|
.Where(m => m.JoinedAt != null)
|
||||||
.Where(m => m.LeaveAt == null)
|
.Where(m => m.LeaveAt == null)
|
||||||
|
@ -98,7 +98,7 @@ public class ChatService(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Only add accounts that aren't null
|
// Only add accounts that aren't null
|
||||||
if (member.AccountId != sender.AccountId)
|
if (member.Account.Id != sender.AccountId)
|
||||||
accountsToNotify.Add(member.Account);
|
accountsToNotify.Add(member.Account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user