feat(epic-4): synchro multi-appareils, outils d'admin et optimisations performance

This commit is contained in:
Michael committed 2026-02-04 15:17:59 +01:00
1 parent dc26f22f51
commit 8777d3b970
10 files changed
+200 -27

No files matched your search

+28 -1
View File
@@ -9,6 +9,7 @@ import (
"github.com/michael/flowreader/internal/domain"
"github.com/michael/flowreader/internal/service"
"github.com/michael/flowreader/internal/utils"
"github.com/michael/flowreader/internal/ws"
)
// ArticleHandler handles article-related HTTP requests.
@@ -17,15 +18,17 @@ type ArticleHandler struct {
feedService *service.FeedService
authService *service.AuthService
sanitizer *utils.ContentSanitizer
hub *ws.Hub
}
// NewArticleHandler creates a new article handler.
func NewArticleHandler(articleRepo domain.ArticleRepository, feedService *service.FeedService, authService *service.AuthService) *ArticleHandler {
func NewArticleHandler(articleRepo domain.ArticleRepository, feedService *service.FeedService, authService *service.AuthService, hub *ws.Hub) *ArticleHandler {
return &ArticleHandler{
articleRepo: articleRepo,
feedService: feedService,
authService: authService,
sanitizer: utils.NewContentSanitizer(),
hub: hub,
}
}
@@ -184,6 +187,14 @@ func (h *ArticleHandler) MarkRead(w http.ResponseWriter, r *http.Request) {
return
}
// Broadcast update
if h.hub != nil {
h.hub.Broadcast("article_updated", map[string]interface{}{
"id": articleID,
"is_read": true,
})
}
respondJSON(w, http.StatusOK, map[string]bool{"is_read": true})
}
@@ -219,6 +230,14 @@ func (h *ArticleHandler) MarkUnread(w http.ResponseWriter, r *http.Request) {
return
}
// Broadcast update
if h.hub != nil {
h.hub.Broadcast("article_updated", map[string]interface{}{
"id": articleID,
"is_read": false,
})
}
respondJSON(w, http.StatusOK, map[string]bool{"is_read": false})
}
@@ -254,6 +273,14 @@ func (h *ArticleHandler) ToggleFavorite(w http.ResponseWriter, r *http.Request)
return
}
// Broadcast update
if h.hub != nil {
h.hub.Broadcast("article_updated", map[string]interface{}{
"id": articleID,
"is_favorite": !article.IsFavorite,
})
}
respondJSON(w, http.StatusOK, map[string]bool{"is_favorite": !article.IsFavorite})
}