feat: add feed
This commit is contained in:
@@ -245,6 +245,36 @@ func (h *PostHandler) ListMine(w http.ResponseWriter, r *http.Request) {
|
||||
response.JSONWithMeta(w, http.StatusOK, posts, paginationMeta(total, limit, offset))
|
||||
}
|
||||
|
||||
// Feed — GET /feed?limit=&offset=. The global personalised home feed (auth
|
||||
// required). Returns at most `limit` posts; the client infers "more" from a
|
||||
// full page (no total count for an unbounded global feed).
|
||||
func (h *PostHandler) Feed(w http.ResponseWriter, r *http.Request) {
|
||||
uid := middleware.UserID(r.Context())
|
||||
limit, offset := parseLimitOffset(r)
|
||||
posts, err := h.svc.Feed(r.Context(), uid, limit, offset)
|
||||
if err != nil {
|
||||
mapSocialErr(w, err)
|
||||
return
|
||||
}
|
||||
response.JSON(w, http.StatusOK, posts)
|
||||
}
|
||||
|
||||
// FeedNewUsers — GET /feed/new-users. Up to 5 accounts that joined in the last
|
||||
// 24h, for the feed's "new on the platform" discovery strip. Returns [] when
|
||||
// there are none (the client hides the section).
|
||||
func (h *PostHandler) FeedNewUsers(w http.ResponseWriter, r *http.Request) {
|
||||
uid := middleware.UserID(r.Context())
|
||||
users, err := h.graph.NewUsers(r.Context(), uid, 5)
|
||||
if err != nil {
|
||||
mapSocialErr(w, err)
|
||||
return
|
||||
}
|
||||
if users == nil {
|
||||
users = []model.UserSummary{}
|
||||
}
|
||||
response.JSON(w, http.StatusOK, users)
|
||||
}
|
||||
|
||||
type replaceImagesReq struct {
|
||||
ImageURLs []string `json:"image_urls"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user