Fix pod removal when it is down
authorChocobozzz <florian.bigard@gmail.com>
Thu, 19 Oct 2017 08:43:54 +0000 (10:43 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Thu, 19 Oct 2017 08:43:54 +0000 (10:43 +0200)
server/controllers/api/pods.ts
server/lib/friends.ts

index ec94efc3524405df682c3c334f67bac77f4f02ff..804aa0659a01143f8b3febfd30fd2c18bc44d5e3 100644 (file)
@@ -83,6 +83,6 @@ function removeFriendController (req: express.Request, res: express.Response, ne
   const pod = res.locals.pod as PodInstance
 
   removeFriend(pod)
-    .then(() => (res.type('json').status(204).end()))
+    .then(() => res.type('json').status(204).end())
     .catch(err => next(err))
 }
index 4cc4a82bfe771b4661e7156034cb3478d4d4b61a..65349ef5f7eb674248ba27f6dc32d365b589e81a 100644 (file)
@@ -251,13 +251,10 @@ function removeFriend (pod: PodInstance) {
   }
 
   return makeSecureRequest(requestParams)
+    .catch(err => logger.warn('Cannot notify friends %s we are quitting him.', pod.host, err))
     .then(() => pod.destroy())
-    .then(() => {
-      logger.info('Removed friend.')
-    })
-    .catch(err => {
-      logger.error('Some errors while quitting friend %s (id: %d).', pod.host, pod.id, err)
-    })
+    .then(() => logger.info('Removed friend %s.', pod.host))
+    .catch(err => logger.error('Cannot destroy friend %s.', pod.host, err))
 }
 
 function getRequestScheduler () {