예제 #1
0
func clearReturn(entity *models.Warning) {
	entity.Message = ""
	entity.Ip = ""
	entity.Browser = ""
	entity.Operating_system = ""
	entity.Device = ""
	entity.Raw = ""
	entity.Created_by = ""
	entity.Last_modified_by = ""
	entity.Last_modified_date = ""

	entity.WarnResp.Reply_to = ""
	entity.WarnResp.Ip = ""
	entity.WarnResp.Browser = ""
	entity.WarnResp.Operating_system = ""
	entity.WarnResp.Device = ""
	entity.WarnResp.Raw = ""
	if entity.WarnResp.Reply_date == "0000-00-00 00:00:00" {
		entity.WarnResp.Reply_date = ""
	}

	if entity.WarnResp.Response_read == "0000-00-00 00:00:00" {
		entity.WarnResp.Response_read = ""
	}
}
예제 #2
0
func sendSMSWarn(entity *models.Warning, db gorp.SqlExecutor) {

	message := SelectMessage(db, entity.Id_message)
	sms_message := messages.GetLocaleMessage(entity.Lang_key, "MSG_SMS_GREET") + "\r\n" + "'" + message.Name + "'"
	if entity.WarnResp == nil {
		sms_message += "\r\n" + messages.GetLocaleMessage(entity.Lang_key, "MSG_FOOTER")
	} else {

		if entity.WarnResp.Id_contact_type == 1 {
			go SendEmailReplyRequestAcknowledge(entity.WarnResp, db)
		} else {
			go SendWhatsappReplyRequestAcknowledge(entity, db)
		}

		sms_message += "\r\n" + messages.GetLocaleMessage(entity.Lang_key, "MSG_REPLY_FOOTER") + " " + ShortUrl(models.URL_REPLY+"/"+entity.WarnResp.Resp_hash)
	}

	sms := &models.SMS{
		CredencialKey: os.Getenv("WARNACREDENCIAL"),
		Content:       sms_message,
		URLPath:       models.URL_MAIN_MOBILE_PRONTO,
		Scheme:        "http",
		Host:          models.URL_DOMAIN_MOBILE_PRONTO,
		Project:       os.Getenv("WARNAPROJECT"),
		AuxUser:       "******",
		MobileNumber:  strings.Replace(entity.Contact, "+", "", 1),
		SendProject:   "N",
	}

	sent, response := SendSMS(sms)

	if sent {
		entity.Message = response
		UpdateWarningSent(entity, db)
	}

}
예제 #3
0
//Deploys the message to be sent into an email struct, call the service and in case of successful send, update the warn as sent.
func sendEmailWarn(entity *models.Warning, db gorp.SqlExecutor) {
	fmt.Println("sendEmailWarn")

	//reads the e-mail template from a local file
	wab_email_template := wab_root + "/resource/warning.html"

	if entity.WarnResp != nil {
		wab_email_template = wab_root + "/resource/warning-reply.html"
	}
	template_byte, err := ioutil.ReadFile(wab_email_template)
	checkErr(err, "Email File Opening ERROR")
	template_email_string := string(template_byte[:])

	subject := GetRandomSubject(entity.Lang_key)

	email_content := sendWarningSetup(subject.Name, template_email_string, entity, db)

	email := &models.Email{
		TemplatePath: wab_email_template,
		Content:      email_content,
		Subject:      subject.Name,
		ToAddress:    entity.Contact,
		FromName:     models.WARN_A_BRODA,
		LangKey:      entity.Lang_key,
		Async:        false,
		UseContent:   true,
		HTMLContent:  true,
	}

	sent, response := SendMail(email)

	if sent {
		entity.Message = response
		UpdateWarningSent(entity, db)
	}
}