Exemplo n.º 1
0
func (w Watcher) handler(i intervals.Interval) {
	list, err := db.GetByInterval(i).List()
	if err != nil {
		log.Error("Error parsing interval (%d): %s", i.ID, err)
		return
	}
	for _, watch := range list {
		w.DigParser.Exec(watch.Domain)
		before, err := whois.GetByDomain(watch.Domain).Count()
		if err != nil {
			log.Error("%s", err)
		}
		w.WhoisParser.Exec(watch.Domain)
		after, err := whois.GetByDomain(watch.Domain).Count()
		if err != nil {
			log.Error("%s", err)
		}
		if after > before && before > 0 {
			log.Info("%s whois changed", watch.Domain)
			message := notifications.Message{
				Added:   time.Now(),
				Message: "Domain Whois update.",
				Domain:  watch.Domain,
			}
			for _, user := range watch.Users {
				log.Info("%s", user.Email)
				noter, _ := notifications.SetupUserNotification(user)
				noter.AddMessage(message)
			}
		}
		err = watch.Save()
		if err != nil {
			log.Error("%s", err)
		}

	}
}
Exemplo n.º 2
0
func ByDomainUUID(w http.ResponseWriter, r *http.Request, domain domains.Domain) {
	record, err := db.GetByDomain(domain).One()
	// could push to dispatcher based on query params
	util.ToJSON(record, err, w)
}