예제 #1
0
파일: backend.go 프로젝트: xing4git/chirp
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)()
}
예제 #2
0
파일: backend.go 프로젝트: xing4git/chirp
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)()
}