Esempio n. 1
0
//
// 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),
	})
}
Esempio n. 2
0
//
// 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),
	})
}
Esempio n. 3
0
func form(c *echo.Context, key string) string {
	return c.Request().FormValue(key)
}