Example #1
0
func NewUnread(repo content.Repo, l webfw.Logger) Unread {
	go func() {
		repo.DeleteStaleUnreadRecords()

		for range time.Tick(24 * time.Hour) {
			repo.DeleteStaleUnreadRecords()
		}
	}()

	return Unread{logger: l}
}
Example #2
0
func getReadeefUser(repo content.Repo, md5hex string, log webfw.Logger) content.User {
	md5, err := hex.DecodeString(md5hex)

	if err != nil {
		log.Printf("Error decoding hex api_key")
		return nil
	}

	user := repo.UserByMD5Api(md5)
	if user.HasErr() {
		log.Printf("Error getting user by md5api field: %v\n", user.Err())
		return nil
	}
	return user
}
Example #3
0
func (e Elastic) IndexAllFeeds(repo content.Repo) error {
	e.logger.Infoln("Indexing all articles")

	for _, f := range repo.AllFeeds() {
		articles := f.AllArticles()
		if f.HasErr() {
			return f.Err()
		}

		if err := e.BatchIndex(articles, data.BatchAdd); err != nil {
			return err
		}
	}

	return repo.Err()
}
Example #4
0
func initAdminUser(repo content.Repo, secret []byte) error {
	users := repo.AllUsers()
	if repo.HasErr() {
		return repo.Err()
	}

	if len(users) > 0 {
		return nil
	}

	u := repo.User()
	u.Data(data.User{Login: data.Login("admin"), Active: true, Admin: true})
	u.Password("admin", secret)
	u.Update()

	return u.Err()
}