♻️ Refactored notification meta

This commit is contained in:
2025-11-23 13:20:40 +08:00
parent 2b95d58611
commit c42befed6b
2 changed files with 21 additions and 18 deletions

View File

@@ -60,22 +60,19 @@ public class PublisherSubscriptionService(
var (title, message) = ps.ChopPostForNotification(post);
// Data to include with the notification
var images = new List<string>();
if (post.Attachments.Any(p => p.MimeType?.StartsWith("image/") ?? false))
images.AddRange(
post.Attachments
.Where(p => p.MimeType?.StartsWith("image/") ?? false)
.Select(p => p.Id)
);
else if (post.Publisher.Picture is not null) images.Add(post.Publisher.Picture.Id);
var data = new Dictionary<string, object>
{
["post_id"] = post.Id,
["publisher_id"] = post.Publisher.Id.ToString(),
["images"] = images,
["publisher_id"] = post.Publisher.Id.ToString()
};
if (post.Attachments.Any(p => p.MimeType?.StartsWith("image/") ?? false))
data["image"] =
post.Attachments
.Where(p => p.MimeType?.StartsWith("image/") ?? false)
.Select(p => p.Id).First();
if (post.Publisher.Picture is not null) data["pfp"] = post.Publisher.Picture.Id;
// Gather subscribers
var subscribers = await db.PublisherSubscriptions
.Where(p => p.PublisherId == post.PublisherId &&