Browse Source

增加呼出结果推送(客户电话拒绝,未接听)

dujunchen 1 week ago
parent
commit
2ca74d0679
5 changed files with 140 additions and 54 deletions
  1. 3 0
      api/admin/zoho/model.go
  2. 134 53
      api/admin/zoho/push.go
  3. BIN
      deployments/crm-api
  4. BIN
      deployments/crm-api-arm
  5. 3 1
      pkg/httpclient/index.go

+ 3 - 0
api/admin/zoho/model.go

@@ -40,6 +40,9 @@ type RefreshTokenResp struct {
 	TokenType   string `json:"token_type"`
 	ExpiresIn   int    `json:"expires_in"`
 }
+type ZohouserResp struct {
+	TextZohouser []TabZohouser
+}
 type TabZohouser struct {
 	ID       int    `xorm:"id pk autoincr" form:"id" json:"id"`
 	UserId   string `xorm:"'userid'" form:"userid" json:"userid"`

+ 134 - 53
api/admin/zoho/push.go

@@ -27,11 +27,11 @@ var DialStatusList = make(map[string]string) // 临时记录 DialStatus:ANSWER N
 //		return strconv.Itoa(num)
 //	}
 func CallNotify(event map[string]string) {
-	fmt.Println("=========================================== ")
-	fmt.Println("event[] = ", event)
-	fmt.Println("event = ", event["Event"])
-	fmt.Println("AMIPushUrl = ", configs.PushConfigValue.AMIPushUrl)
-	fmt.Println("Channel = ", event["Channel"])
+	// fmt.Println("=========================================== ")
+	fmt.Println("event111111111111111111111111111111111[] = ", event)
+	fmt.Println("Cause111111111111111111111111111111111 = ", event["Cause"])
+	fmt.Println("AMIPushUrl1111111111111111111111111111 = ", configs.PushConfigValue.AMIPushUrl)
+	fmt.Println("Channel1111111111111111111111111111111 = ", event["Uniqueid"])
 
 	/* ===================不这样取callDest,删除 ====================
 	var callDest string
@@ -69,10 +69,10 @@ func CallNotify(event map[string]string) {
 	// 	callId = strconv.Itoa(num)
 	// 	fmt.Println("callId2222222222 = ", callId)
 	// }
-	var callId = "callid100007" // 测试用,每次测试 +1
+	// var callId = "callid100014" // 测试用,每次测试 +1
 	// event["Exten"] = "123456789" // 测试用
 	// fmt.Println("callId = ", callId)
-	var zohoUser = "872297346" // 测试用 872297346 873447071  // 后面看是否从数据库中取 t_zoho_user
+	// var zohoUser = "872297346" // 测试用 872297346 873447071  // 后面看是否从数据库中取 t_zoho_user
 	// var info TabZohouser
 	// if _, err := mysql.DBOrmInstance.Insert(&info); err != nil {
 	// 	lfshook.NewLogger().Error(err)
@@ -125,26 +125,34 @@ func CallNotify(event map[string]string) {
 		// * ===================================================================================== */
 		// Outgoing Call - Ringing
 		if event["Context"] == "macro-trunkdial-failover" {
+			lfshook.NewLogger().Info("Outgoing Call - Ringing")
+			fmt.Println("event[] = ", event)
+			fmt.Println("event = ", event["Event"])
+			fmt.Println("Linkedid = ", event["Timestamp"])
 			StartTimeList[event["Linkedid"]] = time.Now().Add(-8 * time.Hour)
 			// https://www.zohoapis.com/phonebridge/v3/callnotify?type=dialed&state=ringing&id=10031&from=123456789&to=12300000001
-			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dialed&state=ringing&id=%s&from=%s&to=%s", ZOHO_URL, callId, event["CallerIDNum"], event["DestCallerIDNum"])
-			if zohoUser != "" {
-				getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
-			}
+			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dialed&state=ringing&id=%s&from=%s&to=%s", ZOHO_URL, event["Linkedid"], event["CallerIDNum"], event["DestCallerIDNum"])
+			// if zohoUser != "" {
+			// 	getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
+			// }
 			fmt.Println("getURL = ", getURL)
 			go httpclient.ZohoGet(getURL)
 
 			// Incoming Call - Ringing
 			// if event["Context"] == "macro-stdexten" {
 		} else if event["Context"] == "macro-stdexten" || event["Context"] == "macro-stdexten-withoutvm" { // 开启语音留言:macro-stdexten  关闭语音留言:macro-stdexten-withoutvm
+			lfshook.NewLogger().Error("Incoming Call - Ringing")
+			fmt.Println("event[] = ", event)
+			fmt.Println("event = ", event["Event"])
 			StartTimeList[event["Linkedid"]] = time.Now().Add(-8 * time.Hour)
+			fmt.Println("Linkedid = ", event["Timestamp"])
 			// if strings.Compare(event["Context"], "macro-stdexten") == 0 {  // OK
 			// https://www.zohoapis.com/phonebridge/v3/callnotify?type=received&state=ringing&id=10033&from=12300000001&to=123456789
 			// getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=received&state=ringing&id=%s&from=%s&to=%s", ZOHO_URL, callId, event["Exten"], callDest) // 取得from to 可能不准
-			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=received&state=ringing&id=%s&from=%s&to=%s", ZOHO_URL, callId, event["CallerIDNum"], event["DestCallerIDNum"])
-			if zohoUser != "" {
-				getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
-			}
+			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=received&state=ringing&id=%s&from=%s&to=%s", ZOHO_URL, event["Linkedid"], event["CallerIDNum"], event["DestCallerIDNum"])
+			// if zohoUser != "" {
+			// 	getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
+			// }
 			fmt.Println("getURL = ", getURL)
 			go httpclient.ZohoGet(getURL)
 
@@ -154,29 +162,80 @@ func CallNotify(event map[string]string) {
 	} else if event["Event"] == "DialEnd" {
 		// 记录呼叫状态
 		DialStatusList[event["Linkedid"]] = event["DialStatus"]
-
+		fmt.Println("DialEnd[] = ", event)
+		fmt.Println("DialEnd = ", event["Event"])
 		// Outgoing Call - Unattended
-		if event["Context"] == "macro-trunkdial-failover" && event["DialStatus"] != "ANSWER" {
-			startTime := StartTimeList[event["Linkedid"]].Format("2006-01-02 15:04:09")
+		if event["Context"] == "macro-trunkdial-failover" && event["DialStatus"] == "CANCEL" {
+			lfshook.NewLogger().Info("Outgoing Call - CANCEL")
+			fmt.Println("event[] = ", event)
+			fmt.Println("event = ", event["Event"])
+			fmt.Println("Linkedid = ", event["Timestamp"])
+			// startTime := StartTimeList[event["Linkedid"]].Format("2006-01-02 15:04:09")
+			startTimeutc := StartTimeList[event["Linkedid"]].In(time.UTC) // 存储从string 改为 time.Time
+			startTime := startTimeutc.Format(time.RFC3339)
 			fmt.Println("startTime: ", startTime)
 			// https://www.zohoapis.com/phonebridge/v3/callnotify?type=dialed&state=busy&id=10025&from=123456789&to=12300000001&start_time=2024-12-04 15:09:10
-			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dialed&state=busy&id=%s&from=%s&to=%s&start_time=%s", ZOHO_URL, callId, event["CallerIDNum"], event["DestCallerIDNum"], startTime)
-			if zohoUser != "" {
-				getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
-			}
+			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dialed&state=busy&id=%s&from=%s&to=%s&start_time=%s", ZOHO_URL, event["Linkedid"], event["CallerIDNum"], event["DestCallerIDNum"], startTime)
+			// if zohoUser != "" {
+			// 	getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
+			// }
+			fmt.Println("getURL = ", getURL)
+			go httpclient.ZohoGet(getURL)
+
+			// Incoming Call - Missed
+			// if event["Context"] == "macro-stdexten" && event["DialStatus"] != "ANSWER" {
+		} else if event["Context"] == "macro-trunkdial-failover" && event["DialStatus"] == "NOANSWER" {
+			lfshook.NewLogger().Info("Outgoing Call - NOANSWER")
+			fmt.Println("event[] = ", event)
+			fmt.Println("event = ", event["Event"])
+			fmt.Println("Linkedid = ", event["Timestamp"])
+			// startTime := StartTimeList[event["Linkedid"]].Format("2006-01-02 15:04:09")
+			startTimeutc := StartTimeList[event["Linkedid"]].In(time.UTC) // 存储从string 改为 time.Time
+			startTime := startTimeutc.Format(time.RFC3339)
+			fmt.Println("startTime: ", startTime)
+			// https://www.zohoapis.com/phonebridge/v3/callnotify?type=dialed&state=busy&id=10025&from=123456789&to=12300000001&start_time=2024-12-04 15:09:10
+			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dialed&state=noanswer&id=%s&from=%s&to=%s&start_time=%s", ZOHO_URL, event["Linkedid"], event["CallerIDNum"], event["DestCallerIDNum"], startTime)
+			// if zohoUser != "" {
+			// 	getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
+			// }
+			fmt.Println("getURL = ", getURL)
+			go httpclient.ZohoGet(getURL)
+
+			// Incoming Call - Missed
+			// if event["Context"] == "macro-stdexten" && event["DialStatus"] != "ANSWER" {
+		} else if event["Context"] == "macro-trunkdial-failover" && event["DialStatus"] == "BUSY" {
+			lfshook.NewLogger().Info("Outgoing Call - BUSY")
+			fmt.Println("event[] = ", event)
+			fmt.Println("event = ", event["Event"])
+			fmt.Println("Linkedid = ", event["Timestamp"])
+			// startTime := StartTimeList[event["Linkedid"]].Format("2006-01-02 15:04:09")
+			startTimeutc := StartTimeList[event["Linkedid"]].In(time.UTC) // 存储从string 改为 time.Time
+			startTime := startTimeutc.Format(time.RFC3339)
+			fmt.Println("startTime: ", startTime)
+			// https://www.zohoapis.com/phonebridge/v3/callnotify?type=dialed&state=busy&id=10025&from=123456789&to=12300000001&start_time=2024-12-04 15:09:10
+			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dialed&state=rejected&id=%s&from=%s&to=%s&start_time=%s", ZOHO_URL, event["Linkedid"], event["CallerIDNum"], event["DestCallerIDNum"], startTime)
+			// if zohoUser != "" {
+			// 	getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
+			// }
 			fmt.Println("getURL = ", getURL)
 			go httpclient.ZohoGet(getURL)
 
 			// Incoming Call - Missed
 			// if event["Context"] == "macro-stdexten" && event["DialStatus"] != "ANSWER" {
 		} else if (event["Context"] == "macro-stdexten" || event["Context"] == "macro-stdexten-withoutvm") && event["DialStatus"] != "ANSWER" { // 开启语音留言:macro-stdexten  关闭语音留言:macro-stdexten-withoutvm
-			startTime := StartTimeList[event["Linkedid"]].Format("2006-01-02 15:04:09")
+			lfshook.NewLogger().Error("Incoming Call - Missed")
+			fmt.Println("event[] = ", event)
+			fmt.Println("event = ", event["Event"])
+			// startTime := StartTimeList[event["Linkedid"]].Format("2006-01-02 15:04:09")
+			startTimeutc := StartTimeList[event["Linkedid"]].In(time.UTC) // 存储从string 改为 time.Time
+			startTime := startTimeutc.Format(time.RFC3339)
 			fmt.Println("startTime: ", startTime)
+			fmt.Println("Linkedid = ", event["Timestamp"])
 			// https://www.zohoapis.com/phonebridge/v3/callnotify?type=received&state=missed&id=10005&from=12300000001&to=123456789&start_time=2024-12-04 15:09:10
-			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=received&state=missed&id=%s&from=%s&to=%s&start_time=%s", ZOHO_URL, callId, event["CallerIDNum"], event["DestCallerIDNum"], startTime)
-			if zohoUser != "" {
-				getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
-			}
+			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=received&state=missed&id=%s&from=%s&to=%s&start_time=%s", ZOHO_URL, event["Linkedid"], event["CallerIDNum"], event["DestCallerIDNum"], startTime)
+			// if zohoUser != "" {
+			// 	getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
+			// }
 			fmt.Println("getURL = ", getURL)
 			go httpclient.ZohoGet(getURL)
 
@@ -189,15 +248,19 @@ func CallNotify(event map[string]string) {
 			// 记录开始时间
 			// TimestampList[event["Uniqueid"]] = event["Timestamp"] // error 需要把 Uniqueid 改为 Linkedid
 			// StartTimeList[event["Uniqueid"]] = time.Now()         // error 需要把 Uniqueid 改为 Linkedid
+			lfshook.NewLogger().Info("Outgoing Call - Answered")
+			fmt.Println("event[] = ", event)
+			fmt.Println("event = ", event["Event"])
+			fmt.Println("Linkedid = ", event["Timestamp"])
 			TimestampList[event["Linkedid"]] = event["Timestamp"]
 			StartTimeList[event["Linkedid"]] = time.Now().Add(-8 * time.Hour)
 
 			// https: //www.zohoapis.com/phonebridge/v3/callnotify?type=dialed&state=answered&id=10003&from=123456789&to=12300000001
 			// getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dialed&state=answered&id=%s&from=%s&to=%s", ZOHO_URL, callId, event["CallerIDNum"], event["ConnectedLineNum"])
-			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dialed&state=answered&id=%s&from=%s&to=%s", ZOHO_URL, callId, event["ConnectedLineNum"], event["CallerIDNum"])
-			if zohoUser != "" {
-				getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
-			}
+			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dialed&state=answered&id=%s&from=%s&to=%s", ZOHO_URL, event["Linkedid"], event["ConnectedLineNum"], event["CallerIDNum"])
+			// if zohoUser != "" {
+			// 	getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
+			// }
 			fmt.Println("getURL = ", getURL)
 			go httpclient.ZohoGet(getURL)
 
@@ -207,14 +270,18 @@ func CallNotify(event map[string]string) {
 			// 记录开始时间
 			// TimestampList[event["Uniqueid"]] = event["Timestamp"] // Uniqueid 有时通话也不合适  NG  // 都改为 Linkedid
 			// StartTimeList[event["Uniqueid"]] = time.Now()         // Uniqueid 有时通话也不合适  NG  // 都改为 Linkedid
+			lfshook.NewLogger().Error("Incoming Call - Answered")
+			fmt.Println("event[] = ", event)
+			fmt.Println("event = ", event["Event"])
+			fmt.Println("Linkedid = ", event["Timestamp"])
 			TimestampList[event["Linkedid"]] = event["Timestamp"]             // 呼入时设置 Uniqueid 不是 Linkedid
 			StartTimeList[event["Linkedid"]] = time.Now().Add(-8 * time.Hour) // 呼入时设置 Uniqueid 不是 Linkedid
 
 			// https://www.zohoapis.com/phonebridge/v3/callnotify?type=received&state=answered&id=10023&from=12300000001&to=123456789
-			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=received&state=answered&id=%s&from=%s&to=%s", ZOHO_URL, callId, event["CallerIDNum"], event["ConnectedLineNum"])
-			if zohoUser != "" {
-				getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
-			}
+			getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=received&state=answered&id=%s&from=%s&to=%s", ZOHO_URL, event["Linkedid"], event["CallerIDNum"], event["ConnectedLineNum"])
+			// if zohoUser != "" {
+			// 	getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
+			// }
 			fmt.Println("getURL = ", getURL)
 			go httpclient.ZohoGet(getURL)
 
@@ -252,10 +319,21 @@ func CallNotify(event map[string]string) {
 		// delete(TimestampList, event["Uniqueid"])
 		// * ===================================================================================== */
 		// 判断呼叫状态,为 ANSWER 时才推送,否则见以上推送 Outgoing Call - Unattended 或 Incoming Call - Missed
-		if DialStatusList[event["Linkedid"]] == event["DialStatus"] {
-
+		fmt.Println("event[] = ", event)
+		fmt.Println("event = ", event["Event"])
+		lfshook.NewLogger().Errorf("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa %+v", event["Context"])
+		fmt.Println("ChannelHangupRequest1 = ", DialStatusList[event["Linkedid"]])
+		fmt.Println("ChannelHangupRequest1 = ", event["DialStatus"])
+		if DialStatusList[event["Linkedid"]] == "ANSWER" {
+			lfshook.NewLogger().Errorf("ChannelHangupRequest = %+v", event["Uniqueid"])
+			fmt.Println("event[] = ", event)
+			fmt.Println("event = ", event["Event"])
+			lfshook.NewLogger().Errorf("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa %+v", event["Context"])
+			lfshook.NewLogger().Errorf("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb %+v", event["Linkedid"])
+			lfshook.NewLogger().Errorf("ccccccccccccccccccccccccccccccc %+v", event["DialStatus"])
 			// Outgoing Call - Ended
 			if event["Context"] == "macro-trunkdial-failover" {
+				fmt.Println("Linkedid = ", event["Timestamp"])
 				// 获取时间
 				// durationTime := getDuration(event["Uniqueid"], event["Timestamp"])
 				durationTime := getDuration(event["Linkedid"], event["Timestamp"])
@@ -263,7 +341,9 @@ func CallNotify(event map[string]string) {
 				// startTime, _ := time.Parse("2006-01-02 15:04:05", TimestampList[event["Uniqueid"]]) // error   1734328213.774410  =>  0001-01-01 00:00:00 +0000 UTC
 				// startTime := StartTimeList[event["Uniqueid"]]
 				// startTime := StartTimeList[event["Uniqueid"]].Format("2006-01-02 15:04:09") // 存储从string 改为 time.Time
-				startTime := StartTimeList[event["Linkedid"]].Format("2006-01-02 15:04:09") // 存储从string 改为 time.Time
+				// startTime := StartTimeList[event["Linkedid"]].Format("2006-01-02 15:04:09") // 存储从string 改为 time.Time
+				startTimeutc := StartTimeList[event["Linkedid"]].In(time.UTC) // 存储从string 改为 time.Time
+				startTime := startTimeutc.Format(time.RFC3339)
 				fmt.Println("startTime: ", startTime)
 				// durationTime002 := getDuration002(startTime)
 				// durationTime002 := time.Now().Sub(StartTimeList[event["Uniqueid"]]) // ok    durationTime002:  7.78408849s   // should use time.Since instead of time.Now().Sub (S1012)
@@ -276,17 +356,17 @@ func CallNotify(event map[string]string) {
 
 				// https://www.zohoapis.com/phonebridge/v3/callnotify?type=dailed&state=ended&id=10030&from=123456789&to=12300000001&start_time=2024-12-04 11:32:15&duration=325
 				// getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dailed&state=ended&id=%s&from=%s&to=%s&start_time=%s&duration=%d", ZOHO_URL, callId, event["CallerIDNum"], event["ConnectedLineNum"], startTime, durationTime)
-				getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dailed&state=ended&id=%s&from=%s&to=%s&start_time=%s&duration=%d", ZOHO_URL, callId, event["ConnectedLineNum"], event["CallerIDNum"], startTime, durationTime)
-				if zohoUser != "" {
-					getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
-				}
+				getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=dailed&state=ended&id=%s&from=%s&to=%s&start_time=%s&duration=%d", ZOHO_URL, event["Linkedid"], event["ConnectedLineNum"], event["CallerIDNum"], startTime, durationTime)
+				// if zohoUser != "" {
+				// 	getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
+				// }
 				fmt.Println("getURL = ", getURL)
 				go httpclient.ZohoGet(getURL)
 				// Incoming Call - Ended
-				// if event["Context"] == "macro-stdexten" { // Context:DialPlan1
-			} else if event["Context"] == "macro-stdexten" || event["Context"] == "macro-stdexten-withoutvm" { // 开启语音留言:macro-stdexten  关闭语音留言:macro-stdexten-withoutvm
+				// 	// if event["Context"] == "macro-stdexten" { // Context:DialPlan1
+			} else { // 开启语音留言:macro-stdexten  关闭语音留言:macro-stdexten-withoutvm
 				// if event["Context"] != "macro-trunkdial-failover" {
-
+				fmt.Println("Linkedid = ", event["Timestamp"])
 				// 还需优化判断,开启语音留言时,主叫挂断才是 macro-stdexten , 被叫挂断是 DialPlan1
 				//              关闭语音留言时,主叫挂断才是 macro-stdexten-withoutvm , 被叫挂断是 DialPlan1
 				// 如果 Outgoing Call 只会是 macro-trunkdial-failover 的话,那么和以下判断换一下,else 不判断,都为 Incoming Call 处理
@@ -295,15 +375,16 @@ func CallNotify(event map[string]string) {
 				// durationTime := getDuration(event["Uniqueid"], event["Timestamp"])
 				// startTime := StartTimeList[event["Uniqueid"]].Format("2006-01-02 15:04:09") // 存储从string 改为 time.Time
 				durationTime := getDuration(event["Linkedid"], event["Timestamp"])
-				startTime := StartTimeList[event["Linkedid"]].Format("2006-01-02 15:04:09") // 存储从string 改为 time.Time
+				startTimeutc := StartTimeList[event["Linkedid"]].In(time.UTC) // 存储从string 改为 time.Time
+				startTime := startTimeutc.Format(time.RFC3339)
 				fmt.Println("startTime: ", startTime)
 
 				// https://www.zohoapis.com/phonebridge/v3/callnotify?type=received&state=ended&id=100&from=12300000001&to=123456789&start_time=2024-12-04 10:32:10&duration=223
-				getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=received&state=ended&id=%s&from=%s&to=%s&start_time=%s&duration=%d", ZOHO_URL, callId, event["CallerIDNum"], event["ConnectedLineNum"], startTime, durationTime)
+				getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=received&state=ended&id=%s&from=%s&to=%s&start_time=%s&duration=%d", ZOHO_URL, event["Linkedid"], event["CallerIDNum"], event["ConnectedLineNum"], startTime, durationTime)
 				// getURL := fmt.Sprintf("%s/phonebridge/v3/callnotify?type=received&state=ended&id=%s&from=%s&to=%s&start_time=%s&duration=%d", ZOHO_URL, callId, event["ConnectedLineNum"], event["CallerIDName"], startTime, durationTime)
-				if zohoUser != "" {
-					getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
-				}
+				// if zohoUser != "" {
+				// 	getURL = fmt.Sprintf("%s&zohouser=%s", getURL, zohoUser)
+				// }
 				fmt.Println("getURL = ", getURL)
 				go httpclient.ZohoGet(getURL)
 
@@ -313,9 +394,9 @@ func CallNotify(event map[string]string) {
 	// fmt.Println("getURL = ", getURL)
 
 	// 测试验证下上面有没有删除,以防TimestampList越来越大
-	for k, v := range TimestampList {
-		fmt.Printf("===Linkedid:%s   Timestamp:%s===\n", k, v)
-	}
+	// for k, v := range TimestampList {
+	// 	fmt.Printf("===Linkedid:%s   Timestamp:%s===\n", k, v)
+	// }
 
 }
 

BIN
deployments/crm-api


BIN
deployments/crm-api-arm


+ 3 - 1
pkg/httpclient/index.go

@@ -141,7 +141,6 @@ func ZohoGet(url string) *http.Response {
 		return nil
 	}
 
-	lfshook.NewLogger().Infof("get %s", url)
 	client := http.Client{
 		Timeout: 10 * time.Second,
 	}
@@ -168,11 +167,14 @@ func ZohoGet(url string) *http.Response {
 	req.Header.Set("Authorization", "Bearer "+AccessToken)
 	lfshook.NewLogger().Errorf("11111111111111%s", AccessToken)
 	lfshook.NewLogger().Errorf("22222222222222%s", req.Header)
+	lfshook.NewLogger().Infof("request %+v", req)
 	resp, err := client.Do(req)
 	if err != nil {
 		lfshook.NewLogger().Errorf("Error: unable to connect to - %s\n", err.Error())
 	} else if resp.Status != "200 OK" {
 		lfshook.NewLogger().Errorf("Error: non 200 status from - %s\n", resp.Status)
+	} else if resp.Status == "200 OK" {
+		lfshook.NewLogger().Errorf("Error: 200 ok status from - %s\n", resp.Status)
 	}
 
 	// 读取请求后的响应