Exemplo n.º 1
0
func (s *SQLEngine) consumeCreation(tx *sql.Tx, i gregor.Item) error {
	md := i.Metadata()
	qb := s.newQueryBuilder()
	qb.Build("INSERT INTO gregor_items(uid, msgid, category, body, dtime) VALUES(?,?,?,?,",
		hexEnc(md.UID()),
		hexEnc(md.MsgID()),
		i.Category().String(),
		i.Body().Bytes(),
	)
	qb.TimeOrOffset(i.DTime())
	qb.Build(")")
	err := qb.Exec(tx)
	if err != nil {
		return err
	}

	for i, t := range i.RemindTimes() {
		if t == nil {
			continue
		}
		nqb := s.newQueryBuilder()
		nqb.Build("INSERT INTO gregor_reminders(uid, msgid, seqno, rtime) VALUES(?,?,?,", hexEnc(md.UID()), hexEnc(md.MsgID()), i)
		nqb.TimeOrOffset(t)
		nqb.Build(")")
		err = nqb.Exec(tx)
		if err != nil {
			return err
		}
	}
	return nil
}
Exemplo n.º 2
0
func (r *RekeyLogHandler) log(category string, item gregor.Item) {
	md := item.Metadata()
	r.G().Log.Debug("RekeyLogHandler: %s item message metadata: uid = %s, msg id = %s, ctime = %s, device = %s, inband type = %d", category, md.UID(), md.MsgID(), md.CTime(), md.DeviceID(), md.InBandMsgType())
	r.G().Log.Debug("RekeyLogHandler: %s item dtime = %s, remind times = %v", category, r.timeOrOffsetString(item.DTime()), item.RemindTimes())
	r.G().Log.Debug("RekeyLogHandler: %s item body: %s", category, item.Body())
}