// // GET /library/newepisodes // func getNewEpisodes(c *echo.Context) error { now := time.Now().Unix() user := c.Get("user").(*User) since := c.Request().URL.Query().Get("since") if since == "" { return c.JSON(200, newEpisodes{ Timestamp: now, Episodes: store.GetEpisodesSince(0, user.Subscriptions), }) } ts, err := strconv.ParseInt(since, 10, 64) if err != nil { return c.NoContent(400) } return c.JSON(200, newEpisodes{ Timestamp: now, Episodes: store.GetEpisodesSince(ts, user.Subscriptions), }) }
// // GET /library/events // func getEvents(c *echo.Context) error { now := time.Now().Unix() var err error var ts uint64 since := c.Request().URL.Query().Get("since") if since != "" { ts, err = strconv.ParseUint(since, 10, 64) if err != nil { return c.NoContent(400) } } user := c.Get("user").(*User) uuid := "" excludeSelf := c.Request().URL.Query().Get("exclude_self") if excludeSelf == "true" { uuid = c.Get("uuid").(string) } return c.JSON(200, events{ Timestamp: now, Events: store.GetEvents(user.ID, ts, uuid), }) }
func form(c *echo.Context, key string) string { return c.Request().FormValue(key) }