Exemplo n.º 1
0
Arquivo: db.go Projeto: ivahaev/gosms
func insertMessage(sms *SMS) error {
	log.Info("insertMessage ", sms)
	err := sdb.Save(bucket, sms.UUID, sms)
	if err != nil {
		log.Error("Error when inserting message: ", err)
	}
	return nil
}
Exemplo n.º 2
0
Arquivo: db.go Projeto: ivahaev/gosms
func updateMessageStatus(sms SMS) error {
	log.Info("updateMessageStatus ", sms)
	encoded, err := sdb.Get(bucket, sms.UUID)
	if err != nil {
		log.Error("Error when getting message: ", err)
		return err
	}
	oldSms := SMS{}
	err = json.Unmarshal(encoded, &oldSms)
	if err != nil {
		log.Error("Error when unmarshaling message: ", err)
		return err
	}
	oldSms.Status = sms.Status
	oldSms.Retries = sms.Retries
	oldSms.Device = sms.Device
	oldSms.UpdatedAt = time.Now()
	err = sdb.Save(bucket, oldSms.UUID, oldSms)
	if err != nil {
		log.Error("Error when inserting message: ", err)
	}
	return err
}