func()

in rellenv/empcheck/empcheck.go [55:85]


func (c *Checker) Check(id uint64) bool {
	if is, ok := c.Cache.Get(cacheKey(id)); ok {
		return is.(bool)
	}

	values, err := fbapi.ParamValues(c.App, fields)
	if err != nil {
		c.Logger.Printf("Ignoring error in IsEmployee ParamValues: %s", err)
		return false
	}

	var user user
	u := url.URL{
		Path:     strconv.FormatUint(id, 10),
		RawQuery: values.Encode(),
	}
	req := http.Request{Method: "GET", URL: &u}
	_, err = c.FbApiClient.Do(&req, &user)
	if err != nil {
		if apiErr, ok := err.(*fbapi.Error); ok {
			if apiErr.Code == 100 { // common error with test users
				return false
			}
		}
		c.Logger.Printf("Ignoring error in IsEmployee FbApiClient.Do: %s", err)
		return false
	}

	c.Cache.Add(cacheKey(id), user.IsEmployee)
	return user.IsEmployee
}