func SearchForMyNotification()

in FindNotification.go [57:91]


func SearchForMyNotification(r *vidispine.VSRequestor, expectedUri string, entityType string, notificationType string) (bool, error) {
	urlEntityType := entityType
	if entityType == "metadata" || entityType == "shape" {
		urlEntityType = "item" //metadata updates get sent to to /item endpoint
	}
	listResponse, serverErr := r.Get(
		fmt.Sprintf("/API/%s/notification", urlEntityType),
		"application/xml",
	)

	if serverErr != nil {
		return false, serverErr
	}

	parsedResponse, parseErr := xmlquery.Parse(listResponse)
	if parseErr != nil {
		log.Printf("ERROR SearchForMyNotification could not parse server response: %s", parseErr)
		return false, errors.New("invalid server response")
	}

	urinodes := xmlquery.Find(parsedResponse, "//uri")
	for _, node := range urinodes {
		log.Print("INFO SearchForMyNotification checking ", node.InnerText())
		result, err := TestDocument(r, node.InnerText(), &expectedUri, &entityType, &notificationType)
		if err != nil {
			log.Print("ERROR SearchForMyNotification could not process: ", err)
			return false, err
		}
		if result {
			return true, nil
		}
	}

	return false, nil
}