Beispiel #1
0
// IsLoginAvailable checks if this login (i.e. username) is already taken
func (a *API) IsLoginAvailable(args *rpc.Args, r *rpc.Ret) os.Error {
	login, err := args.QueryString("L")
	if err != nil {
		return err
	}
	if login, err = SanitizeLogin(login); err != nil {
		return rpc.ErrArg
	}
	u, _, err := a.db.FindUserByLogin(login)
	if err != nil {
		return ErrDb
	}
	r.SetBool("Available", u == nil)
	return nil
}
Beispiel #2
0
func (a *API) LikeInfo(args *rpc.Args, r *rpc.Ret) (err os.Error) {
	fid, _ := args.QueryString("FID")
	_, uid, err := a.whoAmI(args)
	if err != nil {
		return err
	}
	likes, err := a.db.Likes(uid, fid)
	if err != nil {
		likes = false
	}
	n, err := a.db.LikeCount(fid)
	if err != nil {
		return err
	}
	r.SetBool("Likes", likes)
	r.SetInt("Count", n)
	return nil
}
Beispiel #3
0
// FollowInfo returns true if the logged user follows the given object
func (a *API) FollowInfo(args *rpc.Args, r *rpc.Ret) (err os.Error) {

	_, uid, err := a.whoAmI(args)
	if err != nil {
		return err
	}
	what, _ := args.QueryString("What")

	follows, err := a.db.IsFollow(uid, what)
	if err != nil {
		follows = false
	}

	n, err := a.db.FollowerCount(what)
	if err != nil {
		return err
	}

	r.SetBool("Follows", follows)
	r.SetInt("Count", n)

	return nil
}