👔 Optimize push notification logic

This commit is contained in:
2025-11-11 00:38:43 +08:00
parent 68cd23d64f
commit f7b3926338

View File

@@ -463,22 +463,6 @@ public class PersistentTaskService(
UserId = task.AccountId.ToString(), UserId = task.AccountId.ToString(),
Packet = wsPacket Packet = wsPacket
}); });
// Push notification
var pushNotification = new PushNotification
{
Topic = "drive.tasks",
Title = "Task Completed",
Subtitle = task.Name,
Body = $"Your {task.Type.ToString().ToLower()} task has completed successfully.",
IsSavable = true
};
await ringService.SendPushNotificationToUserAsync(new SendPushNotificationToUserRequest
{
UserId = task.AccountId.ToString(),
Notification = pushNotification
});
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -516,7 +500,7 @@ public class PersistentTaskService(
var pushNotification = new PushNotification var pushNotification = new PushNotification
{ {
Topic = "drive.tasks", Topic = "drive.tasks",
Title = "Task Failed", Title = "Drive Task Failed",
Subtitle = task.Name, Subtitle = task.Name,
Body = $"Your {task.Type.ToString().ToLower()} task has failed.", Body = $"Your {task.Type.ToString().ToLower()} task has failed.",
IsSavable = true IsSavable = true
@@ -927,22 +911,6 @@ public class PersistentTaskService(
UserId = task.AccountId.ToString(), UserId = task.AccountId.ToString(),
Packet = wsPacket Packet = wsPacket
}); });
// Send push notification
var pushNotification = new PushNotification
{
Topic = "drive.tasks.upload",
Title = "Upload Completed",
Subtitle = task.FileName,
Body = $"Your file '{task.FileName}' has been uploaded successfully.",
IsSavable = true
};
await ringService.SendPushNotificationToUserAsync(new SendPushNotificationToUserRequest
{
UserId = task.AccountId.ToString(),
Notification = pushNotification
});
} }
catch (Exception ex) catch (Exception ex)
{ {