From 0b44c4547c37a3dc4c35948e661f318834f3e6f9 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 10 Aug 2025 12:24:34 +0800 Subject: [PATCH] :lipstick: Optimize chat message notification --- DysonNetwork.Pass/Account/AccountService.cs | 2 +- DysonNetwork.Sphere/Chat/ChatService.cs | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/DysonNetwork.Pass/Account/AccountService.cs b/DysonNetwork.Pass/Account/AccountService.cs index 0aee522..1c2da5b 100644 --- a/DysonNetwork.Pass/Account/AccountService.cs +++ b/DysonNetwork.Pass/Account/AccountService.cs @@ -515,7 +515,7 @@ public class AccountService( .AnyAsync(); if (isExists) throw new InvalidOperationException("Contact method already exists."); - + var contact = new AccountContact { Type = type, diff --git a/DysonNetwork.Sphere/Chat/ChatService.cs b/DysonNetwork.Sphere/Chat/ChatService.cs index d2e79ec..162aa5c 100644 --- a/DysonNetwork.Sphere/Chat/ChatService.cs +++ b/DysonNetwork.Sphere/Chat/ChatService.cs @@ -239,13 +239,26 @@ public partial class ChatService( { Topic = "messages.new", Title = $"{sender.Nick ?? sender.Account.Nick} ({roomSubject})", - Body = !string.IsNullOrEmpty(message.Content) - ? message.Content[..Math.Min(message.Content.Length, 100)] - : "", Meta = GrpcTypeHelper.ConvertObjectToByteString(metaDict), ActionUri = $"/chat/{room.Id}", IsSavable = false, }; + if (message.DeletedAt is not null) + notification.Body = "Deleted a message"; + switch (message.Type) + { + case "call.ended": + notification.Body = "Call ended"; + break; + case "call.start": + notification.Body = "Call begun"; + break; + default: + notification.Body = !string.IsNullOrEmpty(message.Content) + ? message.Content[..Math.Min(message.Content.Length, 100)] + : $"<{message.Attachments.Count} attachments>"; + break; + } List accountsToNotify = []; foreach (var member in members)