コード例 #1
0
ファイル: trib-impl.go プロジェクト: karomancer/Tribbler
func (ts *Tribserver) GetSubscriptions(args *tribproto.GetSubscriptionsArgs, reply *tribproto.GetSubscriptionsReply) error {

	//check errors for any calls to libstore

	//check if subscriber exists
	_, userErr := ts.lstore.Get(args.Userid)

	if userErr != nil {
		reply.Status = tribproto.ENOSUCHUSER
		return nil
	}

	//otherwise...
	//then do getList (user:subscriptions)
	subs, err1 := ts.lstore.GetList(args.Userid + ":subscriptions")

	if err1 != nil {
		return err1
	}
	//if there's no list, return an empty list
	if subs == nil {
		reply.Userids = []string{}
	} else {
		reply.Userids = subs
	}
	//then reply = OK, list
	reply.Status = tribproto.OK
	//return nil
	return nil
}
コード例 #2
0
ファイル: trib-impl.go プロジェクト: ammarar/DS-P2
func (ts *Tribserver) GetSubscriptions(args *tribproto.GetSubscriptionsArgs, reply *tribproto.GetSubscriptionsReply) error {
	// check that user exists
	_, err := ts.ls.Get(args.Userid)
	if err != nil {
		reply.Status = tribproto.ENOSUCHUSER
		reply.Userids = nil
		return nil
	}
	// get subscriptions
	subsid := fmt.Sprintf("%s:subs", args.Userid)
	var sublist []string
	sublist, err = ts.ls.GetList(subsid)
	if err != nil {
		return err
	}
	reply.Status = tribproto.OK
	reply.Userids = sublist
	return nil
}
コード例 #3
0
ファイル: trib-impl.go プロジェクト: yuguess/440_P2
/**@brief get tribbles from subscriped users
 * @param GetSubscriptionsArgs
 * @param GetSubscriptionsReply
 * @return error
 */
func (ts *Tribserver) GetSubscriptions(
	args *tribproto.GetSubscriptionsArgs,
	reply *tribproto.GetSubscriptionsReply) error {
	var fllw_key string
	var fllw_ids []string
	var err error

	fllw_key = fmt.Sprintf("%s:F", args.Userid)
	fllw_ids, err = ts.Store.GetList(fllw_key)
	if lsplog.CheckReport(1, err) {
		reply.Status = tribproto.ENOSUCHUSER
		reply.Userids = nil
		return nil
	}

	reply.Status = tribproto.OK
	reply.Userids = fllw_ids

	return nil
}