Exemple #1
0
func CreateFeed(feed model.Feed) {
	f := func() {
		logstr := fmt.Sprintf("create feed: %+v", feed)
		// insert into self timeline
		log.Infof("%s, insert into self timeline", logstr)
		err := redisdao.InsertTimeline(feed.Uid, feed)
		if err != nil {
			log.Errorf("%s, insert into self timeline error: %s", logstr, err.Error())
		}

		// insert into self feeds list
		log.Infof("%s, insert into self feeds list", logstr)
		err = redisdao.InsertUserFeed(feed.Uid, feed)
		if err != nil {
			log.Errorf("%s, insert into self feeds list error: %s", logstr, err.Error())
		}

		insertIntoFansTimeline(feed)

		// insert forwards list
		if feed.Refid != "" {
			log.Infof("%s, insert into feed forwards list", logstr)
			err = redisdao.InsertFeedForward(feed.Refid, feed)
			if err != nil {
				log.Errorf("%s, insert into forwards list error: %s", logstr, err.Error())
			}
		}
	}
	go util.SafeEmptyFunc(f)()
}
Exemple #2
0
func insertIntoPartFansTimeline(feed model.Feed, fans []model.User) {
	f := func() {
		for _, fan := range fans {
			fanuid := fan.Uid.Hex()
			err := redisdao.InsertTimeline(fanuid, feed)
			if err != nil {
				log.Errorf("insert into fans(%s) timeline error: %s", fanuid, err.Error())
			}
		}
	}
	go util.SafeEmptyFunc(f)()
}