From 732aa9bf5a1f8efb71befc5ab2d78cd38a48a28d Mon Sep 17 00:00:00 2001
From: Arnaud AMBROSELLI <arnaud.ambroselli@yahoo.fr>
Date: Tue, 28 May 2024 14:01:57 +0200
Subject: [PATCH] feat: force latest version

---
 api/src/middlewares/versionCheck.js | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/api/src/middlewares/versionCheck.js b/api/src/middlewares/versionCheck.js
index 4c72c137d..400d08b3e 100644
--- a/api/src/middlewares/versionCheck.js
+++ b/api/src/middlewares/versionCheck.js
@@ -1,18 +1,20 @@
-const { he } = require("date-fns/locale");
-
-const MINIMUM_MOBILE_APP_VERSION = 75;
+const MINIMUM_MOBILE_APP_VERSION = 273;
 
 module.exports = ({ headers: { appversion, appdevice } }, res, next) => {
   if (appdevice && !appversion) return res.status(403).send({ ok: false, sendInApp: ["Veuillez mettre à jour votre application!"] });
-  if (appdevice && Number(appversion) < MINIMUM_MOBILE_APP_VERSION)
+  if (appdevice && Number(appversion) < MINIMUM_MOBILE_APP_VERSION) {
+    const iosLink = "https://apps.apple.com/fr/app/oz-ensemble/id1498190343";
+    const androidLink = "https://play.google.com/store/apps/details?id=fr.gouv.ozensemble";
+
     return res.status(403).send({
       ok: false,
       sendInApp: [
         "Votre application n'est pas à jour !",
         "Vous pouvez la mettre à jour en cliquant sur le lien ci-dessous",
-        [{ text: "Mettre à jour", link: "https://ozensemble.fabrique.social.gouv.fr" }],
+        [{ text: "Mettre à jour", link: appdevice === "ios" ? iosLink : androidLink }],
         { cancelable: true },
       ],
     });
+  }
   return next();
 };