From a0e0d8bd32f7e485b9026c95351adc9aab454258 Mon Sep 17 00:00:00 2001
From: Hentry Martin <hentrymartin.p@gmail.com>
Date: Fri, 2 May 2025 10:30:20 +0200
Subject: [PATCH 1/3] fix: return existing application instead of throwing an
 error

---
 docs/swagger.yaml                            | 44 +++++++++++++++++++-
 src/routes/copilotOpportunityApply/create.js |  5 +--
 2 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index e38fbe25..dbadf9e6 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -487,9 +487,9 @@ paths:
             $ref: "#/definitions/ApplyCopilotOpportunity"
       responses:
         "200":
-          description: "The copilot opportunity"
+          description: "The copilot opportunity application"
           schema:
-            $ref: "#/definitions/CopilotOpportunity"
+            $ref: "#/definitions/CopilotOpportunityApplication"
         "401":
           description: "Unauthorized"
           schema:
@@ -6013,6 +6013,46 @@ definitions:
         format: int64
         description: READ-ONLY. User that last updated this task
         readOnly: true
+  CopilotOpportunityApplication:
+    type: object
+    properties:
+      id:
+        description: unique identifier
+        type: integer
+        format: int64
+      notes:
+        description: notes regarding the application
+        type: string
+      opportunityId:
+        description: copilot request id
+        type: integer
+      createdAt:
+        type: string
+        description: Datetime (GMT) when task was created
+        readOnly: true
+      createdBy:
+        type: integer
+        format: int64
+        description: READ-ONLY. User who created this task
+        readOnly: true
+      updatedAt:
+        type: string
+        description: READ-ONLY. Datetime (GMT) when task was updated
+        readOnly: true
+      updatedBy:
+        type: integer
+        format: int64
+        description: READ-ONLY. User that last updated this task
+        readOnly: true
+      deletedAt:
+        type: string
+        description: READ-ONLY. Datetime (GMT) when task was deleted
+        readOnly: true
+      deletedBy:
+        type: integer
+        format: int64
+        description: READ-ONLY. User that deleted this task
+        readOnly: true
   Project:
     type: object
     properties:
diff --git a/src/routes/copilotOpportunityApply/create.js b/src/routes/copilotOpportunityApply/create.js
index dcf2cbe5..0093a217 100644
--- a/src/routes/copilotOpportunityApply/create.js
+++ b/src/routes/copilotOpportunityApply/create.js
@@ -60,9 +60,8 @@ module.exports = [
       });
 
       if (existingApplication) {
-        const err = new Error('User already applied for this opportunity');
-        err.status = 400;
-        return next(err);
+        res.status(200).json(existingApplication);
+        return Promise.resolve();
       }
   
       return models.CopilotApplication.create(data)

From 7be3b140103bf7c8a01fd5630cd5fc9459400313 Mon Sep 17 00:00:00 2001
From: Hentry Martin <hentrymartin.p@gmail.com>
Date: Fri, 2 May 2025 10:30:42 +0200
Subject: [PATCH 2/3] fix: return existing application instead of throwing an
 error

---
 .circleci/config.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 3dd6a457..6b4560c1 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -149,7 +149,7 @@ workflows:
           context : org-global
           filters:
             branches:
-              only: ['develop', 'migration-setup', 'PM-577']
+              only: ['develop', 'migration-setup', 'pm-577_1']
       - deployProd:
           context : org-global
           filters:

From 1bd520d41794b81db27a2a2346bd8a4eacbadcd7 Mon Sep 17 00:00:00 2001
From: Hentry Martin <hentrymartin.p@gmail.com>
Date: Fri, 2 May 2025 17:48:46 +0200
Subject: [PATCH 3/3] removed circle branch config

---
 .circleci/config.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 6b4560c1..1acd4a4c 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -149,7 +149,7 @@ workflows:
           context : org-global
           filters:
             branches:
-              only: ['develop', 'migration-setup', 'pm-577_1']
+              only: ['develop', 'migration-setup']
       - deployProd:
           context : org-global
           filters: