🐛 Fix chat notification subject

This commit is contained in:
LittleSheep 2025-06-01 01:47:30 +08:00
parent 7040b236e9
commit ca57faa7c3
2 changed files with 4 additions and 3 deletions

View File

@ -215,7 +215,7 @@ public class NotificationService(
["meta"] = notification.Meta ?? new Dictionary<string, object>(),
},
["mutable_content"] = true,
["priority"] = notification.Priority >= 10 ? "high" : "normal",
["priority"] = notification.Priority >= 5 ? "high" : "normal",
};
if (!string.IsNullOrWhiteSpace(notification.Title))

View File

@ -65,7 +65,8 @@ public class ChatService(
var scopedNty = scope.ServiceProvider.GetRequiredService<NotificationService>();
var scopedCrs = scope.ServiceProvider.GetRequiredService<ChatRoomService>();
var roomSubject = room.Realm is not null ? $"{room.Name}, {room.Realm.Name}" : room.Name;
var roomSubject = room is { Type: ChatRoomType.DirectMessage, Name: null } ? "DM" :
room.Realm is not null ? $"{room.Name}, {room.Realm.Name}" : room.Name;
var members = await scopedCrs.ListRoomMembers(room.Id);
@ -89,7 +90,7 @@ public class ChatService(
var notification = new Notification
{
Topic = "messages.new",
Title = $"{sender.Nick ?? sender.Account.Nick ?? "Unknown"} ({roomSubject})",
Title = $"{sender.Nick ?? sender.Account.Nick} ({roomSubject})",
Content = !string.IsNullOrEmpty(message.Content)
? message.Content[..Math.Min(message.Content.Length, 100)]
: "<no content>",