From 29403b09d2d1c5766f43ebb42ac22e4f3c48513c Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 24 Jul 2025 14:43:00 +0800 Subject: [PATCH] :bug: Fix push notification didn't contains custom category identifier --- DysonNetwork.Pusher/Notification/Notification.cs | 2 +- DysonNetwork.Pusher/Notification/PushService.cs | 5 +++-- DysonNetwork.Pusher/Services/PusherServiceGrpc.cs | 2 +- DysonNetwork.Sphere/Chat/ChatService.cs | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/DysonNetwork.Pusher/Notification/Notification.cs b/DysonNetwork.Pusher/Notification/Notification.cs index 6799022..676b14c 100644 --- a/DysonNetwork.Pusher/Notification/Notification.cs +++ b/DysonNetwork.Pusher/Notification/Notification.cs @@ -14,7 +14,7 @@ public class Notification : ModelBase [MaxLength(1024)] public string? Title { get; set; } [MaxLength(2048)] public string? Subtitle { get; set; } [MaxLength(4096)] public string? Content { get; set; } - [Column(TypeName = "jsonb")] public Dictionary? Meta { get; set; } + [Column(TypeName = "jsonb")] public Dictionary Meta { get; set; } public int Priority { get; set; } = 10; public Instant? ViewedAt { get; set; } diff --git a/DysonNetwork.Pusher/Notification/PushService.cs b/DysonNetwork.Pusher/Notification/PushService.cs index 6ac612e..b5f9f1c 100644 --- a/DysonNetwork.Pusher/Notification/PushService.cs +++ b/DysonNetwork.Pusher/Notification/PushService.cs @@ -238,7 +238,7 @@ public class PushService { ["id"] = notification.Id, ["topic"] = notification.Topic, - ["meta"] = notification.Meta ?? new Dictionary() + ["meta"] = notification.Meta } } }); @@ -259,13 +259,14 @@ public class PushService var payload = new Dictionary { ["topic"] = _apnsTopic, + ["type"] = notification.Topic, ["aps"] = new Dictionary { ["alert"] = alertDict, ["sound"] = notification.Priority >= 5 ? "default" : null, ["mutable-content"] = 1 }, - ["meta"] = notification.Meta ?? new Dictionary() + ["meta"] = notification.Meta }; await _apns.SendAsync( diff --git a/DysonNetwork.Pusher/Services/PusherServiceGrpc.cs b/DysonNetwork.Pusher/Services/PusherServiceGrpc.cs index e83d418..728aae1 100644 --- a/DysonNetwork.Pusher/Services/PusherServiceGrpc.cs +++ b/DysonNetwork.Pusher/Services/PusherServiceGrpc.cs @@ -107,7 +107,7 @@ public class PusherServiceGrpc( Topic = request.Notification.Topic, Title = request.Notification.Title, Subtitle = request.Notification.Subtitle, Content = request.Notification.Body, - Meta = GrpcTypeHelper.ConvertFromValueMap(request.Notification.Meta), + Meta = GrpcTypeHelper.ConvertFromValueMap(request.Notification.Meta) }; if (request.Notification.ActionUri is not null) notification.Meta["action_uri"] = request.Notification.ActionUri; diff --git a/DysonNetwork.Sphere/Chat/ChatService.cs b/DysonNetwork.Sphere/Chat/ChatService.cs index 38099e3..173969f 100644 --- a/DysonNetwork.Sphere/Chat/ChatService.cs +++ b/DysonNetwork.Sphere/Chat/ChatService.cs @@ -220,7 +220,6 @@ public partial class ChatService( ["images"] = message.Attachments .Where(a => a.MimeType != null && a.MimeType.StartsWith("image")) .Select(a => a.Id).ToList(), - ["action_uri"] = $"/chat/{room.Id}" }; if (sender.Account.Profile is not { Picture: null }) metaDict["pfp"] = sender.Account.Profile.Picture.Id; @@ -234,7 +233,8 @@ public partial class ChatService( Body = !string.IsNullOrEmpty(message.Content) ? message.Content[..Math.Min(message.Content.Length, 100)] : "", - IsSavable = false + ActionUri = $"/chat/{room.Id}", + IsSavable = false, }; notification.Meta.Add(GrpcTypeHelper.ConvertToValueMap(metaDict));