From e6b48a497e6c55b8ca828e62c77352aef4282e98 Mon Sep 17 00:00:00 2001
From: Bastien DUMONT <bdumont@grandlyon.com>
Date: Fri, 19 Aug 2022 14:12:00 +0200
Subject: [PATCH] publish: fix: isFirstStart

generated from commit 500cb668cc82fe58474d607757a5fdd7390a9c6a
---
 index.js | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/index.js b/index.js
index 40b891e..26e375e 100644
--- a/index.js
+++ b/index.js
@@ -228239,12 +228239,19 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
 
   try {
     log('debug', 'parsedReply' + JSON.stringify(parsedReply))
-    if (!parsedReply) {
+
+    const json = JSON.stringify(parsedReply)
+    if (
+      !JSON.parse(json)['Envelope']['Body'][
+        'rechercherServicesSouscritsMesuresResponse'
+      ]['servicesSouscritsMesures']
+    ) {
+      log('debug', 'fail no contract')
       return null
     }
+
     const currentContracts = parseContracts(parsedReply)
     let currentContract = null
-    // log('debug', 'current contract size length', currentContracts.length)
     if (Array.isArray(currentContracts)) {
       currentContract = parseContracts(parsedReply)[0]
     } else {
-- 
GitLab