Quellcode durchsuchen

filter tpds users by dropbox

GitOrigin-RevId: ea1222597a9b3e807100abcc2bea957db7faee5f
Ersun Warncke vor 6 Jahren
Ursprung
Commit
5e84d95291

+ 2 - 1
services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateSender.js

@@ -125,7 +125,8 @@ async function getProjectUsersIds(projectId) {
   // filter list to only return users with dropbox linked
   const users = await UserGetter.getUsers(
     {
-      _id: { $in: projectUserIds }
+      _id: { $in: projectUserIds },
+      'dropbox.access_token.uid': { $ne: null }
     },
     {
       _id: 1

+ 0 - 3
services/web/app/src/Features/User/UserGetter.js

@@ -129,9 +129,6 @@ const UserGetter = {
   },
 
   getUsers(query, projection, callback) {
-    if (!query) {
-      return callback(new Error('no query provided'))
-    }
     normalizeQuery(query, (err, query) => {
       if (err) return callback(err)
       db.users.find(query, projection, callback)

+ 70 - 0
services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js

@@ -141,6 +141,20 @@ describe('TpdsUpdateSender', function() {
       job2.headers.sl_all_user_ids.should.equal(
         JSON.stringify(['read_only_ref_1_id_here'])
       )
+
+      this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
+        {
+          _id: {
+            $in: [
+              'user_id_here',
+              'collaberator_ref_1_here',
+              'read_only_ref_1_id_here'
+            ]
+          },
+          'dropbox.access_token.uid': { $ne: null }
+        },
+        { _id: 1 }
+      )
     })
 
     it('post doc with stream origin of docstore', async function() {
@@ -185,6 +199,20 @@ describe('TpdsUpdateSender', function() {
       job2.headers.sl_all_user_ids.should.equal(
         JSON.stringify(['read_only_ref_1_id_here'])
       )
+
+      this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
+        {
+          _id: {
+            $in: [
+              'user_id_here',
+              'collaberator_ref_1_here',
+              'read_only_ref_1_id_here'
+            ]
+          },
+          'dropbox.access_token.uid': { $ne: null }
+        },
+        { _id: 1 }
+      )
     })
 
     it('deleting entity', async function() {
@@ -222,6 +250,20 @@ describe('TpdsUpdateSender', function() {
       job2.headers.sl_all_user_ids.should.equal(
         JSON.stringify(['read_only_ref_1_id_here'])
       )
+
+      this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
+        {
+          _id: {
+            $in: [
+              'user_id_here',
+              'collaberator_ref_1_here',
+              'read_only_ref_1_id_here'
+            ]
+          },
+          'dropbox.access_token.uid': { $ne: null }
+        },
+        { _id: 1 }
+      )
     })
 
     it('moving entity', async function() {
@@ -262,6 +304,20 @@ describe('TpdsUpdateSender', function() {
       job2.headers.sl_all_user_ids.should.equal(
         JSON.stringify(['read_only_ref_1_id_here'])
       )
+
+      this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
+        {
+          _id: {
+            $in: [
+              'user_id_here',
+              'collaberator_ref_1_here',
+              'read_only_ref_1_id_here'
+            ]
+          },
+          'dropbox.access_token.uid': { $ne: null }
+        },
+        { _id: 1 }
+      )
     })
 
     it('should be able to rename a project using the move entity func', async function() {
@@ -301,6 +357,20 @@ describe('TpdsUpdateSender', function() {
       job2.headers.sl_all_user_ids.should.equal(
         JSON.stringify(['read_only_ref_1_id_here'])
       )
+
+      this.UserGetter.promises.getUsers.should.have.been.calledOnce.and.calledWith(
+        {
+          _id: {
+            $in: [
+              'user_id_here',
+              'collaberator_ref_1_here',
+              'read_only_ref_1_id_here'
+            ]
+          },
+          'dropbox.access_token.uid': { $ne: null }
+        },
+        { _id: 1 }
+      )
     })
 
     it('pollDropboxForUser', async function() {