Esempio n. 1
0
File: get.go Progetto: grunya404/dns
func parseRow(row connection.Row) (Watcher, error) {
	w := Watcher{}
	var intervalID int32
	var uuid string
	var usersBuf, logs []byte
	err := row.Scan(&w.ID, &uuid, &w.Added, &w.Updated, &intervalID, &logs, &usersBuf)
	err = json.Unmarshal(logs, &w.Logs)
	if err != nil {
		return w, err
	}
	var usersArr []int
	err = json.Unmarshal(usersBuf, &usersArr)
	if err != nil {
		return w, err
	}
	for _, u := range usersArr {
		user, err := users.GetByID(u).One()
		if err != nil {
			continue
		}
		w.Users = append(w.Users, user)
	}
	w.Domain, err = domains.GetByUUID(uuid).One()
	if err != nil {
		return w, err
	}
	w.Interval, err = intervals.GetByID(intervalID).One()
	return w, err
}
Esempio n. 2
0
File: get.go Progetto: grunya404/dns
func parseRow(row connection.Row) (Record, error) {
	r := Record{}
	var rUUID, dUUID string
	var rtID int32
	var pID int32
	var jsonBuf []byte
	err := row.Scan(&rUUID, &dUUID, &r.Name, &jsonBuf, &rtID, &r.Date, &pID, &r.Added)
	if err != nil {
		return r, err
	}
	err = json.Unmarshal(jsonBuf, &r.Args)
	if err != nil {
		return r, err
	}
	r.UUID = uuid.Parse(rUUID)
	r.Domain, err = domains.GetByUUID(dUUID).One()
	if err != nil {
		return r, err
	}
	r.Type, err = types.GetByID(rtID).One()
	if err != nil {
		return r, err
	}
	// ignore error as we dont need a Parser
	p, _ := parser.Get(parser.GetByID(), pID)
	r.Parser = p
	return r, nil
}
Esempio n. 3
0
File: get.go Progetto: grunya404/dns
func parseRow(row connection.Row) (User, error) {
	u := User{}
	var settings []byte
	err := row.Scan(&u.ID, &u.Email, &u.Password, &u.Added, &u.Updated, &settings)
	if err != nil {
		return u, err
	}
	err = json.Unmarshal(settings, &u.Settings)
	return u, err
}
Esempio n. 4
0
File: get.go Progetto: grunya404/dns
func parseRow(row connection.Row) (Domain, error) {
	d := Domain{}
	var dUUID string
	var tldID int32
	err := row.Scan(&dUUID, &d.Name, &tldID)
	if err != nil {
		return d, err
	}
	d.UUID = uuid.Parse(dUUID)
	d.TLD, err = tlds.GetByID(tldID).One()
	return d, err
}
Esempio n. 5
0
File: get.go Progetto: grunya404/dns
func parseRow(row connection.Row) (Record, error) {
	w := Record{}
	var duuid, wuuid string
	var emails, organizations, phones, postcodes, names []byte
	err := row.Scan(
		&w.ID,
		&duuid,
		&w.Data,
		&w.Raw,
		&w.Contacts,
		&emails,
		&w.Added,
		&wuuid,
		&organizations,
		&phones,
		&postcodes,
		&names,
	)
	if err != nil {
		return w, err
	}
	err = json.Unmarshal(emails, &w.Emails)
	if err != nil {
		return w, err
	}
	err = json.Unmarshal(organizations, &w.Organizations)
	if err != nil {
		return w, err
	}
	err = json.Unmarshal(phones, &w.Phones)
	if err != nil {
		return w, err
	}
	err = json.Unmarshal(postcodes, &w.Postcodes)
	if err != nil {
		return w, err
	}
	err = json.Unmarshal(names, &w.Emails)
	if err != nil {
		return w, err
	}
	w.Domain, err = domains.GetByUUID(duuid).One()
	if err != nil {
		return w, err
	}
	w.UUID = uuid.Parse(wuuid)
	return w, nil
}
Esempio n. 6
0
File: get.go Progetto: grunya404/dns
func parseRow(row connection.Row) (Parser, error) {
	p := Parser{}
	var tldID int32
	var jsonBuf []byte
	err := row.Scan(&p.ID, &p.Filename, &p.Started, &p.Finished, &p.Date, &tldID, &jsonBuf)
	if err != nil {
		return p, err
	}
	err = json.Unmarshal(jsonBuf, &p.Logs)
	if err != nil {
		return p, err
	}
	t, err := tlds.GetByID(tldID).One()
	p.TLD = t
	return p, err
}
Esempio n. 7
0
File: get.go Progetto: grunya404/dns
func parseRow(row connection.Row) (Notification, error) {
	n := Notification{}
	var userID int
	var messages, archived []byte
	err := row.Scan(&userID, &messages, &n.Updated, &n.Alerts, &archived)
	if err != nil {
		return n, err
	}
	err = json.Unmarshal(archived, &n.Archived)
	if err != nil {
		return n, err
	}
	err = json.Unmarshal(messages, &n.Messages)
	if err != nil {
		return n, err
	}
	n.User, err = users.GetByID(userID).One()
	if err != nil {
	}
	return n, err
}
Esempio n. 8
0
File: get.go Progetto: grunya404/dns
func parseRow(row connection.Row) (Interval, error) {
	i := Interval{}
	err := row.Scan(&i.ID, &i.Value)
	return i, err
}
Esempio n. 9
0
File: get.go Progetto: grunya404/dns
func parseRow(row connection.Row) (Type, error) {
	rt := Type{}
	err := row.Scan(&rt.ID, &rt.Name)
	return rt, err
}
Esempio n. 10
0
File: get.go Progetto: grunya404/dns
func parseRow(row connection.Row) (TLD, error) {
	t := TLD{}
	err := row.Scan(&t.ID, &t.Name)
	return t, err

}