// UserFollowing handles the request and returns the user following
167164
func UserFollowing() echo.HandlerFunc {

	// swagger:route GET /users/{id}/following/users users info following GetUserFollowing
	//
	// Shows the following informations for the specified user
	//
	// You can personalize the request via query string parameters
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile:read
	//
	//	Responses:
	//		default: UsersIdFollowingUsers

	return func(c echo.Context) error {
		if !rest.IsGranted("profile:read", c) {
			return rest.InvalidScopeResponse("profile:read", c)
		}
		following := c.Get("other").(*nerdz.User).UserFollowing()
		return rest.SelectFields(rest.GetUsersInfo(following), c)
	}
}
13409
func (s *Service) FindUserByID(ctx context.Context, id influxdb.ID) (*influxdb.User, error) {
	var u *influxdb.User

	err := s.kv.View(ctx, func(tx Tx) error {
		usr, err := s.findUserByID(ctx, tx, id)
		if err != nil {
			return err
		}
		u = usr
		return nil
	})

	if err != nil {
		return nil, err
	}

	return u, nil
}
921370
func (c *Client) FindUserByID(ctx context.Context, id platform.ID) (*platform.User, error) {
	var u *platform.User

	err := c.db.View(func(tx *bolt.Tx) error {
		usr, pe := c.findUserByID(ctx, tx, id)
		if pe != nil {
			return pe
		}
		u = usr
		return nil
	})

	if err != nil {
		return nil, &platform.Error{
			Op:  getOp(platform.OpFindUserByID),
			Err: err,
		}
	}

	return u, nil
}
1061754
func (u *User) Profile() (interface{}, error) {
	urlStr := GetApiBaseURL() + "/user/"
	return u.c.execute("GET", urlStr, "")
}
967079
func CheckMyFollowing(c *context.APIContext) {
	target := GetUserByParams(c)
	if c.Written() {
		return
	}
	checkUserFollowing(c, c.User, target.ID)
}
1256460
func (c *Client) FindUser(ctx context.Context, filter platform.UserFilter) (*platform.User, error) {
	var u *platform.User
	var err error
	op := getOp(platform.OpFindUser)
	if filter.ID != nil {
		u, err = c.FindUserByID(ctx, *filter.ID)
		if err != nil {
			return nil, &platform.Error{
				Op:  op,
				Err: err,
			}
		}
		return u, nil
	}

	if filter.Name != nil {
		u, err = c.FindUserByName(ctx, *filter.Name)
		if err != nil {
			return nil, &platform.Error{
				Op:  op,
				Err: err,
			}
		}
		return u, nil
	}

	return nil, &platform.Error{
		Code: platform.ENotFound,
		Msg:  "user not found",
	}
}
217384
func GetFollowing(client ClientInterface, offset, limit uint) (*FollowingList, error) {
	params := setParamsUint(uint64(limit), url.Values{}, "limit")
	params = setParamsUint(uint64(offset), params, "offset")
	result, err := client.GetWithParams("/user/following", params)
	if err != nil {
		return nil, err
	}
	response := struct {
		Response FollowingList `json:"response"`
	}{
		Response: FollowingList{
			client: client,
			limit:  limit,
			offset: offset,
		},
	}
	if err = json.Unmarshal(result.body, &response); err != nil {
		return nil, err
	}
	return &response.Response, nil
}
585998
func (user *User) NumericProjectFollowing() (following []uint64) {
	Db().Model(ProjectFollower{}).Where(&ProjectFollower{From: user.ID()}).Pluck(`"to"`, &following)
	return
}
474026
func (c *Client) FindUser(ctx context.Context, filter platform.UserFilter) (*platform.User, error) {
	var u *platform.User
	var err error
	op := getOp(platform.OpFindUser)
	if filter.ID != nil {
		u, err = c.FindUserByID(ctx, *filter.ID)
		if err != nil {
			return nil, &platform.Error{
				Op:  op,
				Err: err,
			}
		}
		return u, nil
	}

	if filter.Name != nil {
		u, err = c.FindUserByName(ctx, *filter.Name)
		if err != nil {
			return nil, &platform.Error{
				Op:  op,
				Err: err,
			}
		}
		return u, nil
	}

	filterFn := filterUsersFn(filter)

	err = c.db.View(func(tx *bolt.Tx) error {
		return forEachUser(ctx, tx, func(usr *platform.User) bool {
			if filterFn(usr) {
				u = usr
				return false
			}
			return true
		})
	})

	if err != nil {
		return nil, &platform.Error{
			Op:  op,
			Err: err,
		}
	}

	if u == nil {
		return nil, &platform.Error{
			Code: platform.ENotFound,
			Msg:  "user not found",
		}
	}

	return u, nil
}
96103
func (bot *Bot) usersLookup(ids []int64) (*apiResult, error) {
	if len(ids) > 100 {
		return nil, errors.New("Too many ids!")
	}
	strIds := make([]string, len(ids))
	for i, id := range ids {
		strIds[i] = strconv.FormatInt(id, 10)
	}
	query := url.Values{}
	query.Set("user_id", strings.Join(strIds, ","))

	// get users
	users := make([]User, len(ids))
	rateLimit, err := bot.request(post, "/users/lookup.json", query, &users)
	if err != nil {
		return nil, err
	}
	return &apiResult{
		results:   users,
		rateLimit: rateLimit,
	}, nil
}
1177967
func GetUserInfo(user *nerdz.User) *UserInfo {
	var info UserInfo
	info.Info = user.Info().GetTO()
	info.Contacts = user.ContactInfo().GetTO()
	info.Personal = user.PersonalInfo().GetTO()
	return &info
}
734630
func ListFollowing(c *context.APIContext) {
	u := GetUserByParams(c)
	if c.Written() {
		return
	}
	listUserFollowing(c, u)
}
736942
func (c *Contributor) GetFollowersURL() string {
	if c == nil || c.FollowersURL == nil {
		return ""
	}
	return *c.FollowersURL
}
519365
func ListFollowers(c *context.APIContext) {
	u := GetUserByParams(c)
	if c.Written() {
		return
	}
	listUserFollowers(c, u)
}
700673
func (c *Client) UnfollowUser(ids ...ID) error {
	return c.modifyFollowers("user", false, ids...)
}
783116
func (o *Organization) GetFollowing() int {
	if o == nil || o.Following == nil {
		return 0
	}
	return *o.Following
}
468219
func (a *AuthWithRoles) currentUserAction(username string) error {
	if username == a.user.GetName() {
		return nil
	}
	return a.checker.CheckAccessToRule(&services.Context{User: a.user},
		defaults.Namespace, services.KindUser, services.VerbCreate, false)
}