filter tpds users by dropbox

GitOrigin-RevId: ea1222597a9b3e807100abcc2bea957db7faee5f
This commit is contained in:
Ersun Warncke 2020-06-05 00:10:46 -04:00 committed by Copybot
parent 387695c2b1
commit 5e84d95291
3 changed files with 72 additions and 4 deletions

View file

@ -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

View file

@ -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)

View file

@ -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() {