💄 Optimize chat message notification
This commit is contained in:
@@ -515,7 +515,7 @@ public class AccountService(
|
|||||||
.AnyAsync();
|
.AnyAsync();
|
||||||
if (isExists)
|
if (isExists)
|
||||||
throw new InvalidOperationException("Contact method already exists.");
|
throw new InvalidOperationException("Contact method already exists.");
|
||||||
|
|
||||||
var contact = new AccountContact
|
var contact = new AccountContact
|
||||||
{
|
{
|
||||||
Type = type,
|
Type = type,
|
||||||
|
@@ -239,13 +239,26 @@ public partial class ChatService(
|
|||||||
{
|
{
|
||||||
Topic = "messages.new",
|
Topic = "messages.new",
|
||||||
Title = $"{sender.Nick ?? sender.Account.Nick} ({roomSubject})",
|
Title = $"{sender.Nick ?? sender.Account.Nick} ({roomSubject})",
|
||||||
Body = !string.IsNullOrEmpty(message.Content)
|
|
||||||
? message.Content[..Math.Min(message.Content.Length, 100)]
|
|
||||||
: "<no content>",
|
|
||||||
Meta = GrpcTypeHelper.ConvertObjectToByteString(metaDict),
|
Meta = GrpcTypeHelper.ConvertObjectToByteString(metaDict),
|
||||||
ActionUri = $"/chat/{room.Id}",
|
ActionUri = $"/chat/{room.Id}",
|
||||||
IsSavable = false,
|
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<Account> accountsToNotify = [];
|
List<Account> accountsToNotify = [];
|
||||||
foreach (var member in members)
|
foreach (var member in members)
|
||||||
|
Reference in New Issue
Block a user