🐛 Fix bugs of subscription

This commit is contained in:
LittleSheep 2025-06-22 00:08:27 +08:00
parent bf40b51c41
commit 38abe16ba6

View File

@ -1,4 +1,5 @@
using DysonNetwork.Sphere.Account; using DysonNetwork.Sphere.Account;
using DysonNetwork.Sphere.Localization;
using DysonNetwork.Sphere.Post; using DysonNetwork.Sphere.Post;
using DysonNetwork.Sphere.Storage; using DysonNetwork.Sphere.Storage;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -10,7 +11,7 @@ public class PublisherSubscriptionService(
AppDatabase db, AppDatabase db,
NotificationService nty, NotificationService nty,
PostService ps, PostService ps,
IStringLocalizer<Notification> localizer, IStringLocalizer<NotificationResource> localizer,
ICacheService cache ICacheService cache
) )
{ {
@ -49,9 +50,9 @@ public class PublisherSubscriptionService(
public async Task<int> NotifySubscriberPost(Post.Post post) public async Task<int> NotifySubscriberPost(Post.Post post)
{ {
var subscribers = await db.PublisherSubscriptions var subscribers = await db.PublisherSubscriptions
.Include(ps => ps.Account) .Include(p => p.Account)
.Where(ps => ps.PublisherId == post.Publisher.Id && .Where(p => p.PublisherId == post.PublisherId &&
ps.Status == SubscriptionStatus.Active) p.Status == SubscriptionStatus.Active)
.ToListAsync(); .ToListAsync();
if (subscribers.Count == 0) if (subscribers.Count == 0)
return 0; return 0;