From a46eb2418a61f8424ed3fac92c620634662b5de0 Mon Sep 17 00:00:00 2001
From: Timothy Carambat <rambat1010@gmail.com>
Date: Thu, 12 Dec 2024 10:44:11 -0800
Subject: [PATCH] add Gitlab to watchable documents (#2817)

---
 server/endpoints/api/workspace/index.js | 10 ++++------
 server/jobs/sync-watched-documents.js   |  2 +-
 server/models/documentSyncQueue.js      |  5 +++--
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/server/endpoints/api/workspace/index.js b/server/endpoints/api/workspace/index.js
index 2b0ad577d..4b781d887 100644
--- a/server/endpoints/api/workspace/index.js
+++ b/server/endpoints/api/workspace/index.js
@@ -919,12 +919,10 @@ function apiWorkspaceEndpoints(app) {
         const embeddingsCount = await VectorDb.namespaceCount(workspace.slug);
 
         if (!hasVectorizedSpace || embeddingsCount === 0)
-          return response
-            .status(200)
-            .json({
-              results: [],
-              message: "No embeddings found for this workspace.",
-            });
+          return response.status(200).json({
+            results: [],
+            message: "No embeddings found for this workspace.",
+          });
 
         const parseSimilarityThreshold = () => {
           let input = parseFloat(scoreThreshold);
diff --git a/server/jobs/sync-watched-documents.js b/server/jobs/sync-watched-documents.js
index c4f235a0d..43dbf7515 100644
--- a/server/jobs/sync-watched-documents.js
+++ b/server/jobs/sync-watched-documents.js
@@ -46,7 +46,7 @@ const { DocumentSyncRun } = require('../models/documentSyncRun.js');
         newContent = response?.content;
       }
 
-      if (type === 'confluence' || type === 'github') {
+      if (type === 'confluence' || type === 'github' || type === 'gitlab') {
         const response = await collector.forwardExtensionRequest({
           endpoint: "/ext/resync-source-document",
           method: "POST",
diff --git a/server/models/documentSyncQueue.js b/server/models/documentSyncQueue.js
index 0ebaa0529..b2142a75a 100644
--- a/server/models/documentSyncQueue.js
+++ b/server/models/documentSyncQueue.js
@@ -4,13 +4,13 @@ const { SystemSettings } = require("./systemSettings");
 const { Telemetry } = require("./telemetry");
 
 /**
- * @typedef {('link'|'youtube'|'confluence'|'github')} validFileType
+ * @typedef {('link'|'youtube'|'confluence'|'github'|'gitlab')} validFileType
  */
 
 const DocumentSyncQueue = {
   featureKey: "experimental_live_file_sync",
   // update the validFileTypes and .canWatch properties when adding elements here.
-  validFileTypes: ["link", "youtube", "confluence", "github"],
+  validFileTypes: ["link", "youtube", "confluence", "github", "gitlab"],
   defaultStaleAfter: 604800000,
   maxRepeatFailures: 5, // How many times a run can fail in a row before pruning.
   writable: [],
@@ -51,6 +51,7 @@ const DocumentSyncQueue = {
     if (chunkSource.startsWith("youtube://")) return true; // If is a youtube link
     if (chunkSource.startsWith("confluence://")) return true; // If is a confluence document link
     if (chunkSource.startsWith("github://")) return true; // If is a Github file reference
+    if (chunkSource.startsWith("gitlab://")) return true; // If is a Gitlab file reference
     return false;
   },
 
-- 
GitLab