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 }
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 }