🐛 Fixes bugs

This commit is contained in:
LittleSheep 2025-05-05 01:49:59 +08:00
parent 7e7c8fe556
commit 2206676214
2 changed files with 6 additions and 5 deletions

View File

@ -97,7 +97,7 @@ public class AccountController(
},
expiredAt: SystemClock.Instance.GetCurrentInstant().Plus(Duration.FromDays(7))
);
spells.NotifyMagicSpell(spell);
await spells.NotifyMagicSpell(spell, true);
return account;
}

View File

@ -37,11 +37,12 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
.Take(take)
.ToListAsync();
posts = PostService.TruncatePostContent(posts);
var postsId = posts.Select(e => e.Id).ToList();
var reactionMaps = await ps.GetPostReactionMapBatch(postsId);
foreach (var post in posts)
post.ReactionsCount = reactionMaps[post.Id];
post.ReactionsCount =
reactionMaps.TryGetValue(post.Id, out var count) ? count : new Dictionary<string, int>();
Response.Headers["X-Total"] = totalCount.ToString();
@ -104,7 +105,7 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
.Take(take)
.ToListAsync();
posts = PostService.TruncatePostContent(posts);
var postsId = posts.Select(e => e.Id).ToList();
var reactionMaps = await ps.GetPostReactionMapBatch(postsId);
foreach (var post in posts)
@ -241,7 +242,7 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
AccountId = currentUser.Id
};
await ps.ModifyPostVotes(post, reaction, isExistingReaction);
if (isExistingReaction) return NoContent();
return Ok(reaction);
}