fix: feed repitition
This commit is contained in:
@@ -56,6 +56,7 @@ type Server struct {
|
||||
collectionH *handler.CollectionHandler
|
||||
profileH *handler.ProfileHandler
|
||||
relationH *handler.RelationshipHandler
|
||||
soketiWebhookH *handler.SoketiWebhookHandler
|
||||
notificationH *handler.NotificationHandler
|
||||
sadhnaH *handler.SadhnaHandler
|
||||
pushH *handler.PushHandler
|
||||
@@ -168,7 +169,13 @@ func (s *Server) initAuth(cfg *config.Config, logger *zap.Logger) {
|
||||
likeRepo := repository.NewLikeRepo(s.pg, s.redis, logger)
|
||||
mentionRepo := repository.NewMentionRepo(s.pg)
|
||||
commentRepo := repository.NewCommentRepo(s.pg, logger)
|
||||
postSvc := service.NewPostService(postRepo, r2, likeRepo, mentionRepo, commentRepo)
|
||||
// Per-user "already served" set so the home feed never repeats posts
|
||||
// across pages (nil-safe — falls back to offset paging without Redis).
|
||||
feedRepo := repository.NewFeedRepo(s.redis, logger)
|
||||
postSvc := service.NewPostService(postRepo, r2, likeRepo, mentionRepo, commentRepo, feedRepo)
|
||||
// Soketi signs webhooks with the app secret; on channel_vacated for a
|
||||
// per-user notifications channel we evict that user's feed seen-set.
|
||||
s.soketiWebhookH = handler.NewSoketiWebhookHandler(cfg.SoketiAppKey, cfg.SoketiAppSecret, feedRepo, logger)
|
||||
bookmarkSvc := service.NewBookmarkService(userRepo, bookmarkRepo)
|
||||
collectionSvc := service.NewCollectionService(userRepo, collectionRepo, postRepo, r2)
|
||||
|
||||
@@ -765,6 +772,13 @@ func (s *Server) setupRouter() {
|
||||
// present, so the feed can carry `viewer_has_reshared` on each
|
||||
// post. Without a cookie the routes still respond — they just
|
||||
// return the anonymous shape (all-false).
|
||||
// Soketi webhooks — server-to-server, authenticated by the HMAC
|
||||
// signature (not a session). channel_vacated on a per-user
|
||||
// notifications channel evicts that user's feed seen-set.
|
||||
if s.soketiWebhookH != nil {
|
||||
r.Post("/webhooks/soketi", s.soketiWebhookH.Handle)
|
||||
}
|
||||
|
||||
// Home feed — the global, personalised feed of posts + its "new on
|
||||
// the platform" discovery strip. Auth-required (the feed is
|
||||
// per-viewer: ordering + relationship flags depend on the caller).
|
||||
@@ -777,6 +791,8 @@ func (s *Server) setupRouter() {
|
||||
r.Use(middleware.RequireAuth(s.authIssuer, s.userRepo))
|
||||
r.Get("/", s.postH.Feed)
|
||||
r.Get("/new-users", s.postH.FeedNewUsers)
|
||||
// Clear the per-user seen-set (logout / page unload).
|
||||
r.Post("/reset", s.postH.FeedReset)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user