🐛 Trying to fix chat notification
This commit is contained in:
parent
0bbd322c2e
commit
b7960e3060
@ -73,7 +73,7 @@ public class ChatService(
|
|||||||
var notification = new Notification
|
var notification = new Notification
|
||||||
{
|
{
|
||||||
Topic = "messages.new",
|
Topic = "messages.new",
|
||||||
Title = $"{sender.Nick ?? sender.Account.Nick} ({roomSubject})",
|
Title = $"{sender.Nick ?? sender.Account?.Nick ?? "Unknown"} ({roomSubject})",
|
||||||
Content = !string.IsNullOrEmpty(message.Content)
|
Content = !string.IsNullOrEmpty(message.Content)
|
||||||
? message.Content[..Math.Min(message.Content.Length, 100)]
|
? message.Content[..Math.Min(message.Content.Length, 100)]
|
||||||
: "<attachments>",
|
: "<attachments>",
|
||||||
@ -90,17 +90,25 @@ public class ChatService(
|
|||||||
List<Account.Account> accountsToNotify = [];
|
List<Account.Account> accountsToNotify = [];
|
||||||
foreach (var member in members)
|
foreach (var member in members)
|
||||||
{
|
{
|
||||||
|
// Send WebSocket packet
|
||||||
scopedWs.SendPacketToAccount(member.AccountId, new WebSocketPacket
|
scopedWs.SendPacketToAccount(member.AccountId, new WebSocketPacket
|
||||||
{
|
{
|
||||||
Type = type,
|
Type = type,
|
||||||
Data = message
|
Data = message
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Only add accounts that aren't null
|
||||||
|
if (member.AccountId != sender.AccountId)
|
||||||
accountsToNotify.Add(member.Account);
|
accountsToNotify.Add(member.Account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.LogInformation($"Trying to deliver message to {accountsToNotify.Count} accounts...");
|
||||||
|
// Only send notifications if there are accounts to notify
|
||||||
|
if (accountsToNotify.Count > 0)
|
||||||
tasks.Add(scopedNty.SendNotificationBatch(notification, accountsToNotify, save: false));
|
tasks.Add(scopedNty.SendNotificationBatch(notification, accountsToNotify, save: false));
|
||||||
|
|
||||||
await Task.WhenAll(tasks);
|
await Task.WhenAll(tasks);
|
||||||
|
logger.LogInformation($"Delivered message to {accountsToNotify.Count} accounts.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -44,7 +44,7 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
builder.Host.UseContentRoot(Directory.GetCurrentDirectory());
|
builder.Host.UseContentRoot(Directory.GetCurrentDirectory());
|
||||||
builder.WebHost.ConfigureKestrel(options =>
|
builder.WebHost.ConfigureKestrel(options =>
|
||||||
{
|
{
|
||||||
options.Limits.MaxRequestBodySize = long.MaxValue;
|
options.Limits.MaxRequestBodySize = 50 * 1024 * 1024;
|
||||||
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2);
|
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2);
|
||||||
options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(30);
|
options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(30);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user