Organization publishers, subscriptions to publishers

This commit is contained in:
2025-05-12 21:48:16 +08:00
parent b20bc3c443
commit b275f06061
14 changed files with 6197 additions and 19 deletions

View File

@ -11,7 +11,7 @@ namespace DysonNetwork.Sphere.Post;
[ApiController]
[Route("/posts")]
public class PostController(AppDatabase db, PostService ps, RelationshipService rels) : ControllerBase
public class PostController(AppDatabase db, PostService ps, RelationshipService rels, IServiceScopeFactory factory) : ControllerBase
{
[HttpGet]
public async Task<ActionResult<List<Post>>> ListPosts([FromQuery] int offset = 0, [FromQuery] int take = 20)
@ -205,6 +205,13 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
return BadRequest(err.Message);
}
_ = Task.Run(async () =>
{
using var scope = factory.CreateScope();
var subs = scope.ServiceProvider.GetRequiredService<PublisherSubscriptionService>();
await subs.NotifySubscribersPostAsync(post);
});
return post;
}