示例#1
0
文件: login.go 项目: petar/ShelfLife
// 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
}
示例#2
0
文件: like.go 项目: petar/ShelfLife
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
}
示例#3
0
文件: follow.go 项目: petar/ShelfLife
// 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
}