Esempio n. 1
0
func HandleCallback(event *model.Event, action *api.Action) {

	teams := action.Uic
	mails := []string{}
	ims := []string{}

	if teams != "" {
		_, mails, ims = api.ParseTeams(teams)
		imsmsContent := GenerateIMSmsContent(event)
		mailContent := GenerateMailContent(event)
		if action.BeforeCallbackSms == 1 {
			redis.WriteIMSms(ims, imsmsContent)
		}

		if action.BeforeCallbackMail == 1 {
			redis.WriteMail(mails, imsmsContent, mailContent)
		}
	}

	message := Callback(event, action)

	if teams != "" {
		if action.AfterCallbackSms == 1 {
			redis.WriteIMSms(ims, message)
		}

		if action.AfterCallbackMail == 1 {
			redis.WriteMail(mails, message, message)
		}
	}

}
Esempio n. 2
0
// 处理事件(去掉了优先级区分)
func consumeEvents(event *model.Event, action *api.Action) {
	if action.Uic == "" {
		return
	}
	//获取联系方式
	phones, mails, ims := api.ParseTeams(action.Uic)

	smsContent := GenerateSmsContent(event)
	mailContent := GenerateMailContent(event)
	imContent := GenerateIMSmsContent(event)
	phoneContent := GeneratePhoneContent(event)

	// level 0 will have phone,im,mail
	// level 1-2 will have im,mail
	// level 3-6 will only have im

	if event.Priority() == 0 {
		redis.WritePhone(phones, phoneContent)
	}

	if event.Priority() < 3 {
		redis.WriteMail(mails, smsContent, mailContent)
	}

	redis.WriteIMSms(ims, imContent)
}