Commit ceaff2d7 authored by supermikii's avatar supermikii
Browse files

fix ams target app not found

parent 44ccea21
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -715,7 +715,7 @@ func amsNotificationCallback(w http.ResponseWriter, r *http.Request) {
	amsTargetId = amsNotification.TargetAppInfo.AppInstanceId
	targetDevice := amsNotification.AssociateId[0].Value

	// Find ams target service resource url using mec011
	// Retrieve all mec service on target ams application
	serviceInfo, _, serviceErr := srvMgmtClient.MecServiceMgmtApi.AppServicesGET(context.TODO(), amsTargetId, nil)
	if serviceErr != nil {
		log.Debug("Failed to get target app mec service resource on mec platform", serviceErr.Error())
@@ -723,6 +723,20 @@ func amsNotificationCallback(w http.ResponseWriter, r *http.Request) {
		return
	}

	// Verify demo3 service exists
	var notifyUrl string
	for i := 0; i < len(serviceInfo); i++ {
		if serviceInfo[i].SerName == serviceCategory {
			notifyUrl = serviceInfo[i].TransportInfo.Endpoint.Uris[0]
		}
	}

	// If demo3 service does not exists return
	if notifyUrl == "" {
		w.WriteHeader(http.StatusOK)
		return
	}

	// Remove device from terminal devices using this instances no longer incrementing state
	for i, v := range trackDevices {
		if v == targetDevice {
@@ -742,14 +756,6 @@ func amsNotificationCallback(w http.ResponseWriter, r *http.Request) {
	// Update Activity Logs
	log.Info("AMS event received for ", amsNotification.AssociateId[0].Value, " moved to app ", amsTargetId)

	// Verify service exists
	var notifyUrl string
	for i := 0; i < len(serviceInfo); i++ {
		if serviceInfo[i].SerName == serviceCategory {
			notifyUrl = serviceInfo[i].TransportInfo.Endpoint.Uris[0]
		}
	}

	if notifyUrl != "" {

		// Update ams pane