コード例 #1
0
func HandleGetHomeTimeline(r render.Render, limit Limit, db *models.DB, backchannel Backchannel) {
	timeline, err := db.GetAllIMs(limit.GetLimit() + uint32(1))
	if err != nil {
		r.JSON(500, JsonErr("Internal error: "+err.Error()))
		return
	}
	for _, im := range timeline {
		err = db.AnnotateHearted(im, backchannel.UserId())
		if err != nil {
			log.Println("Error annotating hearted info:", err.Error())
			r.JSON(500, "Sorry, an internal server error has occurred.")
			return
		}
	}
	hasMore, timeline := hasMoreTimeline(limit, timeline)
	r.JSON(200, map[string]interface{}{
		"timeline": timeline,
		"hasMore":  hasMore,
	})
}